@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.
Files changed (36) hide show
  1. package/dist/lib/ArtaClient.js +57 -144
  2. package/dist/lib/arta.d.ts +2 -0
  3. package/dist/lib/arta.js +31 -30
  4. package/dist/lib/endpoint/addressVerifications.js +13 -16
  5. package/dist/lib/endpoint/attachment.js +13 -16
  6. package/dist/lib/endpoint/emailRules.js +16 -19
  7. package/dist/lib/endpoint/emailSubscriptions.js +16 -19
  8. package/dist/lib/endpoint/endpoint.js +44 -160
  9. package/dist/lib/endpoint/hostedSessions.js +19 -70
  10. package/dist/lib/endpoint/importCostEstimates.d.ts +17 -0
  11. package/dist/lib/endpoint/importCostEstimates.js +21 -0
  12. package/dist/lib/endpoint/invoicePayments.js +17 -27
  13. package/dist/lib/endpoint/invoices.js +11 -14
  14. package/dist/lib/endpoint/keys.js +15 -18
  15. package/dist/lib/endpoint/logs.js +17 -27
  16. package/dist/lib/endpoint/metadata.js +63 -64
  17. package/dist/lib/endpoint/organization.js +12 -67
  18. package/dist/lib/endpoint/payments.js +17 -27
  19. package/dist/lib/endpoint/requests.js +35 -113
  20. package/dist/lib/endpoint/selfShipCollectionAvailabilityChecks.js +6 -47
  21. package/dist/lib/endpoint/selfShipCollections.js +13 -16
  22. package/dist/lib/endpoint/shipments.js +21 -23
  23. package/dist/lib/endpoint/tags.js +13 -16
  24. package/dist/lib/endpoint/trackings.js +12 -66
  25. package/dist/lib/endpoint/uploads.js +13 -16
  26. package/dist/lib/endpoint/webhookDeliveries.js +9 -12
  27. package/dist/lib/endpoint/webhooks.js +37 -112
  28. package/dist/lib/error.js +14 -35
  29. package/dist/lib/index.d.ts +1 -0
  30. package/dist/lib/logging.js +18 -48
  31. package/dist/lib/net/FetchHttpClient.js +43 -108
  32. package/dist/lib/queryParams.js +5 -6
  33. package/dist/lib/types.d.ts +47 -0
  34. package/dist/lib/utils.js +10 -17
  35. package/dist/package.json +24 -18
  36. package/package.json +24 -18
@@ -1,169 +1,53 @@
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
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
39
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
40
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
41
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
42
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
43
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
44
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
45
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
46
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
47
- function fulfill(value) { resume("next", value); }
48
- function reject(value) { resume("throw", value); }
49
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
50
- };
51
2
  Object.defineProperty(exports, "__esModule", { value: true });
52
3
  exports.DefaultEndpoint = void 0;
