@shipengine/js-api 1.3.0 → 1.4.1

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
- import { GetCarrierConnectionFormParams, GetCarrierConnectionFormResponse, ListCarrierConnectionsParams, ListCarrierConnectionsResponse } from "./types";
2
+ import { ConnectCarrierAccount, ConnectCarrierAccountResponse, GetCarrierConnectionFormParams, GetCarrierConnectionFormResponse, ListCarrierConnectionsParams, ListCarrierConnectionsResponse } from "./types";
3
3
  /**
4
- * # Carriers API module - /v1/carriers
4
+ * # Connections API module - /v1/connections
5
5
  */
6
6
  export declare class ConnectionsAPI {
7
7
  private client;
@@ -15,4 +15,8 @@ export declare class ConnectionsAPI {
15
15
  * information required to connect to the carrier.
16
16
  */
17
17
  getCarrierConnectionForm: (carrierName: string, params: GetCarrierConnectionFormParams) => Promise<import("axios").AxiosResponse<GetCarrierConnectionFormResponse, any>>;
18
+ /**
19
+ * The `connectCarrier` method connects a carrier to account.
20
+ */
21
+ connectCarrier: (carrierName: string, formData: ConnectCarrierAccount) => Promise<import("axios").AxiosResponse<ConnectCarrierAccountResponse, any>>;
18
22
  }
@@ -15,18 +15,18 @@ export type CarrierMetadata = {
15
15
  name: string;
16
16
  searchTerms?: string[] | null;
17
17
  };
18
- /**
19
- * @category Requests
20
- */
21
18
  export type ListCarrierConnectionsParams = LocaleBasedQuery;
22
19
  export type GetCarrierConnectionFormParams = LocaleBasedQuery;
20
+ export type ConnectCarrierAccount = {
21
+ nickname: string;
22
+ } & GenericObject;
23
23
  /**
24
24
  * @category Responses
25
25
  */
26
26
  export type GetCarrierConnectionFormResponse = {
27
27
  formMetadata: {
28
- connectionNames?: string[];
29
- defaultConnectionName?: string;
28
+ connectionNames?: string[] | null;
29
+ defaultConnectionName?: string | null;
30
30
  formSchema: {
31
31
  jsonSchema: GenericObject;
32
32
  uiSchema: GenericObject;
@@ -34,3 +34,7 @@ export type GetCarrierConnectionFormResponse = {
34
34
  };
35
35
  };
36
36
  export type ListCarrierConnectionsResponse = CarrierMetadata[];
37
+ export type ConnectCarrierAccountResponse = {
38
+ carrierId?: string;
39
+ redirectUrl?: string;
40
+ };
package/index.js CHANGED
@@ -964,7 +964,7 @@ var ipaddr = {
964
964
  }).call(commonjsGlobal);
965
965
  } (ipaddr));
966
966
 
