@arrowsphere/api-client 3.50.0-rc.bdj.2 → 3.50.0-rc.bdj.4

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.
@@ -29,6 +29,7 @@ export declare type Parameters = Record<string, string | string[] | number | num
29
29
  export declare type Payload = Record<string, unknown> | Array<Payload>;
30
30
  export declare type Options = {
31
31
  isAdmin?: boolean;
32
+ returnAxiosData?: boolean;
32
33
  };
33
34
  export declare type ConfigurationsClient = {
34
35
  [ParameterKeys.API_KEY]?: string;
@@ -99,6 +100,7 @@ export declare abstract class AbstractRestfulClient extends AbstractHttpClient {
99
100
  /**
100
101
  * Processes and returns the Axios response data
101
102
  * @param response - The AxiosResponse
103
+ * @param options - options
102
104
  * @returns T
103
105
  */
104
106
  private getResponse;
@@ -110,7 +110,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
110
110
  };
111
111
  try {
112
112
  const response = await this.client.get(url, config);
113
- return this.getResponse(response);
113
+ return this.getResponse(response, options);
114
114
  }
115
115
  catch (error) {
116
116
  if (error instanceof exception_1.PublicApiClientException) {
@@ -120,7 +120,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
120
120
  headers: this.prepareHeaders(headers),
121
121
  };
122
122
  const response = await this.client.get(url, config);
123
- return this.getResponse(response);
123
+ return this.getResponse(response, options);
124
124
  }
125
125
  }
126
126
  throw error;
@@ -129,9 +129,13 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
129
129
  /**
130
130
  * Processes and returns the Axios response data
131
131
  * @param response - The AxiosResponse
132
+ * @param options - options
132
133
  * @returns T
133
134
  */
134
- getResponse(response) {
135
+ getResponse(response, options = {}) {
136
+ if (options.returnAxiosData) {
137
+ return response.data;
138
+ }
135
139
  const statusCode = response.status;
136
140
  if (statusCode === 404) {
137
141
  throw new exception_1.NotFoundException(`Resource not found on URL ${this.getUrl()}`, response.data.error, statusCode);
@@ -171,7 +175,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
171
175
  };
172
176
  try {
173
177
  const response = await this.client.post(url, payload, config);
174
- return this.getResponse(response);
178
+ return this.getResponse(response, options);
175
179
  }
176
180
  catch (error) {
177
181
  if (error instanceof exception_1.PublicApiClientException) {
@@ -181,7 +185,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
181
185
  headers: this.prepareHeaders(headers),
182
186
  };
183
187
  const response = await this.client.post(url, payload, config);
184
- return this.getResponse(response);
188
+ return this.getResponse(response, options);
185
189
  }
186
190
  }
187
191
  throw error;
@@ -202,7 +206,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
202
206
  };
203
207
  try {
204
208
  const response = await this.client.put(url, payload, config);
205
- return this.getResponse(response);
209
+ return this.getResponse(response, options);
206
210
  }
207
211
  catch (error) {
208
212
  if (error instanceof exception_1.PublicApiClientException) {
@@ -212,7 +216,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
212
216
  headers: this.prepareHeaders(headers),
213
217
  };
214
218
  const response = await this.client.put(url, payload, config);
215
- return this.getResponse(response);
219
+ return this.getResponse(response, options);
216
220
  }
217
221
  }
218
222
  throw error;
@@ -233,7 +237,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
233
237
  };
234
238
  try {
235
239
  const response = await this.client.patch(url, payload, config);
236
- return this.getResponse(response);
240
+ return this.getResponse(response, options);
237
241
  }
238
242
  catch (error) {
239
243
  if (error instanceof exception_1.PublicApiClientException) {
@@ -243,7 +247,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
243
247
  headers: this.prepareHeaders(headers),
244
248
  };
245
249
  const response = await this.client.patch(url, payload, config);
246
- return this.getResponse(response);
250
+ return this.getResponse(response, options);
247
251
  }
248
252
  }
249
253
  throw error;
@@ -264,7 +268,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
264
268
  };
265
269
  try {
266
270
  const response = await this.client.delete(url, config);
267
- return this.getResponse(response);
271
+ return this.getResponse(response, options);
268
272
  }
269
273
  catch (error) {
270
274
  if (error instanceof exception_1.PublicApiClientException) {
@@ -274,7 +278,7 @@ class AbstractRestfulClient extends AbstractHttpClient_1.AbstractHttpClient {
274
278
  headers: this.prepareHeaders(headers),
275
279
  };
276
280
  const response = await this.client.delete(url, config);
277
- return this.getResponse(response);
281
+ return this.getResponse(response, options);
278
282
  }
279
283
  }