53
- var utils_1 = require("../utils");
54
- var queryParams_1 = require("../queryParams");
55
- var DefaultEndpoint = /** @class */ (function () {
56
- function DefaultEndpoint(path, artaClient, onReturn) {
4
+ const utils_1 = require("../utils");
5
+ const queryParams_1 = require("../queryParams");
6
+ class DefaultEndpoint {
7
+ constructor(path, artaClient, onReturn) {
57
8
  this.artaClient = artaClient;
58
9
  this.onReturn = onReturn;
59
- this.path = path.startsWith('/') ? path : "/".concat(path);
10
+ this.path = path.startsWith('/') ? path : `/${path}`;
11
+ }
12
+ async getById(id, auth) {
13
+ const req = await this.artaClient.get(`${this.path}/${id}`, auth);
14
+ return this.processBody(req);
15
+ }
16
+ async list(queryParam, auth) {
17
+ const toUseQueryParam = queryParam !== null && queryParam !== void 0 ? queryParam : queryParams_1.defaultQueryParams;
18
+ const queryParams = (0, queryParams_1.parseQueryParams)(toUseQueryParam);
19
+ const body = await this.artaClient.get(`${this.path}${queryParams}`, auth);
20
+ const items = body.items.map(this.processBody.bind(this));
21
+ return { items, metadata: body.metadata };
22
+ }
23
+ async *listAll(auth) {
24
+ let page = 1;
25
+ let returned_elements = 0;
26
+ let body;
27
+ do {
28
+ body = await this.artaClient.get(`${this.path}?page=${page}`, auth);
29
+ page = body.metadata.page + 1;
30
+ for (const item of body.items) {
31
+ returned_elements++;
32
+ yield this.processBody(item);
33
+ }
34
+ } while (body.metadata.total_count > returned_elements);
35
+ }
36
+ async create(payload, auth) {
37
+ const body = await this.artaClient.post(this.path, payload, auth);
38
+ return this.processBody(body);
39
+ }
40
+ async update(id, payload, auth) {
41
+ const body = await this.artaClient.patch(`${this.path}/${id}`, payload, auth);
42
+ return this.processBody(body);
60
43
  }
61
- DefaultEndpoint.prototype.getById = function (id, auth) {
62
- return __awaiter(this, void 0, void 0, function () {
63
- var req;
64
- return __generator(this, function (_a) {
65
- switch (_a.label) {
66
- case 0: return [4 /*yield*/, this.artaClient.get("".concat(this.path, "/").concat(id), auth)];
67
- case 1:
68
- req = _a.sent();
69
- return [2 /*return*/, this.processBody(req)];
70
- }
71
- });
72
- });
73
- };
74
- DefaultEndpoint.prototype.list = function (queryParam, auth) {
75
- return __awaiter(this, void 0, void 0, function () {
76
- var toUseQueryParam, queryParams, body, items;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0:
80
- toUseQueryParam = queryParam !== null && queryParam !== void 0 ? queryParam : queryParams_1.defaultQueryParams;
81
- queryParams = (0, queryParams_1.parseQueryParams)(toUseQueryParam);
82
- return [4 /*yield*/, this.artaClient.get("".concat(this.path).concat(queryParams), auth)];
83
- case 1:
84
- body = _a.sent();
85
- items = body.items.map(this.processBody.bind(this));
86
- return [2 /*return*/, { items: items, metadata: body.metadata }];
87
- }
88
- });
89
- });
90
- };
91
- DefaultEndpoint.prototype.listAll = function (auth) {
92
- return __asyncGenerator(this, arguments, function listAll_1() {
93
- var page, returned_elements, body, _i, _a, item;
94
- return __generator(this, function (_b) {
95
- switch (_b.label) {
96
- case 0:
97
- page = 1;
98
- returned_elements = 0;
99
- _b.label = 1;
100
- case 1: return [4 /*yield*/, __await(this.artaClient.get("".concat(this.path, "?page=").concat(page), auth))];
101
- case 2:
102
- body = _b.sent();
103
- page = body.metadata.page + 1;
104
- _i = 0, _a = body.items;
105
- _b.label = 3;
106
- case 3:
107
- if (!(_i < _a.length)) return [3 /*break*/, 7];
108
- item = _a[_i];
109
- returned_elements++;
110
- return [4 /*yield*/, __await(this.processBody(item))];
111
- case 4: return [4 /*yield*/, _b.sent()];
112
- case 5:
113
- _b.sent();
114
- _b.label = 6;
115
- case 6:
116
- _i++;
117
- return [3 /*break*/, 3];
118
- case 7:
119
- if (body.metadata.total_count > returned_elements) return [3 /*break*/, 1];
120
- _b.label = 8;
121
- case 8: return [2 /*return*/];
122
- }
123
- });
124
- });
125
- };
126
- DefaultEndpoint.prototype.create = function (payload, auth) {
127
- return __awaiter(this, void 0, void 0, function () {
128
- var body;
129
- return __generator(this, function (_a) {
130
- switch (_a.label) {
131
- case 0: return [4 /*yield*/, this.artaClient.post(this.path, payload, auth)];
132
- case 1:
133
- body = _a.sent();
134
- return [2 /*return*/, this.processBody(body)];
135
- }
136
- });
137
- });
138
- };
139
- DefaultEndpoint.prototype.update = function (id, payload, auth) {
140
- return __awaiter(this, void 0, void 0, function () {
141
- var body;
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
144
- case 0: return [4 /*yield*/, this.artaClient.patch("".concat(this.path, "/").concat(id), payload, auth)];
145
- case 1:
146
- body = _a.sent();
147
- return [2 /*return*/, this.processBody(body)];
148
- }
149
- });
150
- });
151
- };
152
- DefaultEndpoint.prototype.remove = function (id, auth) {
153
- return __awaiter(this, void 0, void 0, function () {
154
- return __generator(this, function (_a) {
155
- switch (_a.label) {
156
- case 0: return [4 /*yield*/, this.artaClient.delete("".concat(this.path, "/").concat(id), auth)];
157
- case 1: return [2 /*return*/, _a.sent()];
158
- }
159
- });
160
- });
161
- };
162
- DefaultEndpoint.prototype.processBody = function (payload) {
163
- var resource = (0, utils_1.convertDatesToUtc)(payload);
44
+ async remove(id, auth) {
45
+ return await this.artaClient.delete(`${this.path}/${id}`, auth);
46
+ }
47
+ processBody(payload) {
48
+ let resource = (0, utils_1.convertDatesToUtc)(payload);
164
49
  resource = this.onReturn ? this.onReturn(resource) : resource;
165
50
  return resource;
166
- };
167
- return DefaultEndpoint;
168
- }());
51
+ }
52
+ }
169
53
  exports.DefaultEndpoint = DefaultEndpoint;
