@commercelayer/sdk
Advanced tools
Comparing version 1.3.1 to 1.3.2
module.exports = require('./lib/clayer') | ||
// Model Extension | ||
module.exports.model = require('./lib/model') | ||
module.exports.query = require('./lib/query') | ||
// QueryFilter Extension | ||
module.exports.query = require('./lib/query') |
@@ -23,4 +23,4 @@ const axios = require('axios') | ||
} | ||
setScope(value) { this.scope = value; return this; } | ||
marketScope(value) { this.scope = (value != undefined)? 'market:'+value : value; return this; } | ||
setScope(scope) { this.scope = scope; return this; } | ||
marketScope(market) { this.scope = (market != undefined)? 'market:'+market : market; return this; } | ||
} | ||
@@ -36,2 +36,4 @@ | ||
} | ||
setCode(code) { this.code = code; return this; } | ||
redirectUri(uri) { this.redirect_uri = uri; return this; } | ||
} | ||
@@ -47,2 +49,4 @@ | ||
} | ||
setUsername(username) { this.username = username; return this; } | ||
setPassword(password) { this.password = password; return this; } | ||
} | ||
@@ -56,2 +60,3 @@ | ||
} | ||
refreshToken(token) { this.refresh_token = token; return this; } | ||
} | ||
@@ -58,0 +63,0 @@ |
@@ -8,2 +8,9 @@ const api = require('./api') | ||
// Expose SDK configuration | ||
module.exports.settings = config.sdk; | ||
// Probe function | ||
module.exports.hey = () => { return 'Hello!' } | ||
// SDK initialization | ||
module.exports.initialize = (cfg) => { | ||
@@ -17,5 +24,1 @@ if (cfg != undefined) cfg.default = false; | ||
} | ||
module.exports.settings = config.sdk; | ||
module.exports.hey = () => { return 'Hello!' } |
@@ -14,5 +14,6 @@ const axios = require('axios') | ||
if (config.base_url == undefined) throw 'missing base_url'; | ||
if (config.market_id == undefined) throw 'missing market_id'; | ||
if (config.client_id == undefined) throw 'missing client_id'; | ||
// TODO: verificare configurazione in base al tipo di autenticazione (da rendere configurabile) | ||
utils.log('config ok.') | ||
@@ -119,3 +120,5 @@ | ||
return auth.authenticate( | ||
new auth.ClientCredentials(this.config.client_id).marketScope(this.config.market_id) | ||
new auth.ClientCredentials(this.config.client_id) | ||
.marketScope(this.config.market_id) | ||
.clientSecret(this.config.client_secret) | ||
) | ||
@@ -122,0 +125,0 @@ .then(token => { |
@@ -8,8 +8,9 @@ | ||
client_id : null, | ||
market_id : null, | ||
base_url : null, | ||
base_path : null, | ||
country_code : 'US', | ||
language_code : 'en', | ||
client_id : null, | ||
market_id : null, | ||
client_secret : null, | ||
base_url : null, | ||
base_path : null, | ||
country_code : 'US', | ||
language_code : 'en', | ||
@@ -23,3 +24,3 @@ }, | ||
auth_attempts : 1, // number of attempts of authentication | ||
response_type : 'normalized', // Resonse format. possible values are: normalized | jsonapi | model | raw | ||
response_type : 'normalized', // Response format, possible values are: normalized | jsonapi | model | raw | ||
timeout : { // in milliseconds | ||
@@ -26,0 +27,0 @@ retry : 250, // retry after authentication request in progress detected |
@@ -41,2 +41,7 @@ | ||
filters(filters) { | ||
if (filters != undefined) Object.keys(filters).forEach(filter => { this.filter(filter, filters[filter]) }) | ||
return this; | ||
} | ||
param(key, value) { | ||
@@ -47,2 +52,7 @@ if ((key != undefined) && (value != undefined)) this.custom_params[key] = value; | ||
params(params) { | ||
if (params != undefined) Object.keys(params).forEach(key => { this.param(key, params[key]) }) | ||
return this; | ||
} | ||
page(number, size) { | ||
@@ -65,3 +75,3 @@ this.pageNumber(number); | ||
nextPage() { | ||
this.page_number = page_number? page_number++ : 1; | ||
this.page_number = (this.page_number && Number.isInteger(this.pageNumber))? page_number++ : 1; | ||
return this; | ||
@@ -68,0 +78,0 @@ } |
@@ -6,3 +6,3 @@ | ||
log : (message) => { | ||
log : (message) => { // BWC | ||
log.msg(message); | ||
@@ -9,0 +9,0 @@ }, |
{ | ||
"name": "@commercelayer/sdk", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "The Official Commerce Layer JS SDK", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
945990
6823