Skip to content

Commit

Permalink
fix(api-core): resources incorrectly handling config
Browse files Browse the repository at this point in the history
some resources could not handle undefined config
providers would throw away any passed in params in config
  • Loading branch information
Kasey Powers committed Jan 4, 2018
1 parent 2443bc0 commit 9a5de1c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions packages/api-core/src/resources/organizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export default class AvOrganizations extends AvApi {
}

queryOrganizations(user, config) {
const params = Object.assign({}, { userId: user.id }, config.params || {});
return this.query(Object.assign({}, { params }, config));
const queryConfig = Object.assign({ params: {} }, config);
queryConfig.params = Object.assign({ userId: user.id }, queryConfig.params);
return this.query(queryConfig);
}

getOrganizations(config) {
Expand Down
10 changes: 3 additions & 7 deletions packages/api-core/src/resources/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ export default class AvProviders extends AvApi {
super(http, promise, options);
}

getProviders(customerId, config = {}) {
let queryConfig = {
params: {
customerId,
},
};
getProviders(customerId, config) {
const queryConfig = Object.assign({ params: {} }, config);
queryConfig.params = Object.assign({ customerId }, queryConfig.params);

queryConfig = Object.assign({}, queryConfig, config);
return this.query(queryConfig);
}
}
9 changes: 6 additions & 3 deletions packages/api-core/src/resources/regions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ export default class AvRegions extends AvApi {

getRegions(config) {
return this.avUsers.me().then(user => {
config.params = config.params || {};
config.params.userId = config.params.userId || user.id;
return this.query(config);
const queryConfig = Object.assign({ params: {} }, config);
queryConfig.params = Object.assign(
{ userId: user.id },
queryConfig.params
);
return this.query(queryConfig);
});
}

Expand Down

0 comments on commit 9a5de1c

Please sign in to comment.