@shipengine/js-api 1.13.0 → 1.14.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.
@@ -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: FundingSourceCarrier[];
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: Array<{
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
@@ -3483,8 +3483,9 @@ class FundingSourcesAPI {
3483
3483
  */
3484
3484
  this.create = (createFundingSource) => __async$2(this, null, function* () {
3485
3485
  const endUserIpAddress = yield getEndUserIpAddress();
3486
- if (!endUserIpAddress)
3486
+ if (!endUserIpAddress) {
3487
3487
  return Promise.reject([new CodedError("Unable to get IP address")]);
3488
+ }
3488
3489
  return yield this.client.post("/v1/funding_sources", __spreadValues$2({
3489
3490
  endUserIpAddress
3490
3491
  }, createFundingSource));
@@ -3496,8 +3497,9 @@ class FundingSourcesAPI {
3496
3497
  */
3497
3498
  this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$2(this, null, function* () {
3498
3499
  const endUserIpAddress = yield getEndUserIpAddress();
3499
- if (!endUserIpAddress)
3500
+ if (!endUserIpAddress) {
3500
3501
  return Promise.reject([new CodedError("Unable to get IP address")]);
3502
+ }
3501
3503
  return yield this.client.put(
3502
3504
  `/v1/funding_sources/${fundingSourceId}`,
3503
3505
  {
@@ -3513,8 +3515,9 @@ class FundingSourcesAPI {
3513
3515
  */
3514
3516
  this.registerCarrier = (carrier) => __async$2(this, null, function* () {
3515
3517
  const endUserIpAddress = yield getEndUserIpAddress();
3516
- if (!endUserIpAddress)
3518
+ if (!endUserIpAddress) {
3517
3519
  return Promise.reject([new CodedError("Unable to get IP address")]);
3520
+ }
3518
3521
  return yield this.client.post("/v1/registration/funding_source", __spreadValues$2({
3519
3522
  endUserIpAddress
3520
3523
  }, carrier));
@@ -3547,6 +3550,16 @@ class FundingSourcesAPI {
3547
3550
  }
3548
3551
  );
3549
3552
  };
3553
+ /**
3554
+ * Now we can attach insurance providers to the user's Funding Source.
3555
+ * This endpoint will retrieve all accepted insurance terms. For example
3556
+ * if "ParcelGuard" appears here that means the user its using it.
3557
+ */
3558
+ this.insuranceAcceptedTerms = () => {
3559
+ return this.client.get(
3560
+ "/v1/insurance/funding_source/accepted_terms"
3561
+ );
3562
+ };
3550
3563
  this.client = client;
3551
3564
  }
3552
3565
  }
package/index.mjs CHANGED
@@ -3479,8 +3479,9 @@ class FundingSourcesAPI {
3479
3479
  */
3480
3480
  this.create = (createFundingSource) => __async$2(this, null, function* () {
3481
3481
  const endUserIpAddress = yield getEndUserIpAddress();
3482
- if (!endUserIpAddress)
3482
+ if (!endUserIpAddress) {
3483
3483
  return Promise.reject([new CodedError("Unable to get IP address")]);
3484
+ }
3484
3485
  return yield this.client.post("/v1/funding_sources", __spreadValues$2({
3485
3486
  endUserIpAddress
3486
3487
  }, createFundingSource));
@@ -3492,8 +3493,9 @@ class FundingSourcesAPI {
3492
3493
  */
3493
3494
  this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$2(this, null, function* () {
3494
3495
  const endUserIpAddress = yield getEndUserIpAddress();
3495
- if (!endUserIpAddress)
3496
+ if (!endUserIpAddress) {
3496
3497
  return Promise.reject([new CodedError("Unable to get IP address")]);
3498
+ }
3497
3499
  return yield this.client.put(
3498
3500
  `/v1/funding_sources/${fundingSourceId}`,
3499
3501
  {
@@ -3509,8 +3511,9 @@ class FundingSourcesAPI {
3509
3511
  */
3510
3512
  this.registerCarrier = (carrier) => __async$2(this, null, function* () {
3511
3513
  const endUserIpAddress = yield getEndUserIpAddress();
3512
- if (!endUserIpAddress)
3514
+ if (!endUserIpAddress) {
3513
3515
  return Promise.reject([new CodedError("Unable to get IP address")]);
3516
+ }
3514
3517
  return yield this.client.post("/v1/registration/funding_source", __spreadValues$2({
3515
3518
  endUserIpAddress
3516
3519
  }, carrier));
@@ -3543,6 +3546,16 @@ class FundingSourcesAPI {
3543
3546
  }
3544
3547
  );
3545
3548
  };
3549
+ /**
3550
+ * Now we can attach insurance providers to the user's Funding Source.
3551
+ * This endpoint will retrieve all accepted insurance terms. For example
3552
+ * if "ParcelGuard" appears here that means the user its using it.
3553
+ */
3554
+ this.insuranceAcceptedTerms = () => {
3555
+ return this.client.get(
3556
+ "/v1/insurance/funding_source/accepted_terms"
3557
+ );
3558
+ };
3546
3559
  this.client = client;
3547
3560
  }
3548
3561
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/js-api",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {