@artaio/node-api 1.9.0 → 1.10.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/dist/lib/ArtaClient.js +57 -144
- package/dist/lib/arta.d.ts +2 -0
- package/dist/lib/arta.js +31 -30
- package/dist/lib/endpoint/addressVerifications.js +13 -16
- package/dist/lib/endpoint/attachment.js +13 -16
- package/dist/lib/endpoint/emailRules.js +16 -19
- package/dist/lib/endpoint/emailSubscriptions.js +16 -19
- package/dist/lib/endpoint/endpoint.js +44 -160
- package/dist/lib/endpoint/hostedSessions.js +19 -70
- package/dist/lib/endpoint/importCostEstimates.d.ts +17 -0
- package/dist/lib/endpoint/importCostEstimates.js +21 -0
- package/dist/lib/endpoint/invoicePayments.js +17 -27
- package/dist/lib/endpoint/invoices.js +11 -14
- package/dist/lib/endpoint/keys.js +15 -18
- package/dist/lib/endpoint/logs.js +17 -27
- package/dist/lib/endpoint/metadata.js +63 -64
- package/dist/lib/endpoint/organization.js +12 -67
- package/dist/lib/endpoint/payments.js +17 -27
- package/dist/lib/endpoint/requests.js +35 -113
- package/dist/lib/endpoint/selfShipCollectionAvailabilityChecks.js +6 -47
- package/dist/lib/endpoint/selfShipCollections.js +13 -16
- package/dist/lib/endpoint/shipments.js +21 -23
- package/dist/lib/endpoint/tags.js +13 -16
- package/dist/lib/endpoint/trackings.js +12 -66
- package/dist/lib/endpoint/uploads.js +13 -16
- package/dist/lib/endpoint/webhookDeliveries.js +9 -12
- package/dist/lib/endpoint/webhooks.js +37 -112
- package/dist/lib/error.js +14 -35
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/logging.js +18 -48
- package/dist/lib/net/FetchHttpClient.js +43 -108
- package/dist/lib/queryParams.js +5 -6
- package/dist/lib/types.d.ts +47 -0
- package/dist/lib/utils.js +10 -17
- package/dist/package.json +24 -18
- package/package.json +24 -18
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ShipmentsEndpoint = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const endpoint_1 = require("./endpoint");
|
|
6
|
+
class ShipmentsEndpoint {
|
|
7
|
+
constructor(artaClient) {
|
|
8
8
|
this.artaClient = artaClient;
|
|
9
9
|
this.path = '/shipments';
|
|
10
10
|
this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields.bind(this));
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
enrichFields(s) {
|
|
13
|
+
var _a;
|
|
13
14
|
s.total = Number(s.total);
|
|
14
15
|
if (s.emissions) {
|
|
15
16
|
s.emissions = Number(s.emissions);
|
|
@@ -21,7 +22,7 @@ var ShipmentsEndpoint = /** @class */ (function () {
|
|
|
21
22
|
s.schedule.pickup_start = (0, utils_1.createDateAsUTC)(s.schedule.pickup_start);
|
|
22
23
|
}
|
|
23
24
|
if (s.packages) {
|
|
24
|
-
s.packages.forEach(
|
|
25
|
+
s.packages.forEach((p) => {
|
|
25
26
|
p.depth = Number(p.depth);
|
|
26
27
|
p.height = Number(p.height);
|
|
27
28
|
p.weight = Number(p.weight);
|
|
@@ -29,34 +30,31 @@ var ShipmentsEndpoint = /** @class */ (function () {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
if (s.exceptions) {
|
|
32
|
-
s.exceptions.forEach(
|
|
33
|
+
s.exceptions.forEach((e) => {
|
|
33
34
|
e.created_at = (0, utils_1.createDateAsUTC)(e.created_at);
|
|
34
35
|
e.updated_at = (0, utils_1.createDateAsUTC)(e.updated_at);
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
if (s.tags) {
|
|
38
|
-
s.tags.forEach(
|
|
39
|
+
s.tags.forEach((t) => {
|
|
39
40
|
t.created_at = (0, utils_1.createDateAsUTC)(t.created_at);
|
|
40
41
|
t.updated_at = (0, utils_1.createDateAsUTC)(t.updated_at);
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
|
-
s.services
|
|
44
|
+
(_a = s.services) === null || _a === void 0 ? void 0 : _a.forEach(utils_1.parseService);
|
|
44
45
|
return s;
|
|
45
|
-
}
|
|
46
|
-
|
|
46
|
+
}
|
|
47
|
+
getById(id, auth) {
|
|
47
48
|
return this.defaultEndpoint.getById(id, auth);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
ShipmentsEndpoint.prototype.create = function (payload, auth) {
|
|
49
|
+
}
|
|
50
|
+
list(search, page = 1, pageSize = 20, auth) {
|
|
51
|
+
return this.defaultEndpoint.list({ page, page_size: pageSize, search }, auth);
|
|
52
|
+
}
|
|
53
|
+
create(payload, auth) {
|
|
55
54
|
return this.defaultEndpoint.create({ shipment: payload }, auth);
|
|
56
|
-
}
|
|
57
|
-
|
|
55
|
+
}
|
|
56
|
+
update(id, payload, auth) {
|
|
58
57
|
return this.defaultEndpoint.update(id, { shipment: payload }, auth);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
62
60
|
exports.ShipmentsEndpoint = ShipmentsEndpoint;
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TagsEndpoint = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const endpoint_1 = require("./endpoint");
|
|
5
|
+
class TagsEndpoint {
|
|
6
|
+
constructor(artaClient) {
|
|
7
7
|
this.artaClient = artaClient;
|
|
8
8
|
this.path = '/tags';
|
|
9
9
|
this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient);
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
getByName(name, auth) {
|
|
12
12
|
return this.defaultEndpoint.getById(name, auth);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
TagsEndpoint.prototype.create = function (payload, auth) {
|
|
13
|
+
}
|
|
14
|
+
list(search, page = 1, pageSize = 20, auth) {
|
|
15
|
+
return this.defaultEndpoint.list({ page, page_size: pageSize, search }, auth);
|
|
16
|
+
}
|
|
17
|
+
create(payload, auth) {
|
|
20
18
|
return this.defaultEndpoint.create({ tag: payload }, auth);
|
|
21
|
-
}
|
|
22
|
-
|
|
19
|
+
}
|
|
20
|
+
update(name, payload, auth) {
|
|
23
21
|
return this.defaultEndpoint.update(name, { tag: payload }, auth);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
27
24
|
exports.TagsEndpoint = TagsEndpoint;
|
|
@@ -1,73 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
3
|
exports.TrackingsEndpoint = void 0;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
class TrackingsEndpoint {
|
|
6
|
+
constructor(artaClient) {
|
|
54
7
|
this.artaClient = artaClient;
|
|
55
8
|
this.path = '/trackings';
|
|
56
9
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return [2 /*return*/, __assign(__assign({}, unparsedTracking), { events: parsedEvents })];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
return TrackingsEndpoint;
|
|
72
|
-
}());
|
|
10
|
+
async getById(id, auth) {
|
|
11
|
+
const unparsedTracking = await this.artaClient.get(`${this.path}/${id}`, auth);
|
|
12
|
+
const parsedEvents = unparsedTracking.events.map((event) => ({
|
|
13
|
+
...event,
|
|
14
|
+
date: (0, utils_1.createDateAsUTC)(event.date),
|
|
15
|
+
}));
|
|
16
|
+
return { ...unparsedTracking, events: parsedEvents };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
73
19
|
exports.TrackingsEndpoint = TrackingsEndpoint;
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UploadsEndpoint = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const endpoint_1 = require("./endpoint");
|
|
5
|
+
class UploadsEndpoint {
|
|
6
|
+
constructor(artaClient) {
|
|
7
7
|
this.artaClient = artaClient;
|
|
8
8
|
this.path = '/uploads';
|
|
9
9
|
this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient);
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
getById(id, auth) {
|
|
12
12
|
return this.defaultEndpoint.getById(id, auth);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
UploadsEndpoint.prototype.create = function (payload, auth) {
|
|
13
|
+
}
|
|
14
|
+
list(page = 1, pageSize = 20, auth) {
|
|
15
|
+
return this.defaultEndpoint.list({ page, page_size: pageSize }, auth);
|
|
16
|
+
}
|
|
17
|
+
create(payload, auth) {
|
|
20
18
|
return this.defaultEndpoint.create({ upload: payload }, auth);
|
|
21
|
-
}
|
|
22
|
-
|
|
19
|
+
}
|
|
20
|
+
remove(id, auth) {
|
|
23
21
|
return this.defaultEndpoint.remove(id, auth);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
27
24
|
exports.UploadsEndpoint = UploadsEndpoint;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebhookDeliveriesEndpoint = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const endpoint_1 = require("./endpoint");
|
|
5
|
+
class WebhookDeliveriesEndpoint {
|
|
6
|
+
constructor(artaClient) {
|
|
7
7
|
this.artaClient = artaClient;
|
|
8
8
|
this.path = '/webhook_deliveries';
|
|
9
9
|
this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient);
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
getById(id, auth) {
|
|
12
12
|
return this.defaultEndpoint.getById(id, auth);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
return WebhookDeliveriesEndpoint;
|
|
20
|
-
}());
|
|
13
|
+
}
|
|
14
|
+
list(page = 1, pageSize = 20, auth) {
|
|
15
|
+
return this.defaultEndpoint.list({ page, page_size: pageSize }, auth);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
21
18
|
exports.WebhookDeliveriesEndpoint = WebhookDeliveriesEndpoint;
|
|
@@ -1,124 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.WebhooksEndpoint = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
4
|
+
const endpoint_1 = require("./endpoint");
|
|
5
|
+
class WebhooksEndpoint {
|
|
6
|
+
constructor(artaClient) {
|
|
43
7
|
this.artaClient = artaClient;
|
|
44
8
|
this.path = '/webhooks';
|
|
45
9
|
this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.withFunctionCalls.bind(this));
|
|
46
10
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
webhook.
|
|
50
|
-
webhook.
|
|
51
|
-
webhook.resetSecret = function (auth) { return _this.resetSecret(webhook.id, auth); };
|
|
11
|
+
withFunctionCalls(webhook) {
|
|
12
|
+
webhook.ping = (auth) => this.ping(webhook.id, auth);
|
|
13
|
+
webhook.getSecret = (auth) => this.getSecret(webhook.id, auth);
|
|
14
|
+
webhook.resetSecret = (auth) => this.resetSecret(webhook.id, auth);
|
|
52
15
|
return webhook;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
WebhooksEndpoint.prototype.list = function (page, pageSize, auth) {
|
|
62
|
-
if (page === void 0) { page = 1; }
|
|
63
|
-
if (pageSize === void 0) { pageSize = 20; }
|
|
64
|
-
return this.defaultEndpoint.list({ page: page, page_size: pageSize }, auth);
|
|
65
|
-
};
|
|
66
|
-
WebhooksEndpoint.prototype.listAll = function (auth) {
|
|
16
|
+
}
|
|
17
|
+
async getById(id, auth) {
|
|
18
|
+
return this.defaultEndpoint.getById(id, auth);
|
|
19
|
+
}
|
|
20
|
+
list(page = 1, pageSize = 20, auth) {
|
|
21
|
+
return this.defaultEndpoint.list({ page, page_size: pageSize }, auth);
|
|
22
|
+
}
|
|
23
|
+
listAll(auth) {
|
|
67
24
|
return this.defaultEndpoint.listAll(auth);
|
|
68
|
-
}
|
|
69
|
-
|
|
25
|
+
}
|
|
26
|
+
create(payload, auth) {
|
|
70
27
|
return this.defaultEndpoint.create({ webhook: payload }, auth);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return [2 /*return*/, this.defaultEndpoint.update(id, webhookUpdate, auth)];
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
WebhooksEndpoint.prototype.remove = function (id, auth) {
|
|
28
|
+
}
|
|
29
|
+
async update(id, payload, auth) {
|
|
30
|
+
const webhookUpdate = { webhook: payload };
|
|
31
|
+
return this.defaultEndpoint.update(id, webhookUpdate, auth);
|
|
32
|
+
}
|
|
33
|
+
remove(id, auth) {
|
|
82
34
|
return this.defaultEndpoint.remove(id, auth);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
-
var secret;
|
|
99
|
-
return __generator(this, function (_a) {
|
|
100
|
-
switch (_a.label) {
|
|
101
|
-
case 0: return [4 /*yield*/, this.artaClient.get("".concat(this.path, "/").concat(id, "/secret_token"), auth)];
|
|
102
|
-
case 1:
|
|
103
|
-
secret = _a.sent();
|
|
104
|
-
return [2 /*return*/, secret.secret_token];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
WebhooksEndpoint.prototype.resetSecret = function (id, auth) {
|
|
110
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
-
var newSecret;
|
|
112
|
-
return __generator(this, function (_a) {
|
|
113
|
-
switch (_a.label) {
|
|
114
|
-
case 0: return [4 /*yield*/, this.artaClient.patch("".concat(this.path, "/").concat(id, "/secret_token/reset"), auth)];
|
|
115
|
-
case 1:
|
|
116
|
-
newSecret = _a.sent();
|
|
117
|
-
return [2 /*return*/, newSecret.secret_token];
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
return WebhooksEndpoint;
|
|
123
|
-
}());
|
|
35
|
+
}
|
|
36
|
+
async ping(id, auth) {
|
|
37
|
+
await this.artaClient.post(`${this.path}/${id}/ping`, auth);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
async getSecret(id, auth) {
|
|
41
|
+
const secret = await this.artaClient.get(`${this.path}/${id}/secret_token`, auth);
|
|
42
|
+
return secret.secret_token;
|
|
43
|
+
}
|
|
44
|
+
async resetSecret(id, auth) {
|
|
45
|
+
const newSecret = await this.artaClient.patch(`${this.path}/${id}/secret_token/reset`, auth);
|
|
46
|
+
return newSecret.secret_token;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
124
49
|
exports.WebhooksEndpoint = WebhooksEndpoint;
|
package/dist/lib/error.js
CHANGED
|
@@ -1,54 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.ArtaSDKError = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
for (
|
|
22
|
-
var key = _a[_i];
|
|
4
|
+
const parseArtaError = (apiError) => {
|
|
5
|
+
let formattedArtaError = '';
|
|
6
|
+
for (const key of Object.keys(apiError.errors)) {
|
|
23
7
|
if (key === 'detail') {
|
|
24
|
-
return
|
|
8
|
+
return `${apiError.errors['detail']}, `;
|
|
25
9
|
}
|
|
26
10
|
else if (Array.isArray(apiError.errors[key])) {
|
|
27
|
-
for (
|
|
28
|
-
|
|
29
|
-
formattedArtaError += "".concat(key, " ").concat(error, ", ");
|
|
11
|
+
for (const error of apiError.errors[key]) {
|
|
12
|
+
formattedArtaError += `${key} ${error}, `;
|
|
30
13
|
}
|
|
31
14
|
}
|
|
32
15
|
else {
|
|
33
|
-
formattedArtaError +=
|
|
16
|
+
formattedArtaError += `${key} ${apiError.errors[key]}, `;
|
|
34
17
|
}
|
|
35
18
|
}
|
|
36
19
|
return formattedArtaError;
|
|
37
20
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var _this = this;
|
|
42
|
-
var keys = Object.keys(apiError.errors);
|
|
21
|
+
class ArtaSDKError extends Error {
|
|
22
|
+
constructor(apiError, status) {
|
|
23
|
+
const keys = Object.keys(apiError.errors);
|
|
43
24
|
if (keys.length === 0) {
|
|
44
|
-
|
|
25
|
+
super(`Unknwon API error, HTTP status: ${status}`);
|
|
45
26
|
}
|
|
46
27
|
else {
|
|
47
|
-
|
|
28
|
+
super(`${parseArtaError(apiError)}HTTP status: ${status}`);
|
|
48
29
|
}
|
|
49
|
-
Object.setPrototypeOf(
|
|
50
|
-
return _this;
|
|
30
|
+
Object.setPrototypeOf(this, ArtaSDKError.prototype);
|
|
51
31
|
}
|
|
52
|
-
|
|
53
|
-
}(Error));
|
|
32
|
+
}
|
|
54
33
|
exports.ArtaSDKError = ArtaSDKError;
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { AttachmentCreateBodyRequest, AttachmentCreateBodyShipment, AttachmentCr
|
|
|
5
5
|
export { EmailRuleCreateBody } from './endpoint/emailRules';
|
|
6
6
|
export { EmailSubscriptionCreateBody } from './endpoint/emailSubscriptions';
|
|
7
7
|
export { HostedSessionCreateBody } from './endpoint/hostedSessions';
|
|
8
|
+
export { ImportCostEstimateCreateBody, ImportCostEstimateCreateBodyDirect, ImportCostEstimateCreateBodyFromQuote, } from './endpoint/importCostEstimates';
|
|
8
9
|
export { KeyCreateBody } from './endpoint/keys';
|
|
9
10
|
export * from './MetadataTypes';
|
|
10
11
|
export { UploadCreateBody } from './endpoint/uploads';
|
package/dist/lib/logging.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getLogger = exports.initLogger = void 0;
|
|
13
4
|
var LogLevel;
|
|
@@ -18,59 +9,38 @@ var LogLevel;
|
|
|
18
9
|
LogLevel[LogLevel["INFO"] = 3] = "INFO";
|
|
19
10
|
LogLevel[LogLevel["DEBUG"] = 4] = "DEBUG";
|
|
20
11
|
})(LogLevel || (LogLevel = {}));
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
class LoggerWrapper {
|
|
13
|
+
constructor(logger, loggerVerbosity) {
|
|
23
14
|
this.logger = logger;
|
|
24
15
|
this.verbosity = LogLevel[loggerVerbosity];
|
|
25
16
|
}
|
|
26
|
-
|
|
27
|
-
var _a;
|
|
28
|
-
var optionalParams = [];
|
|
29
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
30
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
31
|
-
}
|
|
17
|
+
debug(message, ...optionalParams) {
|
|
32
18
|
if (this.verbosity >= LogLevel.DEBUG) {
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
LoggerWrapper.prototype.info = function (message) {
|
|
37
|
-
var _a;
|
|
38
|
-
var optionalParams = [];
|
|
39
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
40
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
19
|
+
this.logger.debug(message, ...optionalParams);
|
|
41
20
|
}
|
|
21
|
+
}
|
|
22
|
+
info(message, ...optionalParams) {
|
|
42
23
|
if (this.verbosity >= LogLevel.INFO) {
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
LoggerWrapper.prototype.warn = function (message) {
|
|
47
|
-
var _a;
|
|
48
|
-
var optionalParams = [];
|
|
49
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
50
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
24
|
+
this.logger.info(message, ...optionalParams);
|
|
51
25
|
}
|
|
26
|
+
}
|
|
27
|
+
warn(message, ...optionalParams) {
|
|
52
28
|
if (this.verbosity >= LogLevel.WARN) {
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
LoggerWrapper.prototype.error = function (message) {
|
|
57
|
-
var _a;
|
|
58
|
-
var optionalParams = [];
|
|
59
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
60
|
-
optionalParams[_i - 1] = arguments[_i];
|
|
29
|
+
this.logger.warn(message, ...optionalParams);
|
|
61
30
|
}
|
|
31
|
+
}
|
|
32
|
+
error(message, ...optionalParams) {
|
|
62
33
|
if (this.verbosity >= LogLevel.ERROR) {
|
|
63
|
-
|
|
34
|
+
this.logger.error(message, ...optionalParams);
|
|
64
35
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var initLogger = function (logger, loggerVerbosity) {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
let _logger;
|
|
39
|
+
const initLogger = (logger, loggerVerbosity) => {
|
|
70
40
|
_logger = new LoggerWrapper(logger, loggerVerbosity);
|
|
71
41
|
};
|
|
72
42
|
exports.initLogger = initLogger;
|
|
73
|
-
|
|
43
|
+
const getLogger = () => {
|
|
74
44
|
if (!_logger) {
|
|
75
45
|
(0, exports.initLogger)(console, 'ERROR');
|
|
76
46
|
}
|