967
- var __async$4 = (__this, __arguments, generator) => {
967
+ var __async$5 = (__this, __arguments, generator) => {
968
968
  return new Promise((resolve, reject) => {
969
969
  var fulfilled = (value) => {
970
970
  try {
@@ -984,7 +984,7 @@ var __async$4 = (__this, __arguments, generator) => {
984
984
  step((generator = generator.apply(__this, __arguments)).next());
985
985
  });
986
986
  };
987
- const getEndUserIpAddress = () => __async$4(void 0, null, function* () {
987
+ const getEndUserIpAddress = () => __async$5(void 0, null, function* () {
988
988
  try {
989
989
  const response = yield axios.get("https://api.ipify.org/?format=json");
990
990
  if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
@@ -1027,7 +1027,7 @@ var __objRest = (source, exclude) => {
1027
1027
  }
1028
1028
  return target;
1029
1029
  };
1030
- var __async$3 = (__this, __arguments, generator) => {
1030
+ var __async$4 = (__this, __arguments, generator) => {
1031
1031
  return new Promise((resolve, reject) => {
1032
1032
  var fulfilled = (value) => {
1033
1033
  try {
@@ -1065,7 +1065,7 @@ class CarriersAPI {
1065
1065
  /**
1066
1066
  * The `connect` method connects a carrier account to a user's ShipEngine account.
1067
1067
  */
1068
- this.connect = (_a) => __async$3(this, null, function* () {
1068
+ this.connect = (_a) => __async$4(this, null, function* () {
1069
1069
  var _b = _a, { carrierCode } = _b, connection = __objRest(_b, ["carrierCode"]);
1070
1070
  const endUserIpAddress = yield getEndUserIpAddress();
1071
1071
  if (!endUserIpAddress)
@@ -1149,6 +1149,26 @@ class CarriersAPI {
1149
1149
  }
1150
1150
  }
1151
1151
 
1152
+ var __async$3 = (__this, __arguments, generator) => {
1153
+ return new Promise((resolve, reject) => {
1154
+ var fulfilled = (value) => {
1155
+ try {
1156
+ step(generator.next(value));
1157
+ } catch (e) {
1158
+ reject(e);
1159
+ }
1160
+ };
1161
+ var rejected = (value) => {
1162
+ try {
1163
+ step(generator.throw(value));
1164
+ } catch (e) {
1165
+ reject(e);
1166
+ }
1167
+ };
1168
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1169
+ step((generator = generator.apply(__this, __arguments)).next());
1170
+ });
1171
+ };
1152
1172
  class ConnectionsAPI {
1153
1173
  constructor(client) {
1154
1174
  this.client = client;
@@ -1168,6 +1188,15 @@ class ConnectionsAPI {
1168
1188
  { params }
1169
1189
  );
1170
1190
  };
1191
+ /**
1192
+ * The `connectCarrier` method connects a carrier to account.
1193
+ */
1194
+ this.connectCarrier = (carrierName, formData) => __async$3(this, null, function* () {
1195
+ return yield this.client.post(
1196
+ `/v1/connections/carriers/${carrierName}`,
1197
+ formData
1198
+ );
1199
+ });
1171
1200
  this.client = client;
1172
1201
  }
1173
1202
  }
package/index.mjs CHANGED
@@ -960,7 +960,7 @@ var ipaddr = {
960
960
  }).call(commonjsGlobal);
961
961
  } (ipaddr));
962
962
 
963
- var __async$4 = (__this, __arguments, generator) => {
963
+ var __async$5 = (__this, __arguments, generator) => {
964
964
  return new Promise((resolve, reject) => {
965
965
  var fulfilled = (value) => {
966
966
  try {
@@ -980,7 +980,7 @@ var __async$4 = (__this, __arguments, generator) => {
980
980
  step((generator = generator.apply(__this, __arguments)).next());
981
981
  });
982
982
  };
983
- const getEndUserIpAddress = () => __async$4(void 0, null, function* () {
983
+ const getEndUserIpAddress = () => __async$5(void 0, null, function* () {
984
984
  try {
985
985
  const response = yield axios.get("https://api.ipify.org/?format=json");
986
986
  if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
@@ -1023,7 +1023,7 @@ var __objRest = (source, exclude) => {
1023
1023
  }
1024
1024
  return target;
1025
1025
  };
1026
- var __async$3 = (__this, __arguments, generator) => {
1026
+ var __async$4 = (__this, __arguments, generator) => {
1027
1027
  return new Promise((resolve, reject) => {
1028
1028
  var fulfilled = (value) => {
1029
1029
  try {
@@ -1061,7 +1061,7 @@ class CarriersAPI {
1061
1061
  /**
1062
1062
  * The `connect` method connects a carrier account to a user's ShipEngine account.
1063
1063
  */
1064
- this.connect = (_a) => __async$3(this, null, function* () {
1064
+ this.connect = (_a) => __async$4(this, null, function* () {
1065
1065
  var _b = _a, { carrierCode } = _b, connection = __objRest(_b, ["carrierCode"]);
1066
1066
  const endUserIpAddress = yield getEndUserIpAddress();
1067
1067
  if (!endUserIpAddress)
@@ -1145,6 +1145,26 @@ class CarriersAPI {
1145
1145
  }
1146
1146
  }
1147
1147
 
1148
+ var __async$3 = (__this, __arguments, generator) => {
1149
+ return new Promise((resolve, reject) => {
1150
+ var fulfilled = (value) => {
1151
+ try {
1152
+ step(generator.next(value));
1153
+ } catch (e) {
1154
+ reject(e);
1155
+ }
1156
+ };
1157
+ var rejected = (value) => {
1158
+ try {
1159
+ step(generator.throw(value));
1160
+ } catch (e) {
1161
+ reject(e);
1162
+ }
1163
+ };
1164
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
1165
+ step((generator = generator.apply(__this, __arguments)).next());
1166
+ });
1167
+ };
1148
1168
  class ConnectionsAPI {
1149
1169
  constructor(client) {
1150
1170
  this.client = client;
@@ -1164,6 +1184,15 @@ class ConnectionsAPI {
1164
1184
  { params }
1165
1185
  );
1166
1186
  };
1187
+ /**
1188
+ * The `connectCarrier` method connects a carrier to account.
1189
+ */
1190
+ this.connectCarrier = (carrierName, formData) => __async$3(this, null, function* () {
1191
+ return yield this.client.post(
1192
+ `/v1/connections/carriers/${carrierName}`,
1193
+ formData
1194
+ );
1195
+ });
1167
1196
  this.client = client;
1168
1197
  }
1169
1198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/js-api",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -31,7 +31,7 @@ export type ServicePoint = {
31
31
  distanceInMeters: number;
32
32
  features: ServicePointFeature[];
33
33
  hoursOfOperation: {
34
- [key in DayOfOperation]: OperatingHours;
34
+ [key in DayOfOperation]: OperatingHours[];
35
35
  };
36
36
  lat: number;
37
37
  long: number;