@arrowsphere/api-client 3.17.0-rc.2 → 3.17.0-rc.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.
- package/build/abstractClient.d.ts +1 -2
- package/build/abstractClient.js +3 -33
- package/build/axiosSingleton.d.ts +23 -0
- package/build/axiosSingleton.js +59 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/publicApiClient.js +11 -11
- package/package.json +3 -3
|
@@ -55,10 +55,9 @@ export declare abstract class AbstractClient {
|
|
|
55
55
|
protected headers: Headers;
|
|
56
56
|
/**
|
|
57
57
|
* AbstractClient constructor.
|
|
58
|
-
* @param client - Pre-existing Axios instance that will be used for calls
|
|
59
58
|
* @returns AbstractClient
|
|
60
59
|
*/
|
|
61
|
-
protected constructor(
|
|
60
|
+
protected constructor();
|
|
62
61
|
/**
|
|
63
62
|
* Sets the Client ArrowSphere API key
|
|
64
63
|
* @param key - ArrowSphere API key
|
package/build/abstractClient.js
CHANGED
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AbstractClient = exports.ParameterKeys = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
7
|
const exception_1 = require("./exception");
|
|
9
8
|
const querystring_1 = __importDefault(require("querystring"));
|
|
10
9
|
const url_1 = require("url");
|
|
11
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const axiosSingleton_1 = require("./axiosSingleton");
|
|
12
12
|
/**
|
|
13
13
|
* Lists of available query parameters for the API call
|
|
14
14
|
*/
|
|
@@ -24,10 +24,9 @@ var ParameterKeys;
|
|
|
24
24
|
class AbstractClient {
|
|
25
25
|
/**
|
|
26
26
|
* AbstractClient constructor.
|
|
27
|
-
* @param client - Pre-existing Axios instance that will be used for calls
|
|
28
27
|
* @returns AbstractClient
|
|
29
28
|
*/
|
|
30
|
-
constructor(
|
|
29
|
+
constructor() {
|
|
31
30
|
/**
|
|
32
31
|
* Base path for HTTP calls
|
|
33
32
|
*/
|
|
@@ -60,17 +59,7 @@ class AbstractClient {
|
|
|
60
59
|
* Defines header information for axios call
|
|
61
60
|
*/
|
|
62
61
|
this.headers = {};
|
|
63
|
-
this.client =
|
|
64
|
-
// Prevent axios from throwing its own errors, let us do that
|
|
65
|
-
this.client.defaults.validateStatus = null;
|
|
66
|
-
this.client.interceptors.request.use((request) => {
|
|
67
|
-
console.log('AXIOS - Starting Request : ', JSON.stringify(request, null, 2));
|
|
68
|
-
return request;
|
|
69
|
-
});
|
|
70
|
-
this.client.interceptors.response.use((response) => {
|
|
71
|
-
console.log('AXIOS - Response : ', JSON.stringify(response, null, 2));
|
|
72
|
-
return response;
|
|
73
|
-
});
|
|
62
|
+
this.client = axiosSingleton_1.AxiosSingleton.getInstance();
|
|
74
63
|
}
|
|
75
64
|
/**
|
|
76
65
|
* Sets the Client ArrowSphere API key
|
|
@@ -132,13 +121,9 @@ class AbstractClient {
|
|
|
132
121
|
* @returns Promise\<AxiosResponse['data']\>
|
|
133
122
|
*/
|
|
134
123
|
async get(parameters = {}, headers = {}, options = {}) {
|
|
135
|
-
console.log('GET parameters', parameters);
|
|
136
|
-
console.log('GET options', options);
|
|
137
|
-
console.log('GET Header', headers);
|
|
138
124
|
const response = await this.client.get(this.generateUrl(parameters, options), {
|
|
139
125
|
headers: this.prepareHeaders(headers),
|
|
140
126
|
});
|
|
141
|
-
console.log('GET Response', response);
|
|
142
127
|
return this.getResponse(response);
|
|
143
128
|
}
|
|
144
129
|
/**
|
|
@@ -177,14 +162,9 @@ class AbstractClient {
|
|
|
177
162
|
* @param options - Options to send
|
|
178
163
|
*/
|
|
179
164
|
async post(payload = {}, parameters = {}, headers = {}, options = {}) {
|
|
180
|
-
console.log('POST parameters', parameters);
|
|
181
|
-
console.log('POST options', options);
|
|
182
|
-
console.log('POST payload', payload);
|
|
183
|
-
console.log('POST Header', headers);
|
|
184
165
|
const response = await this.client.post(this.generateUrl(parameters, options), payload, {
|
|
185
166
|
headers: this.prepareHeaders(headers),
|
|
186
167
|
});
|
|
187
|
-
console.log('POST Response', response);
|
|
188
168
|
return this.getResponse(response);
|
|
189
169
|
}
|
|
190
170
|
/**
|
|
@@ -196,14 +176,9 @@ class AbstractClient {
|
|
|
196
176
|
* @returns Promise\<void\>
|
|
197
177
|
*/
|
|
198
178
|
async put(payload = {}, parameters = {}, headers = {}, options = {}) {
|
|
199
|
-
console.log('PUT parameters', parameters);
|
|
200
|
-
console.log('PUT options', options);
|
|
201
|
-
console.log('PUT payload', payload);
|
|
202
|
-
console.log('PUT Header', headers);
|
|
203
179
|
const response = await this.client.put(this.generateUrl(parameters, options), payload, {
|
|
204
180
|
headers: this.prepareHeaders(headers),
|
|
205
181
|
});
|
|
206
|
-
console.log('PUT Response', response);
|
|
207
182
|
return this.getResponse(response);
|
|
208
183
|
}
|
|
209
184
|
/**
|
|
@@ -215,14 +190,9 @@ class AbstractClient {
|
|
|
215
190
|
* @returns Promise\<T\>
|
|
216
191
|
*/
|
|
217
192
|
async patch(payload = {}, parameters = {}, headers = {}, options = {}) {
|
|
218
|
-
console.log('PATCH parameters', parameters);
|
|
219
|
-
console.log('PATCH options', options);
|
|
220
|
-
console.log('PATCH payload', payload);
|
|
221
|
-
console.log('PATCH Header', headers);
|
|
222
193
|
const response = await this.client.patch(this.generateUrl(parameters, options), payload, {
|
|
223
194
|
headers: this.prepareHeaders(headers),
|
|
224
195
|
});
|
|
225
|
-
console.log('PATCH Response', response);
|
|
226
196
|
return this.getResponse(response);
|
|
227
197
|
}
|
|
228
198
|
/**
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export declare class AxiosSingleton {
|
|
3
|
+
private static _axiosInstance;
|
|
4
|
+
static getInstance(): AxiosInstance;
|
|
5
|
+
private static _initializedRequestInterceptor;
|
|
6
|
+
private static _initializedResponseInterceptor;
|
|
7
|
+
/**
|
|
8
|
+
* @param request - Axios Request
|
|
9
|
+
*/
|
|
10
|
+
private static _handleRequest;
|
|
11
|
+
/**
|
|
12
|
+
* @param response - Axios Response
|
|
13
|
+
*/
|
|
14
|
+
private static _handleResponse;
|
|
15
|
+
/**
|
|
16
|
+
* @param request - Axios Request
|
|
17
|
+
*/
|
|
18
|
+
private static cleanRequestLog;
|
|
19
|
+
/**
|
|
20
|
+
* @param response - Axios Response
|
|
21
|
+
*/
|
|
22
|
+
private static cleanResponseLog;
|
|
23
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AxiosSingleton = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
class AxiosSingleton {
|
|
9
|
+
static getInstance() {
|
|
10
|
+
if (!AxiosSingleton._axiosInstance) {
|
|
11
|
+
AxiosSingleton._axiosInstance = axios_1.default.create();
|
|
12
|
+
AxiosSingleton._initializedRequestInterceptor();
|
|
13
|
+
AxiosSingleton._initializedResponseInterceptor();
|
|
14
|
+
AxiosSingleton._axiosInstance.defaults.validateStatus = null;
|
|
15
|
+
}
|
|
16
|
+
return AxiosSingleton._axiosInstance;
|
|
17
|
+
}
|
|
18
|
+
static _initializedRequestInterceptor() {
|
|
19
|
+
this._axiosInstance.interceptors.request.use(this._handleRequest);
|
|
20
|
+
}
|
|
21
|
+
static _initializedResponseInterceptor() {
|
|
22
|
+
this._axiosInstance.interceptors.response.use(this._handleResponse);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @param request - Axios Request
|
|
26
|
+
*/
|
|
27
|
+
static _handleRequest(request) {
|
|
28
|
+
console.log('AXIOS - Request : ', AxiosSingleton.cleanRequestLog(request));
|
|
29
|
+
return request;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @param response - Axios Response
|
|
33
|
+
*/
|
|
34
|
+
static _handleResponse(response) {
|
|
35
|
+
console.log('AXIOS - Response : ', AxiosSingleton.cleanResponseLog(response));
|
|
36
|
+
return response;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @param request - Axios Request
|
|
40
|
+
*/
|
|
41
|
+
static cleanRequestLog(request) {
|
|
42
|
+
var _a;
|
|
43
|
+
const tempRequest = request;
|
|
44
|
+
(_a = tempRequest === null || tempRequest === void 0 ? void 0 : tempRequest.headers) === null || _a === void 0 ? true : delete _a.apiKey;
|
|
45
|
+
return tempRequest;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @param response - Axios Response
|
|
49
|
+
*/
|
|
50
|
+
static cleanResponseLog(response) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const tempResponse = response;
|
|
53
|
+
(_b = (_a = tempResponse === null || tempResponse === void 0 ? void 0 : tempResponse.config) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? true : delete _b.apiKey;
|
|
54
|
+
tempResponse === null || tempResponse === void 0 ? true : delete tempResponse.request;
|
|
55
|
+
return tempResponse;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.AxiosSingleton = AxiosSingleton;
|
|
59
|
+
//# sourceMappingURL=axiosSingleton.js.map
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.ContactInformation = void 0;
|
|
26
|
+
__exportStar(require("./axiosSingleton"), exports);
|
|
26
27
|
__exportStar(require("./abstractClient"), exports);
|
|
27
28
|
__exportStar(require("./abstractEntity"), exports);
|
|
28
29
|
__exportStar(require("./abstractGraphQLClient"), exports);
|
package/build/publicApiClient.js
CHANGED
|
@@ -24,7 +24,7 @@ class PublicApiClient extends abstractClient_1.AbstractClient {
|
|
|
24
24
|
* @returns {@link CustomersClient}
|
|
25
25
|
*/
|
|
26
26
|
getCustomersClient() {
|
|
27
|
-
return new customers_1.CustomersClient(
|
|
27
|
+
return new customers_1.CustomersClient()
|
|
28
28
|
.setUrl(this.url)
|
|
29
29
|
.setApiKey(this.apiKey)
|
|
30
30
|
.setHeaders(this.headers);
|
|
@@ -34,7 +34,7 @@ class PublicApiClient extends abstractClient_1.AbstractClient {
|
|
|
34
34
|
* @returns {@link WhoAmIClient}
|
|
35
35
|
*/
|
|
36
36
|
getWhoamiClient() {
|
|
37
|
-
return new general_1.WhoAmIClient(
|
|
37
|
+
return new general_1.WhoAmIClient()
|
|
38
38
|
.setUrl(this.url)
|
|
39
39
|
.setApiKey(this.apiKey)
|
|
40
40
|
.setHeaders(this.headers);
|
|
@@ -44,7 +44,7 @@ class PublicApiClient extends abstractClient_1.AbstractClient {
|
|
|
44
44
|
* @returns {@link LicensesClient}
|
|
45
45
|
*/
|
|
46
46
|
getLicensesClient() {
|
|
47
|
-
return new licenses_1.LicensesClient(
|
|
47
|
+
return new licenses_1.LicensesClient()
|
|
48
48
|
.setUrl(this.url)
|
|
49
49
|
.setApiKey(this.apiKey)
|
|
50
50
|
.setHeaders(this.headers);
|
|
@@ -54,7 +54,7 @@ class PublicApiClient extends abstractClient_1.AbstractClient {
|
|
|
54
54
|
* @returns {@link CheckDomainClient}
|
|
55
55
|
*/
|
|
56
56
|
getCheckDomainClient() {
|
|
57
|
-
return new general_1.CheckDomainClient(
|
|
57
|
+
return new general_1.CheckDomainClient()
|
|
58
58
|
.setUrl(this.url)
|
|
59
59
|
.setApiKey(this.apiKey)
|
|
60
60
|
.setHeaders(this.headers);
|
|
@@ -64,7 +64,7 @@ class PublicApiClient extends abstractClient_1.AbstractClient {
|
|
|
64
64
|
* @returns {@link SubscriptionsClient}
|
|
65
65
|
*/
|
|
66
66
|
getSubscriptionsClient() {
|
|
67
|
-
return new subscriptions_1.SubscriptionsClient(
|
|
67
|
+
return new subscriptions_1.SubscriptionsClient()
|
|
68
68
|
.setUrl(this.url)
|
|
69
69
|
.setApiKey(this.apiKey)
|
|
70
70
|
.setHeaders(this.headers);
|
|
@@ -74,7 +74,7 @@ class PublicApiClient extends abstractClient_1.AbstractClient {
|
|
|
74
74
|
* @returns {@link OrdersClient}
|
|
75
75
|
*/
|
|
76
76
|
getOrdersClient() {
|
|
77
|
-
return new orders_1.OrdersClient(
|
|
77
|
+
return new orders_1.OrdersClient()
|
|
78
78
|
.setUrl(this.url)
|
|
79
79
|
.setApiKey(this.apiKey)
|
|
80
80
|
.setHeaders(this.headers);
|
|
@@ -84,7 +84,7 @@ class PublicApiClient extends abstractClient_1.AbstractClient {
|
|
|
84
84
|
* @returns {@link ContactClient}
|
|
85
85
|
*/
|
|
86
86
|
getContactClient() {
|
|
87
|
-
return new contact_1.ContactClient(
|
|
87
|
+
return new contact_1.ContactClient()
|
|
88
88
|
.setUrl(this.url)
|
|
89
89
|
.setApiKey(this.apiKey)
|
|
90
90
|
.setHeaders(this.headers);
|
|
@@ -94,25 +94,25 @@ class PublicApiClient extends abstractClient_1.AbstractClient {
|
|
|
94
94
|
* @returns {@link ContactClient}
|
|
95
95
|
*/
|
|
96
96
|
getCampaignClient() {
|
|
97
|
-
return new campaign_1.CampaignClient(
|
|
97
|
+
return new campaign_1.CampaignClient()
|
|
98
98
|
.setUrl(this.url)
|
|
99
99
|
.setApiKey(this.apiKey)
|
|
100
100
|
.setHeaders(this.headers);
|
|
101
101
|
}
|
|
102
102
|
getConsumptionClient() {
|
|
103
|
-
return new consumption_1.ConsumptionClient(
|
|
103
|
+
return new consumption_1.ConsumptionClient()
|
|
104
104
|
.setUrl(this.url)
|
|
105
105
|
.setApiKey(this.apiKey)
|
|
106
106
|
.setHeaders(this.headers);
|
|
107
107
|
}
|
|
108
108
|
getSecurityStandardsClient() {
|
|
109
|
-
return new standardsClient_1.StandardsClient(
|
|
109
|
+
return new standardsClient_1.StandardsClient()
|
|
110
110
|
.setUrl(this.url)
|
|
111
111
|
.setApiKey(this.apiKey)
|
|
112
112
|
.setHeaders(this.headers);
|
|
113
113
|
}
|
|
114
114
|
getSecurityRegisterClient() {
|
|
115
|
-
return new security_1.RegisterClient(
|
|
115
|
+
return new security_1.RegisterClient()
|
|
116
116
|
.setUrl(this.url)
|
|
117
117
|
.setApiKey(this.apiKey)
|
|
118
118
|
.setHeaders(this.headers);
|
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.17.0-rc.
|
|
7
|
+
"version": "3.17.0-rc.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",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/chai": "4.2.15",
|
|
34
34
|
"@types/chai-as-promised": "7.1.3",
|
|
35
35
|
"@types/mocha": "8.2.0",
|
|
36
|
-
"@types/node": "
|
|
36
|
+
"@types/node": "18.11.10",
|
|
37
37
|
"@types/sinon": "9.0.10",
|
|
38
38
|
"@types/sinon-chai": "3.2.5",
|
|
39
39
|
"@typescript-eslint/eslint-plugin": "4.15.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@types/validatorjs": "3.15.0",
|
|
82
|
-
"axios": "
|
|
82
|
+
"axios": "1.1.3",
|
|
83
83
|
"graphql": "^16.3.0",
|
|
84
84
|
"graphql-request": "4.2.0",
|
|
85
85
|
"validatorjs": "3.22.1"
|