@@ -1,81 +1,30 @@
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.HostedSessionsEndpoint = void 0;
40
- var utils_1 = require("../utils");
41
- var endpoint_1 = require("./endpoint");
42
- var HostedSessionsEndpoint = /** @class */ (function () {
43
- function HostedSessionsEndpoint(artaClient) {
4
+ const utils_1 = require("../utils");
5
+ const endpoint_1 = require("./endpoint");
6
+ class HostedSessionsEndpoint {
7
+ constructor(artaClient) {
44
8
  this.artaClient = artaClient;
45
9
  this.path = '/hosted_sessions';
46
10
  this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.withFunctionCalls.bind(this));
47
11
  }
48
- HostedSessionsEndpoint.prototype.withFunctionCalls = function (hostedSession) {
49
- var _this = this;
50
- hostedSession.cancel = function (auth) {
51
- return _this.cancel(hostedSession.id, auth);
52
- };
12
+ withFunctionCalls(hostedSession) {
13
+ hostedSession.cancel = (auth) => this.cancel(hostedSession.id, auth);
53
14
  return hostedSession;
54
- };
55
- HostedSessionsEndpoint.prototype.getById = function (id, auth) {
15
+ }
16
+ getById(id, auth) {
56
17
  return this.defaultEndpoint.getById(id, auth);
57
- };
58
- HostedSessionsEndpoint.prototype.list = function (search, page, pageSize, auth) {
59
- if (page === void 0) { page = 1; }
60
- if (pageSize === void 0) { pageSize = 20; }
61
- return this.defaultEndpoint.list({ page: page, page_size: pageSize, search: search }, auth);
62
- };
63
- HostedSessionsEndpoint.prototype.create = function (payload, auth) {
18
+ }
19
+ list(search, page = 1, pageSize = 20, auth) {
20
+ return this.defaultEndpoint.list({ page, page_size: pageSize, search }, auth);
21
+ }
22
+ create(payload, auth) {
64
23
  return this.defaultEndpoint.create({ hosted_session: payload }, auth);
65
- };
66
- HostedSessionsEndpoint.prototype.cancel = function (id, auth) {
67
- return __awaiter(this, void 0, void 0, function () {
68
- var rawSession;
69
- return __generator(this, function (_a) {
70
- switch (_a.label) {
71
- case 0: return [4 /*yield*/, this.artaClient.patch("".concat(this.path, "/").concat(id, "/cancel"), undefined, auth)];
72
- case 1:
73
- rawSession = _a.sent();
74
- return [2 /*return*/, this.withFunctionCalls((0, utils_1.convertDatesToUtc)(rawSession))];
75
- }
76
- });
77
- });
78
- };
79
- return HostedSessionsEndpoint;
80
- }());
24
+ }
25
+ async cancel(id, auth) {
26
+ const rawSession = await this.artaClient.patch(`${this.path}/${id}/cancel`, undefined, auth);
27
+ return this.withFunctionCalls((0, utils_1.convertDatesToUtc)(rawSession));
28
+ }
29
+ }
81
30
  exports.HostedSessionsEndpoint = HostedSessionsEndpoint;
