Skip to content

Commit 5409042

Browse files
authored
Merge pull request #527 from EasyPost/SHPE-594_sessions
feat: portal and embeddable sessions
2 parents 0e6110f + 34eeaef commit 5409042

File tree

20 files changed

+1724
-1091
lines changed

20 files changed

+1724
-1091
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## Next Release
4+
5+
- Adds the following functions:
6+
- `embeddable.createSession`
7+
- `customerPortal.createAccountLink`
8+
- Bumps dependencies
9+
310
## v8.3.0 (2025-11-10)
411

512
- Adds support for `UspsShipAccount`

package-lock.json

Lines changed: 850 additions & 1072 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@pollyjs/persister-fs": "^6.0.6",
5555
"@typescript-eslint/eslint-plugin": "^5.59.5",
5656
"@typescript-eslint/parser": "^5.59.5",
57-
"@vitest/coverage-istanbul": "^3.0.6",
57+
"@vitest/coverage-istanbul": "^4.0.10",
5858
"audit-ci": "^7.1",
5959
"chai": "5.2",
6060
"chai-as-promised": "^8.0.1",
@@ -74,7 +74,7 @@
7474
"typescript": "^4.9.5 || ~5.0.0",
7575
"vite": "^6.2",
7676
"vite-plugin-externals": "^0.6.2",
77-
"vitest": "^3.0.6",
77+
"vitest": "^4.0.10",
7878
"vows": "^0.8.3"
7979
}
8080
}

src/easypost.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import CarrierAccountService from './services/carrier_account_service';
1717
import CarrierMetadataService from './services/carrier_metadata_service';
1818
import CarrierTypeService from './services/carrier_type_service';
1919
import ClaimService from './services/claim_service';
20+
import CustomerPortalService from './services/customer_portal_service';
2021
import CustomsInfoService from './services/customs_info_service';
2122
import CustomsItemService from './services/customs_item_service';
23+
import EmbeddableService from './services/embeddable_service';
2224
import EndShipperService from './services/end_shipper_service';
2325
import EventService from './services/event_service';
2426
import InsuranceService from './services/insurance_service';
@@ -367,8 +369,10 @@ EasyPostClient.SERVICES = {
367369
CarrierMetadata: CarrierMetadataService,
368370
CarrierType: CarrierTypeService,
369371
Claim: ClaimService,
372+
CustomerPortal: CustomerPortalService,
370373
CustomsInfo: CustomsInfoService,
371374
CustomsItem: CustomsItemService,
375+
Embeddable: EmbeddableService,
372376
EndShipper: EndShipperService,
373377
Event: EventService,
374378
Insurance: InsuranceService,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import baseService from './base_service';
2+
3+
export default (easypostClient) =>
4+
/**
5+
* The CustomerPortalService class provides methods for interacting with EasyPost {@link Tracker} objects.
6+
* @param {EasyPostClient} easypostClient - The pre-configured EasyPostClient instance to use for API requests with this service.
7+
*/
8+
class CustomerPortalService extends baseService(easypostClient) {
9+
/**
10+
* Create a Portal Session.
11+
* @param {Object} [params] - The parameters to create a session from.
12+
* @returns {Object} - An object containing the created session.
13+
*/
14+
static async createAccountLink(params = {}) {
15+
const url = 'customer_portal/account_link';
16+
17+
try {
18+
const response = await easypostClient._post(url, params);
19+
20+
return this._convertToEasyPostObject(response.body, params);
21+
} catch (e) {
22+
return Promise.reject(e);
23+
}
24+
}
25+
};

src/services/embeddable_service.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import baseService from './base_service';
2+
3+
export default (easypostClient) =>
4+
/**
5+
* The EmbeddableService class provides methods for interacting with EasyPost {@link Tracker} objects.
6+
* @param {EasyPostClient} easypostClient - The pre-configured EasyPostClient instance to use for API requests with this service.
7+
*/
8+
class EmbeddableService extends baseService(easypostClient) {
9+
/**
10+
* Create an Embeddable Session.
11+
* @param {Object} [params] - The parameters to create a session from.
12+
* @returns {Object} - An object containing the created session.
13+
*/
14+
static async createSession(params = {}) {
15+
const url = 'embeddables/session';
16+
17+
try {
18+
const response = await easypostClient._post(url, params);
19+
20+
return this._convertToEasyPostObject(response.body, params);
21+
} catch (e) {
22+
return Promise.reject(e);
23+
}
24+
}
25+
};

0 commit comments

Comments
 (0)