Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `betaReferralCustomer.createBankAccountClientSecret`
- `referralCustomer.addCreditCardFromStripe`
- `referralCustomer.addBankAccountFromStripe`
- Routes `AmazonShippingAccount` to the correct endpoint on create
- Fixes all references to the docs
- Properly returns the response body of the following functions: `addPaymentMethod`, `refundByAmount`, `refundByPaymentLog`
- `findMatchingMockRequest` mocking function made private
Expand Down
3 changes: 3 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export default class Constants {
static get UPS_OAUTH_CARRIER_TYPES() {
return ['UpsAccount', 'UpsMailInnovationsAccount', 'UpsSurepostAccount'];
}
static get CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH() {
return ['AmazonShippingAccount'];
}
static EXTERNAL_API_CALL_FAILED = 'Communication with %s failed, please try again later';
static INVALID_API_KEY_TYPE = 'Invalid API key type.';
static INVALID_PARAMETER = 'Invalid parameter: %s.';
Expand Down
9 changes: 7 additions & 2 deletions src/services/carrier_account_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ export default (easypostClient) =>
static _selectCarrierAccountCreationEndpoint(carrierAccountType) {
if (Constants.CARRIER_ACCOUNTS_WITH_CUSTOM_CREATE_WORKFLOWS.includes(carrierAccountType)) {
return 'carrier_accounts/register';
}
if (Constants.UPS_OAUTH_CARRIER_TYPES.includes(carrierAccountType)) {
} else if (Constants.UPS_OAUTH_CARRIER_TYPES.includes(carrierAccountType)) {
return 'ups_oauth_registrations';
} else if (Constants.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.includes(carrierAccountType)) {
return 'carrier_accounts/register_oauth';
}

return 'carrier_accounts';
}

Expand Down Expand Up @@ -113,7 +115,10 @@ export default (easypostClient) =>
static _wrapCarrierAccountParams(carrierAccountType, params) {
if (Constants.UPS_OAUTH_CARRIER_TYPES.includes(carrierAccountType)) {
return { ups_oauth_registrations: params };
} else if (Constants.CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH.includes(carrierAccountType)) {
return { carrier_account_oauth_registrations: params };
}

return { carrier_account: params };
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion test/services/carrier_account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,20 @@ describe('CarrierAccount Service', function () {
expect(carrierAccount).to.be.an.instanceOf(CarrierAccount);
expect(carrierAccount.id).to.match(/^ca_/);
expect(carrierAccount.type).to.equal(type);
// account number not returned in API response, can't assert

await client.CarrierAccount.delete(carrierAccount.id);
});

it('creates an Amazon carrier account', async function () {
const type = 'AmazonShippingAccount';

const data = { type: type };

const carrierAccount = await client.CarrierAccount.create(data);

expect(carrierAccount).to.be.an.instanceOf(CarrierAccount);
expect(carrierAccount.id).to.match(/^ca_/);
expect(carrierAccount.type).to.equal(type);

await client.CarrierAccount.delete(carrierAccount.id);
});
Expand Down