@@ -0,0 +1,17 @@
1
+ import type { RestClient } from '../net/RestClient';
2
+ import type { Page } from '../pagination';
3
+ import type { ImportCostEstimate } from '../types';
4
+ export type ImportCostEstimateCreateBodyFromQuote = Pick<ImportCostEstimate, 'currency' | 'end_use' | 'reference'> & {
5
+ quote_id: string;
6
+ };
7
+ export type ImportCostEstimateCreateBodyDirect = Pick<ImportCostEstimate, 'currency' | 'destination' | 'end_use' | 'objects' | 'origin' | 'reference' | 'transport'>;
8
+ export type ImportCostEstimateCreateBody = ImportCostEstimateCreateBodyFromQuote | ImportCostEstimateCreateBodyDirect;
9
+ export declare class ImportCostEstimatesEndpoint {
10
+ private readonly artaClient;
11
+ private readonly defaultEndpoint;
12
+ private readonly path;
13
+ constructor(artaClient: RestClient);
14
+ getById(id: ImportCostEstimate['id'], auth?: string): Promise<ImportCostEstimate>;
15
+ list(page?: number, pageSize?: number, auth?: string): Promise<Page<ImportCostEstimate>>;
16
+ create(payload: ImportCostEstimateCreateBody, auth?: string): Promise<ImportCostEstimate>;
17
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportCostEstimatesEndpoint = void 0;
4
+ const endpoint_1 = require("./endpoint");
5
+ class ImportCostEstimatesEndpoint {
6
+ constructor(artaClient) {
7
+ this.artaClient = artaClient;
8
+ this.path = '/import_cost_estimates';
9
+ this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient);
10
+ }
11
+ getById(id, auth) {
12
+ return this.defaultEndpoint.getById(id, auth);
13
+ }
14
+ list(page = 1, pageSize = 20, auth) {
15
+ return this.defaultEndpoint.list({ page, page_size: pageSize }, auth);
16
+ }
17
+ create(payload, auth) {
18
+ return this.defaultEndpoint.create({ import_cost_estimate: payload }, auth);
19
+ }
20
+ }
21
+ exports.ImportCostEstimatesEndpoint = ImportCostEstimatesEndpoint;
@@ -1,36 +1,26 @@
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.InvoicePaymentsEndpoint = void 0;
15
- var utils_1 = require("../utils");
16
- var endpoint_1 = require("./endpoint");
17
- var InvoicePaymentsEndpoint = /** @class */ (function () {
18
- function InvoicePaymentsEndpoint(artaClient) {
4
+ const utils_1 = require("../utils");
5
+ const endpoint_1 = require("./endpoint");
6
+ class InvoicePaymentsEndpoint {
7
+ constructor(artaClient) {
19
8
  this.artaClient = artaClient;
20
9
  this.path = '/invoice_payments';
21
10
  this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields);
22
11
  }
23
- InvoicePaymentsEndpoint.prototype.getById = function (id, auth) {
12
+ getById(id, auth) {
24
13
  return this.defaultEndpoint.getById(id, auth);
25
- };
26
- InvoicePaymentsEndpoint.prototype.list = function (page, pageSize, auth) {
27
- if (page === void 0) { page = 1; }
28
- if (pageSize === void 0) { pageSize = 20; }
29
- return this.defaultEndpoint.list({ page: page, page_size: pageSize }, auth);
30
- };
31
- InvoicePaymentsEndpoint.prototype.enrichFields = function (resource) {
32
- return __assign(__assign({}, resource), { amount: Number(resource.amount), paid_on: (0, utils_1.createDateAsUTC)(resource.paid_on) });
33
- };
34
- return InvoicePaymentsEndpoint;
35
- }());
14
+ }
15
+ list(page = 1, pageSize = 20, auth) {
16
+ return this.defaultEndpoint.list({ page, page_size: pageSize }, auth);
17
+ }
18
+ enrichFields(resource) {
19
+ return {
20
+ ...resource,
21
+ amount: Number(resource.amount),
22
+ paid_on: (0, utils_1.createDateAsUTC)(resource.paid_on),
23
+ };
24
+ }
25
+ }
36
26
  exports.InvoicePaymentsEndpoint = InvoicePaymentsEndpoint;
@@ -1,27 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvoicesEndpoint = void 0;
4
- var endpoint_1 = require("./endpoint");
5
- var InvoicesEndpoint = /** @class */ (function () {
6
- function InvoicesEndpoint(artaClient) {
4
+ const endpoint_1 = require("./endpoint");
5
+ class InvoicesEndpoint {
6
+ constructor(artaClient) {
7
7
  this.artaClient = artaClient;
8
8
  this.path = '/invoices';
9
9
  this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields);
10
10
  }
11
- InvoicesEndpoint.prototype.getById = function (id, auth) {
11
+ getById(id, auth) {
12
12
  return this.defaultEndpoint.getById(id, auth);
13
- };
14
- InvoicesEndpoint.prototype.list = function (page, pageSize, auth) {
15
- if (page === void 0) { page = 1; }
16
- if (pageSize === void 0) { pageSize = 20; }
17
- return this.defaultEndpoint.list({ page: page, page_size: pageSize }, auth);
18
- };
19
- InvoicesEndpoint.prototype.enrichFields = function (resource) {
13
+ }
14
+ list(page = 1, pageSize = 20, auth) {
15
+ return this.defaultEndpoint.list({ page, page_size: pageSize }, auth);
16
+ }
17
+ enrichFields(resource) {
20
18
  resource.amount_owed = Number(resource.amount_owed);
21
19
  resource.amount_paid = Number(resource.amount_paid);
22
20
  resource.issued_on = resource.issued_on && new Date(resource.issued_on);
23
21
  return resource;
24
- };
25
- return InvoicesEndpoint;
26
- }());
22
+ }
23
+ }
27
24
  exports.InvoicesEndpoint = InvoicesEndpoint;
