Skip to content

Commit e03a9bf

Browse files
authored
Merge pull request #362 from EasyPost/SHPE-594_sessions
feat: customer portal and embeddable sessions
2 parents 83c309d + f8002ec commit e03a9bf

File tree

10 files changed

+582
-60
lines changed

10 files changed

+582
-60
lines changed

CHANGELOG.md

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

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

511
- Adds support for `UspsShipAccount`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.easypost.model;
2+
3+
import java.util.Date;
4+
import lombok.Getter;
5+
6+
@Getter
7+
public class CustomerPortalAccountLink {
8+
private String object;
9+
private String link;
10+
private Date createdAt;
11+
private Date expiresAt;
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.easypost.model;
2+
3+
import java.util.Date;
4+
import lombok.Getter;
5+
6+
@Getter
7+
public class EmbeddablesSession {
8+
private String object;
9+
private String sessionId;
10+
private Date createdAt;
11+
private Date expiresAt;
12+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.easypost.service;
2+
3+
import java.util.Map;
4+
5+
import com.easypost.exception.EasyPostException;
6+
import com.easypost.http.Requestor;
7+
import com.easypost.http.Requestor.RequestMethod;
8+
import com.easypost.model.CustomerPortalAccountLink;
9+
10+
public class CustomerPortalService {
11+
private final EasyPostClient client;
12+
13+
/**
14+
* CustomerPortalService constructor.
15+
*
16+
* @param client The client object.
17+
*/
18+
CustomerPortalService(EasyPostClient client) {
19+
this.client = client;
20+
}
21+
22+
/**
23+
* Create a CustomerPortalAccountLink from the API.
24+
*
25+
* @param params Map of parameters.
26+
* @return CustomerPortalAccountLink object
27+
* @throws EasyPostException when the request fails.
28+
*/
29+
public CustomerPortalAccountLink createAccountLink(final Map<String, Object> params) throws EasyPostException {
30+
String endpoint = "customer_portal/account_link";
31+
32+
return Requestor.request(RequestMethod.POST, endpoint, params, CustomerPortalAccountLink.class, client);
33+
}
34+
}

src/main/java/com/easypost/service/EasyPostClient.java

Lines changed: 33 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,39 @@ public class EasyPostClient {
1717
private final String clientApiKey; // API key for all EasyPost API requests
1818
private final String apiVersion = "v2";
1919
private final String apiBase;
20-
public final AddressService address;
21-
public final ApiKeyService apiKey;
22-
public final BatchService batch;
23-
public final BetaReferralCustomerService betaReferralCustomer;
24-
public final BetaRateService betaRate;
25-
public final BillingService billing;
26-
public final CarrierAccountService carrierAccount;
27-
public final CarrierMetadataService carrierMetadata;
28-
public final CarrierTypeService carrierType;
29-
public final ClaimService claim;
30-
public final CustomsInfoService customsInfo;
31-
public final CustomsItemService customsItem;
32-
public final EndShipperService endShipper;
33-
public final EventService event;
34-
public final InsuranceService insurance;
35-
public final LumaService luma;
36-
public final OrderService order;
37-
public final ParcelService parcel;
38-
public final PaymentMethodService paymentMethod;
39-
public final PickupService pickup;
40-
public final RateService rate;
41-
public final ReferralCustomerService referralCustomer;
42-
public final RefundService refund;
43-
public final ReportService report;
44-
public final ScanformService scanForm;
45-
public final ShipmentService shipment;
46-
public final SmartRateService smartRate;
47-
public final TrackerService tracker;
48-
public final UserService user;
49-
public final WebhookService webhook;
20+
// Services
21+
public final AddressService address = new AddressService(this);
22+
public final ApiKeyService apiKey = new ApiKeyService(this);
23+
public final BatchService batch = new BatchService(this);
24+
public final BetaRateService betaRate = new BetaRateService(this);
25+
public final BetaReferralCustomerService betaReferralCustomer = new BetaReferralCustomerService(this);
26+
public final BillingService billing = new BillingService(this);
27+
public final CarrierAccountService carrierAccount = new CarrierAccountService(this);
28+
public final CarrierMetadataService carrierMetadata = new CarrierMetadataService(this);
29+
public final CarrierTypeService carrierType = new CarrierTypeService(this);
30+
public final ClaimService claim = new ClaimService(this);
31+
public final CustomerPortalService customerPortal = new CustomerPortalService(this);
32+
public final CustomsInfoService customsInfo = new CustomsInfoService(this);
33+
public final CustomsItemService customsItem = new CustomsItemService(this);
34+
public final EmbeddableService embeddable = new EmbeddableService(this);
35+
public final EndShipperService endShipper = new EndShipperService(this);
36+
public final EventService event = new EventService(this);
37+
public final InsuranceService insurance = new InsuranceService(this);
38+
public final LumaService luma = new LumaService(this);
39+
public final OrderService order = new OrderService(this);
40+
public final ParcelService parcel = new ParcelService(this);
41+
public final PaymentMethodService paymentMethod = new PaymentMethodService(this);
42+
public final PickupService pickup = new PickupService(this);
43+
public final RateService rate = new RateService(this);
44+
public final ReferralCustomerService referralCustomer = new ReferralCustomerService(this);
45+
public final RefundService refund = new RefundService(this);
46+
public final ReportService report = new ReportService(this);
47+
public final ScanformService scanForm = new ScanformService(this);
48+
public final ShipmentService shipment = new ShipmentService(this);
49+
public final SmartRateService smartRate = new SmartRateService(this);
50+
public final TrackerService tracker = new TrackerService(this);
51+
public final UserService user = new UserService(this);
52+
public final WebhookService webhook = new WebhookService(this);
5053
@Getter
5154
private RequestHook requestHooks = new RequestHook();
5255
@Getter
@@ -129,36 +132,6 @@ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, int readTim
129132
this.clientApiKey = apiKey;
130133
this.connectTimeoutMilliseconds = connectTimeoutMilliseconds;
131134
this.readTimeoutMilliseconds = readTimeoutMilliseconds;
132-
this.address = new AddressService(this);
133-
this.apiKey = new ApiKeyService(this);
134-
this.batch = new BatchService(this);
135-
this.betaReferralCustomer = new BetaReferralCustomerService(this);
136-
this.betaRate = new BetaRateService(this);
137-
this.billing = new BillingService(this);
138-
this.carrierAccount = new CarrierAccountService(this);
139-
this.carrierMetadata = new CarrierMetadataService(this);
140-
this.carrierType = new CarrierTypeService(this);
141-
this.claim = new ClaimService(this);
142-
this.customsInfo = new CustomsInfoService(this);
143-
this.customsItem = new CustomsItemService(this);
144-
this.endShipper = new EndShipperService(this);
145-
this.event = new EventService(this);
146-
this.insurance = new InsuranceService(this);
147-
this.luma = new LumaService(this);
148-
this.order = new OrderService(this);
149-
this.parcel = new ParcelService(this);
150-
this.paymentMethod = new PaymentMethodService(this);
151-
this.pickup = new PickupService(this);
152-
this.rate = new RateService(this);
153-
this.referralCustomer = new ReferralCustomerService(this);
154-
this.refund = new RefundService(this);
155-
this.report = new ReportService(this);
156-
this.scanForm = new ScanformService(this);
157-
this.shipment = new ShipmentService(this);
158-
this.smartRate = new SmartRateService(this);
159-
this.tracker = new TrackerService(this);
160-
this.user = new UserService(this);
161-
this.webhook = new WebhookService(this);
162135
}
163136

164137
/**
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.easypost.service;
2+
3+
import java.util.Map;
4+
5+
import com.easypost.exception.EasyPostException;
6+
import com.easypost.http.Requestor;
7+
import com.easypost.http.Requestor.RequestMethod;
8+
import com.easypost.model.EmbeddablesSession;
9+
10+
public class EmbeddableService {
11+
private final EasyPostClient client;
12+
13+
/**
14+
* EmbeddableService constructor.
15+
*
16+
* @param client The client object.
17+
*/
18+
EmbeddableService(EasyPostClient client) {
19+
this.client = client;
20+
}
21+
22+
/**
23+
* Create an EmbeddablesSession from the API.
24+
*
25+
* @param params Map of parameters.
26+
* @return EmbeddablesSession object
27+
* @throws EasyPostException when the request fails.
28+
*/
29+
public EmbeddablesSession createSession(final Map<String, Object> params) throws EasyPostException {
30+
String endpoint = "embeddables/session";
31+
32+
return Requestor.request(RequestMethod.POST, endpoint, params, EmbeddablesSession.class, client);
33+
}
34+
}

src/test/cassettes/customer_portal/create_account_link.json

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

0 commit comments

Comments
 (0)