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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## v8.9.0 (2026-06-25)

- Adds `params` to `requestPin` ensuring users can pass `easypost_details` to the call.
- Bumps dependencies

## v8.8.0 (2026-03-03)

- Adds `IAddressVerificationFieldError` Typescript interface, replacing `IFieldError` on `Verification`
Expand Down
1,461 changes: 762 additions & 699 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@easypost/api",
"description": "EasyPost Node Client Library",
"version": "8.8.0",
"version": "8.9.0",
"author": "Easypost Engineering <oss@easypost.com>",
"homepage": "https://easypost.com",
"exports": {
Expand Down Expand Up @@ -48,6 +48,7 @@
"@pollyjs/adapter-node-http": "^6.0.6",
"@pollyjs/core": "^6.0.6",
"@pollyjs/persister-fs": "^6.0.6",
"@types/node": "^20.17.57",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitest/coverage-istanbul": "^4.0.18",
Expand Down
16 changes: 8 additions & 8 deletions src/services/fedex_registration_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default (easypostClient) =>

try {
const response = await easypostClient._post(endpoint, wrappedParams);
return this._convertToEasyPostObject(response.body, params);
return this._convertToEasyPostObject(response.body, wrappedParams);
} catch (e) {
return Promise.reject(e);
}
Expand All @@ -30,13 +30,13 @@ export default (easypostClient) =>
* Request a PIN for FedEx account verification.
* @param {string} fedexAccountNumber - The FedEx account number.
* @param {string} pinMethodOption - The PIN delivery method: "SMS", "CALL", or "EMAIL".
* @param {Object} params - Map of parameters.
* @returns {Object}
*/
static async requestPin(fedexAccountNumber, pinMethodOption) {
const wrappedParams = {
pin_method: {
option: pinMethodOption,
},
static async requestPin(fedexAccountNumber, pinMethodOption, params) {
const wrappedParams = this._wrapPinValidation(params);
wrappedParams.pin_method = {
option: pinMethodOption,
};
const endpoint = `fedex_registrations/${fedexAccountNumber}/pin`;

Expand All @@ -60,7 +60,7 @@ export default (easypostClient) =>

try {
const response = await easypostClient._post(endpoint, wrappedParams);
return this._convertToEasyPostObject(response.body, params);
return this._convertToEasyPostObject(response.body, wrappedParams);
} catch (e) {
return Promise.reject(e);
}
Expand All @@ -78,7 +78,7 @@ export default (easypostClient) =>

try {
const response = await easypostClient._post(endpoint, wrappedParams);
return this._convertToEasyPostObject(response.body, params);
return this._convertToEasyPostObject(response.body, wrappedParams);
} catch (e) {
return Promise.reject(e);
}
Expand Down
9 changes: 3 additions & 6 deletions test/helpers/setup_polly.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,10 @@ function setupCassette(server) {
function setupPollyTests() {
/** @type {Polly} */
let polly;
let suiteName;

beforeAll(async ({ name }) => {
suiteName = name;
});

beforeEach((context) => {
const suiteName = context.task?.suite?.name || 'unknown-suite';

polly = new Polly(`${suiteName}/${context.task.name}`, {
adapters: ['node-http'],
persister: 'fs',
Expand All @@ -146,4 +143,4 @@ function setupPollyTests() {
return () => polly;
}

export { setupPollyTests, setupCassette };
export { setupCassette, setupPollyTests };
8 changes: 7 additions & 1 deletion test/services/fedex_registration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ describe('FedExRegistrationService', function () {
it('requests a pin', async function () {
const fedexAccountNumber = '123456789';

const params = {
easypost_details: {
carrier_account_id: 'ca_123',
},
};

const mockResponse = {
message: 'sent secured Pin',
};
Expand All @@ -84,7 +90,7 @@ describe('FedExRegistrationService', function () {
requestMiddleware: middleware,
});

const response = await client.FedExRegistration.requestPin(fedexAccountNumber, 'SMS');
const response = await client.FedExRegistration.requestPin(fedexAccountNumber, 'SMS', params);

expect(response.message).to.equal('sent secured Pin');
});
Expand Down
8 changes: 8 additions & 0 deletions types/FedExRegistration/FedExRegistration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,19 @@ declare class FedExRegistration {
*
* @param fedexAccountNumber The FedEx account number.
* @param pinMethodOption The PIN delivery method: "SMS", "CALL", or "EMAIL".
* @param params Parameters including easypost_details.
* @returns {Promise<IFedExRequestPinResponse>} Response object confirming PIN was sent.
*/
static requestPin(
fedexAccountNumber: string,
pinMethodOption: string,
params: {
easypost_details?: {
action?: string;
type?: string;
carrier_account_id?: string;
};
},
): Promise<IFedExRequestPinResponse>;

/**
Expand Down
Loading