@@ -1,30 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KeysEndpoint = void 0;
4
- var endpoint_1 = require("./endpoint");
5
- var KeysEndpoint = /** @class */ (function () {
6
- function KeysEndpoint(artaClient) {
4
+ const endpoint_1 = require("./endpoint");
5
+ class KeysEndpoint {
6
+ constructor(artaClient) {
7
7
  this.artaClient = artaClient;
8
8
  this.path = '/api_keys';
9
9
  this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient);
10
10
  }
11
- KeysEndpoint.prototype.getById = function (id, auth) {
11
+ getById(id, auth) {
12
12
  return this.defaultEndpoint.getById(id, auth);
13
- };
14
- KeysEndpoint.prototype.list = function (page, pageSize, auth) {
15
- if (page === void 0) { page = 1; }
16
- if (pageSize === void 0) { pageSize = 20; }
17
- return this.defaultEndpoint.list({ page: page, page_size: pageSize }, auth);
18
- };
19
- KeysEndpoint.prototype.listAll = function (auth) {
13
+ }
14
+ list(page = 1, pageSize = 20, auth) {
15
+ return this.defaultEndpoint.list({ page, page_size: pageSize }, auth);
16
+ }
17
+ listAll(auth) {
20
18
  return this.defaultEndpoint.listAll(auth);
21
- };
22
- KeysEndpoint.prototype.create = function (payload, auth) {
19
+ }
20
+ create(payload, auth) {
23
21
  return this.defaultEndpoint.create({ api_key: payload }, auth);
24
- };
25
- KeysEndpoint.prototype.remove = function (id, auth) {
22
+ }
23
+ remove(id, auth) {
26
24
  return this.defaultEndpoint.remove(id, auth);
27
- };
28
- return KeysEndpoint;
29
- }());
25
+ }
26
+ }
30
27
  exports.KeysEndpoint = KeysEndpoint;
@@ -1,36 +1,26 @@
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.LogsEndpoint = void 0;
15
- var utils_1 = require("../utils");
16
- var endpoint_1 = require("./endpoint");
17
- var LogsEndpoint = /** @class */ (function () {
18
- function LogsEndpoint(artaClient) {
4
+ const utils_1 = require("../utils");
5
+ const endpoint_1 = require("./endpoint");
6
+ class LogsEndpoint {
7
+ constructor(artaClient) {
19
8
  this.artaClient = artaClient;
20
9
  this.path = '/logs';
21
10
  this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields);
22
11
  }
23
- LogsEndpoint.prototype.getById = function (id, auth) {
12
+ getById(id, auth) {
24
13
  return this.defaultEndpoint.getById(id, auth);
25
- };
26
- LogsEndpoint.prototype.list = function (page, pageSize, auth) {
27
- if (page === void 0) { page = 1; }
28
- if (pageSize === void 0) { pageSize = 20; }
29
- return this.defaultEndpoint.list({ page: page, page_size: pageSize }, auth);
30
- };
31
- LogsEndpoint.prototype.enrichFields = function (resource) {
32
- return __assign(__assign({}, resource), { start_at: (0, utils_1.createDateAsUTC)(resource.start_at), end_at: (0, utils_1.createDateAsUTC)(resource.end_at) });
33
- };
34
- return LogsEndpoint;
35
- }());
14
+ }
15
+ list(page = 1, pageSize = 20, auth) {
16
+ return this.defaultEndpoint.list({ page, page_size: pageSize }, auth);
17
+ }
18
+ enrichFields(resource) {
19
+ return {
20
+ ...resource,
21
+ start_at: (0, utils_1.createDateAsUTC)(resource.start_at),
22
+ end_at: (0, utils_1.createDateAsUTC)(resource.end_at),
23
+ };
24
+ }
25
+ }
36
26
  exports.LogsEndpoint = LogsEndpoint;