@shipengine/js-api 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/funding-sources/api.d.ts +8 -4
- package/funding-sources/types.d.ts +30 -7
- package/index.js +31 -4
- package/index.mjs +31 -4
- package/package.json +1 -1
- package/service-points/api.d.ts +5 -1
- package/service-points/types.d.ts +5 -0
package/funding-sources/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { Money } from "../payments";
|
|
3
3
|
import { CreationRangeQuery, PageableQuery } from "../resources";
|
|
4
|
-
import { AddFundsResponse, CarrierRegistration, CarrierRegistrationResponse, CreateFundingSource, CreditCardInfo, FundingSource, FundingSourceAddress, FundingSourceTransactionsResponse, MetadataResponse } from "./types";
|
|
4
|
+
import { AddFundsResponse, CarrierRegistration, CarrierRegistrationResponse, CreateFundingSource, CreditCardInfo, FundingSource, FundingSourceAddress, FundingSourceCreateResponse, FundingSourceTransactionsResponse, InsuranceFundingSourceAcceptedTermsResponse, MetadataResponse } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* # Funding Sources API module - /v1/funding_sources
|
|
7
7
|
* Docs: https://auctane.atlassian.net/wiki/spaces/SE/pages/3628370266/ShipEngine+Funding+Sources+API
|
|
@@ -23,9 +23,7 @@ export declare class FundingSourcesAPI {
|
|
|
23
23
|
* The `create` method creates a new funding source for a given user. This requires
|
|
24
24
|
* payment information to be collected from the user.
|
|
25
25
|
*/
|
|
26
|
-
create: (createFundingSource: CreateFundingSource) => Promise<import("axios").AxiosResponse<
|
|
27
|
-
fundingSource: FundingSource;
|
|
28
|
-
}, any>>;
|
|
26
|
+
create: (createFundingSource: CreateFundingSource) => Promise<import("axios").AxiosResponse<FundingSourceCreateResponse, any>>;
|
|
29
27
|
/**
|
|
30
28
|
* The `update` method updates a funding source for a given user. This allows the
|
|
31
29
|
* user to update the billing address or payment information associated with the
|
|
@@ -53,4 +51,10 @@ export declare class FundingSourcesAPI {
|
|
|
53
51
|
* See the FundingSourceTransactions type for more information about return data.
|
|
54
52
|
*/
|
|
55
53
|
transactions: (fundingSourceId: string, params?: PageableQuery & CreationRangeQuery) => Promise<import("axios").AxiosResponse<FundingSourceTransactionsResponse, any>>;
|
|
54
|
+
/**
|
|
55
|
+
* Now we can attach insurance providers to the user's Funding Source.
|
|
56
|
+
* This endpoint will retrieve all accepted insurance terms. For example
|
|
57
|
+
* if "ParcelGuard" appears here that means the user its using it.
|
|
58
|
+
*/
|
|
59
|
+
insuranceAcceptedTerms: () => Promise<import("axios").AxiosResponse<InsuranceFundingSourceAcceptedTermsResponse, any>>;
|
|
56
60
|
}
|
|
@@ -25,6 +25,7 @@ export type AbbreviatedCreditCardInfo = {
|
|
|
25
25
|
cardNumberLastFour: string;
|
|
26
26
|
provider: Provider;
|
|
27
27
|
};
|
|
28
|
+
export type FundingSourceInsuranceProvider = "parcelguard" | "x_cover";
|
|
28
29
|
export type Provider = "visa" | "mastercard" | "americanExpress" | "discover";
|
|
29
30
|
export type FundingSourceCarrier = {
|
|
30
31
|
acceptedTerms: Term[];
|
|
@@ -34,8 +35,15 @@ export type FundingSourceCarrier = {
|
|
|
34
35
|
iovationBlackBox: IovationBlackBox;
|
|
35
36
|
pickupAddress?: FundingSourceAddress;
|
|
36
37
|
};
|
|
38
|
+
export type CarrierRegistrationInsuranceProvider = {
|
|
39
|
+
acceptedTerms: Term[];
|
|
40
|
+
agreeToTerms: boolean;
|
|
41
|
+
fundingSourceId: string;
|
|
42
|
+
provider: FundingSourceInsuranceProvider;
|
|
43
|
+
};
|
|
37
44
|
export interface CarrierRegistration {
|
|
38
|
-
carriers
|
|
45
|
+
carriers?: FundingSourceCarrier[];
|
|
46
|
+
insuranceProviders?: CarrierRegistrationInsuranceProvider[];
|
|
39
47
|
}
|
|
40
48
|
export interface FundingSourceAddress {
|
|
41
49
|
addressLine1: string;
|
|
@@ -104,6 +112,12 @@ export type MetadataRegistrationRequirement = {
|
|
|
104
112
|
requirementType: MetadataRequirement;
|
|
105
113
|
satisfyingFormTypes: MetadataSatisfyingFormTypes[];
|
|
106
114
|
};
|
|
115
|
+
export type MetadataCarrierProfile = {
|
|
116
|
+
capabilities: MetadataCapability[] | null;
|
|
117
|
+
carrierCode: string;
|
|
118
|
+
registrationRequirements: MetadataRegistrationRequirement[];
|
|
119
|
+
requiredTerms: MetadataRequiredTerm[];
|
|
120
|
+
};
|
|
107
121
|
export type TransactionCategory = "adjustment" | "credit" | "debit" | "funds_added" | "insurance" | "label" | "refund" | "service_charge" | "unknown";
|
|
108
122
|
export type FundingSourceTransaction = {
|
|
109
123
|
description?: string | null;
|
|
@@ -124,6 +138,16 @@ export type FundingSourceTransaction = {
|
|
|
124
138
|
transactionCategory: TransactionCategory;
|
|
125
139
|
transactionDate: string;
|
|
126
140
|
};
|
|
141
|
+
export interface FundingSourceInsuranceProviderResponse {
|
|
142
|
+
errorMessage: null | string;
|
|
143
|
+
fundingSourceId: string;
|
|
144
|
+
isSuccessful: boolean;
|
|
145
|
+
provider: FundingSourceInsuranceProvider;
|
|
146
|
+
}
|
|
147
|
+
export interface FundingSourceCreateResponse {
|
|
148
|
+
fundingSource: FundingSource;
|
|
149
|
+
insuranceProviderAttachmentResults: FundingSourceInsuranceProviderResponse[];
|
|
150
|
+
}
|
|
127
151
|
export interface CarrierRegistrationResponse {
|
|
128
152
|
carrierAttachmentResults: [
|
|
129
153
|
{
|
|
@@ -134,6 +158,7 @@ export interface CarrierRegistrationResponse {
|
|
|
134
158
|
nickname: string;
|
|
135
159
|
}
|
|
136
160
|
];
|
|
161
|
+
insuranceProviderAttachmentResults: FundingSourceInsuranceProviderResponse[];
|
|
137
162
|
}
|
|
138
163
|
export interface MetadataResponse {
|
|
139
164
|
defaultFundingSourceProfile: {
|
|
@@ -145,12 +170,7 @@ export interface MetadataResponse {
|
|
|
145
170
|
requiredTerms: MetadataRequiredTerm[];
|
|
146
171
|
};
|
|
147
172
|
defaultRegionProfile: {
|
|
148
|
-
carrierProfiles:
|
|
149
|
-
capabilities: MetadataCapability[] | null;
|
|
150
|
-
carrierCode: string;
|
|
151
|
-
registrationRequirements: MetadataRegistrationRequirement[];
|
|
152
|
-
requiredTerms: MetadataRequiredTerm[];
|
|
153
|
-
}>;
|
|
173
|
+
carrierProfiles: MetadataCarrierProfile[];
|
|
154
174
|
countryCode: string;
|
|
155
175
|
currencyCode: string;
|
|
156
176
|
};
|
|
@@ -164,4 +184,7 @@ export type AddFundsResponse = {
|
|
|
164
184
|
export type FundingSourceTransactionsResponse = {
|
|
165
185
|
transactions: FundingSourceTransaction[];
|
|
166
186
|
} & PageableResult;
|
|
187
|
+
export type InsuranceFundingSourceAcceptedTermsResponse = {
|
|
188
|
+
acceptedTerms: Term[];
|
|
189
|
+
};
|
|
167
190
|
export {};
|
package/index.js
CHANGED
|
@@ -1201,7 +1201,15 @@ class ConnectionsAPI {
|
|
|
1201
1201
|
this.connectCarrier = (carrierName, formData) => __async$3(this, null, function* () {
|
|
1202
1202
|
return yield this.client.post(
|
|
1203
1203
|
`/v1/connections/carriers/${carrierName}`,
|
|
1204
|
-
formData
|
|
1204
|
+
formData,
|
|
1205
|
+
{
|
|
1206
|
+
// This actually doesn't work in-browser; redirects will still be followed if the location header
|
|
1207
|
+
// is set. This is relying on the Elements Proxy stripping that header and putting it in the body.
|
|
1208
|
+
maxRedirects: 0,
|
|
1209
|
+
validateStatus: (status) => {
|
|
1210
|
+
return status >= 200 && status < 400;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1205
1213
|
);
|
|
1206
1214
|
});
|
|
1207
1215
|
/**
|
|
@@ -3483,8 +3491,9 @@ class FundingSourcesAPI {
|
|
|
3483
3491
|
*/
|
|
3484
3492
|
this.create = (createFundingSource) => __async$2(this, null, function* () {
|
|
3485
3493
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3486
|
-
if (!endUserIpAddress)
|
|
3494
|
+
if (!endUserIpAddress) {
|
|
3487
3495
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3496
|
+
}
|
|
3488
3497
|
return yield this.client.post("/v1/funding_sources", __spreadValues$2({
|
|
3489
3498
|
endUserIpAddress
|
|
3490
3499
|
}, createFundingSource));
|
|
@@ -3496,8 +3505,9 @@ class FundingSourcesAPI {
|
|
|
3496
3505
|
*/
|
|
3497
3506
|
this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$2(this, null, function* () {
|
|
3498
3507
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3499
|
-
if (!endUserIpAddress)
|
|
3508
|
+
if (!endUserIpAddress) {
|
|
3500
3509
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3510
|
+
}
|
|
3501
3511
|
return yield this.client.put(
|
|
3502
3512
|
`/v1/funding_sources/${fundingSourceId}`,
|
|
3503
3513
|
{
|
|
@@ -3513,8 +3523,9 @@ class FundingSourcesAPI {
|
|
|
3513
3523
|
*/
|
|
3514
3524
|
this.registerCarrier = (carrier) => __async$2(this, null, function* () {
|
|
3515
3525
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3516
|
-
if (!endUserIpAddress)
|
|
3526
|
+
if (!endUserIpAddress) {
|
|
3517
3527
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3528
|
+
}
|
|
3518
3529
|
return yield this.client.post("/v1/registration/funding_source", __spreadValues$2({
|
|
3519
3530
|
endUserIpAddress
|
|
3520
3531
|
}, carrier));
|
|
@@ -3547,6 +3558,16 @@ class FundingSourcesAPI {
|
|
|
3547
3558
|
}
|
|
3548
3559
|
);
|
|
3549
3560
|
};
|
|
3561
|
+
/**
|
|
3562
|
+
* Now we can attach insurance providers to the user's Funding Source.
|
|
3563
|
+
* This endpoint will retrieve all accepted insurance terms. For example
|
|
3564
|
+
* if "ParcelGuard" appears here that means the user its using it.
|
|
3565
|
+
*/
|
|
3566
|
+
this.insuranceAcceptedTerms = () => {
|
|
3567
|
+
return this.client.get(
|
|
3568
|
+
"/v1/insurance/funding_source/accepted_terms"
|
|
3569
|
+
);
|
|
3570
|
+
};
|
|
3550
3571
|
this.client = client;
|
|
3551
3572
|
}
|
|
3552
3573
|
}
|
|
@@ -3851,6 +3872,12 @@ class ServicePointsAPI {
|
|
|
3851
3872
|
this.get = ({ carrierCode, countryCode, id }) => {
|
|
3852
3873
|
return this.client.get(`/v1/service_points/${carrierCode}/${countryCode}/${id}`);
|
|
3853
3874
|
};
|
|
3875
|
+
/**
|
|
3876
|
+
* Get an OAuth token to make HERE Maps API requests
|
|
3877
|
+
*/
|
|
3878
|
+
this.getHereToken = () => {
|
|
3879
|
+
return this.client.get("/here-api/generate-token");
|
|
3880
|
+
};
|
|
3854
3881
|
this.client = client;
|
|
3855
3882
|
}
|
|
3856
3883
|
}
|
package/index.mjs
CHANGED
|
@@ -1197,7 +1197,15 @@ class ConnectionsAPI {
|
|
|
1197
1197
|
this.connectCarrier = (carrierName, formData) => __async$3(this, null, function* () {
|
|
1198
1198
|
return yield this.client.post(
|
|
1199
1199
|
`/v1/connections/carriers/${carrierName}`,
|
|
1200
|
-
formData
|
|
1200
|
+
formData,
|
|
1201
|
+
{
|
|
1202
|
+
// This actually doesn't work in-browser; redirects will still be followed if the location header
|
|
1203
|
+
// is set. This is relying on the Elements Proxy stripping that header and putting it in the body.
|
|
1204
|
+
maxRedirects: 0,
|
|
1205
|
+
validateStatus: (status) => {
|
|
1206
|
+
return status >= 200 && status < 400;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1201
1209
|
);
|
|
1202
1210
|
});
|
|
1203
1211
|
/**
|
|
@@ -3479,8 +3487,9 @@ class FundingSourcesAPI {
|
|
|
3479
3487
|
*/
|
|
3480
3488
|
this.create = (createFundingSource) => __async$2(this, null, function* () {
|
|
3481
3489
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3482
|
-
if (!endUserIpAddress)
|
|
3490
|
+
if (!endUserIpAddress) {
|
|
3483
3491
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3492
|
+
}
|
|
3484
3493
|
return yield this.client.post("/v1/funding_sources", __spreadValues$2({
|
|
3485
3494
|
endUserIpAddress
|
|
3486
3495
|
}, createFundingSource));
|
|
@@ -3492,8 +3501,9 @@ class FundingSourcesAPI {
|
|
|
3492
3501
|
*/
|
|
3493
3502
|
this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$2(this, null, function* () {
|
|
3494
3503
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3495
|
-
if (!endUserIpAddress)
|
|
3504
|
+
if (!endUserIpAddress) {
|
|
3496
3505
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3506
|
+
}
|
|
3497
3507
|
return yield this.client.put(
|
|
3498
3508
|
`/v1/funding_sources/${fundingSourceId}`,
|
|
3499
3509
|
{
|
|
@@ -3509,8 +3519,9 @@ class FundingSourcesAPI {
|
|
|
3509
3519
|
*/
|
|
3510
3520
|
this.registerCarrier = (carrier) => __async$2(this, null, function* () {
|
|
3511
3521
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3512
|
-
if (!endUserIpAddress)
|
|
3522
|
+
if (!endUserIpAddress) {
|
|
3513
3523
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3524
|
+
}
|
|
3514
3525
|
return yield this.client.post("/v1/registration/funding_source", __spreadValues$2({
|
|
3515
3526
|
endUserIpAddress
|
|
3516
3527
|
}, carrier));
|
|
@@ -3543,6 +3554,16 @@ class FundingSourcesAPI {
|
|
|
3543
3554
|
}
|
|
3544
3555
|
);
|
|
3545
3556
|
};
|
|
3557
|
+
/**
|
|
3558
|
+
* Now we can attach insurance providers to the user's Funding Source.
|
|
3559
|
+
* This endpoint will retrieve all accepted insurance terms. For example
|
|
3560
|
+
* if "ParcelGuard" appears here that means the user its using it.
|
|
3561
|
+
*/
|
|
3562
|
+
this.insuranceAcceptedTerms = () => {
|
|
3563
|
+
return this.client.get(
|
|
3564
|
+
"/v1/insurance/funding_source/accepted_terms"
|
|
3565
|
+
);
|
|
3566
|
+
};
|
|
3546
3567
|
this.client = client;
|
|
3547
3568
|
}
|
|
3548
3569
|
}
|
|
@@ -3847,6 +3868,12 @@ class ServicePointsAPI {
|
|
|
3847
3868
|
this.get = ({ carrierCode, countryCode, id }) => {
|
|
3848
3869
|
return this.client.get(`/v1/service_points/${carrierCode}/${countryCode}/${id}`);
|
|
3849
3870
|
};
|
|
3871
|
+
/**
|
|
3872
|
+
* Get an OAuth token to make HERE Maps API requests
|
|
3873
|
+
*/
|
|
3874
|
+
this.getHereToken = () => {
|
|
3875
|
+
return this.client.get("/here-api/generate-token");
|
|
3876
|
+
};
|
|
3850
3877
|
this.client = client;
|
|
3851
3878
|
}
|
|
3852
3879
|
}
|
package/package.json
CHANGED
package/service-points/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import type { GetServicePointParams, ListServicePointsOptions, ServicePointsListResponse } from "./types";
|
|
2
|
+
import type { GetServicePointParams, HereTokenResponse, ListServicePointsOptions, ServicePointsListResponse } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Service points api
|
|
5
5
|
*/
|
|
@@ -16,4 +16,8 @@ export declare class ServicePointsAPI {
|
|
|
16
16
|
* Get a specific service point by its carrier code, country code, and id
|
|
17
17
|
*/
|
|
18
18
|
get: ({ carrierCode, countryCode, id }: GetServicePointParams) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
19
|
+
/**
|
|
20
|
+
* Get an OAuth token to make HERE Maps API requests
|
|
21
|
+
*/
|
|
22
|
+
getHereToken: () => Promise<import("axios").AxiosResponse<HereTokenResponse, any>>;
|
|
19
23
|
}
|