280
284
  throw error;
@@ -66,7 +66,7 @@ export declare type APIResponseCustomerUpdated = {
66
66
  };
67
67
  export interface APIResponseError {
68
68
  status: number;
69
- message: string;
69
+ error: string;
70
70
  }
71
71
  export declare type PatchCustomerContactPayload = {
72
72
  [Property in keyof PostCustomerContactPayload]?: PostCustomerContactPayload[Property];
@@ -84,6 +84,6 @@ export declare class CustomersClient extends AbstractRestfulClient {
84
84
  getCustomerContact(customerReference: string, contactReference: string, parameters?: Parameters): Promise<GetResult<CustomerContact>>;
85
85
  deleteCustomerContact(customerReference: string, contactReference: string, parameters?: Parameters): Promise<void>;
86
86
  patchCustomerContact(customerReference: string, contactReference: string, payload: PatchCustomerContactPayload, parameters?: Parameters): Promise<GetResult<CustomerContact>>;
87
- createCustomer(payload: PostCustomerPayload, parameters?: Parameters): Promise<APIResponseResourceCreated | APIResponseError>;
88
- updateCustomer(customerReference: string, payload: Partial<PostCustomerPayload>, parameters?: Parameters): Promise<APIResponseCustomerUpdated | APIResponseError>;
87
+ createCustomer(payload: PostCustomerPayload, parameters?: Parameters, returnAxiosData?: boolean): Promise<APIResponseResourceCreated | APIResponseError>;
88
+ updateCustomer(customerReference: string, payload: Partial<PostCustomerPayload>, parameters?: Parameters, returnAxiosData?: boolean): Promise<APIResponseCustomerUpdated | APIResponseError>;
89
89
  }
@@ -10,8 +10,6 @@ const customerContactList_1 = require("./entities/customers/customerContact/cust
10
10
  const customerContact_1 = require("./entities/customers/customerContact/customerContact");
11
11
  const customer_1 = require("./entities/customers/customer");
12
12
  const contact_1 = require("./entities/customers/contact/contact");
13
- const lodash_1 = require("lodash");
14
- const http2_1 = require("http2");
15
13
  var CustomerContactPayloadFields;
16
14
  (function (CustomerContactPayloadFields) {
17
15
  CustomerContactPayloadFields["COLUMN_FIRST_NAME"] = "firstName";
@@ -63,31 +61,13 @@ class CustomersClient extends abstractRestfulClient_1.AbstractRestfulClient {
63
61
  this.path = `/${customerReference}/contacts/${contactReference}`;
64
62
  return new getResult_1.GetResult(customerContact_1.CustomerContact, await this.patch(payload, parameters));
65
63
  }
66
- async createCustomer(payload, parameters = {}) {
64
+ async createCustomer(payload, parameters = {}, returnAxiosData = false) {
67
65
  this.path = '';
68
- try {
69
- return await this.post(payload, parameters);
70
- }
71
- catch (error) {
72
- const response = {
73
- status: (0, lodash_1.get)(error, 'httpCode', (0, lodash_1.get)(error, 'code', http2_1.constants.HTTP_STATUS_INTERNAL_SERVER_ERROR)),
74
- message: (0, lodash_1.get)(error, 'httpError', (0, lodash_1.get)(error, 'message', 'An error has occurred')),
75
- };
76
- return response;
77
- }
66
+ return await this.post(payload, parameters, {}, { returnAxiosData });
78
67
  }
79
- async updateCustomer(customerReference, payload, parameters = {}) {
68
+ async updateCustomer(customerReference, payload, parameters = {}, returnAxiosData = false) {
80
69
  this.path = `/${customerReference}`;
81
- try {
82
- return await this.patch(payload, parameters);
83
- }
84
- catch (error) {
85
- const response = {
86
- status: (0, lodash_1.get)(error, 'httpCode', (0, lodash_1.get)(error, 'code', http2_1.constants.HTTP_STATUS_INTERNAL_SERVER_ERROR)),
87
- message: (0, lodash_1.get)(error, 'httpError', (0, lodash_1.get)(error, 'message', 'An error has occurred')),
88
- };
89
- return response;
90
- }
70
+ return await this.patch(payload, parameters, {}, { returnAxiosData });
91
71
  }
92
72
  }
93
73
  exports.CustomersClient = CustomersClient;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/ArrowSphere/nodejs-api-client.git"
6
6
  },
7
- "version": "3.50.0-rc.bdj.2",
7
+ "version": "3.50.0-rc.bdj.4",
8
8
  "description": "Node.js client for ArrowSphere's public API",
9
9
  "main": "build/index.js",
10
10
  "types": "build/index.d.ts",