@artaio/node-api 0.27.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 (66) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +48 -0
  3. package/dist/lib/ArtaClient.d.ts +21 -0
  4. package/dist/lib/ArtaClient.js +155 -0
  5. package/dist/lib/MetadataTypes.d.ts +96 -0
  6. package/dist/lib/MetadataTypes.js +2 -0
  7. package/dist/lib/arta.d.ts +45 -0
  8. package/dist/lib/arta.js +57 -0
  9. package/dist/lib/endpoint/attachment.d.ts +32 -0
  10. package/dist/lib/endpoint/attachment.js +27 -0
  11. package/dist/lib/endpoint/emailRules.d.ts +30 -0
  12. package/dist/lib/endpoint/emailRules.js +33 -0
  13. package/dist/lib/endpoint/emailSubscriptions.d.ts +32 -0
  14. package/dist/lib/endpoint/emailSubscriptions.js +33 -0
  15. package/dist/lib/endpoint/endpoint.d.ts +26 -0
  16. package/dist/lib/endpoint/endpoint.js +168 -0
  17. package/dist/lib/endpoint/hostedSessions.d.ts +53 -0
  18. package/dist/lib/endpoint/hostedSessions.js +81 -0
  19. package/dist/lib/endpoint/invoicePayments.d.ts +24 -0
  20. package/dist/lib/endpoint/invoicePayments.js +26 -0
  21. package/dist/lib/endpoint/invoices.d.ts +27 -0
  22. package/dist/lib/endpoint/invoices.js +27 -0
  23. package/dist/lib/endpoint/keys.d.ts +28 -0
  24. package/dist/lib/endpoint/keys.js +30 -0
  25. package/dist/lib/endpoint/logs.d.ts +29 -0
  26. package/dist/lib/endpoint/logs.js +27 -0
  27. package/dist/lib/endpoint/metadata.d.ts +67 -0
  28. package/dist/lib/endpoint/metadata.js +56 -0
  29. package/dist/lib/endpoint/organization.d.ts +31 -0
  30. package/dist/lib/endpoint/organization.js +84 -0
  31. package/dist/lib/endpoint/payments.d.ts +21 -0
  32. package/dist/lib/endpoint/payments.js +26 -0
  33. package/dist/lib/endpoint/requests.d.ts +80 -0
  34. package/dist/lib/endpoint/requests.js +113 -0
  35. package/dist/lib/endpoint/shipments.d.ts +80 -0
  36. package/dist/lib/endpoint/shipments.js +44 -0
  37. package/dist/lib/endpoint/trackings.d.ts +25 -0
  38. package/dist/lib/endpoint/trackings.js +64 -0
  39. package/dist/lib/endpoint/uploads.d.ts +36 -0
  40. package/dist/lib/endpoint/uploads.js +27 -0
  41. package/dist/lib/endpoint/webhookDeliveries.d.ts +26 -0
  42. package/dist/lib/endpoint/webhookDeliveries.js +21 -0
  43. package/dist/lib/endpoint/webhooks.d.ts +35 -0
  44. package/dist/lib/endpoint/webhooks.js +124 -0
  45. package/dist/lib/error.d.ts +8 -0
  46. package/dist/lib/error.js +54 -0
  47. package/dist/lib/index.d.ts +19 -0
  48. package/dist/lib/index.js +20 -0
  49. package/dist/lib/logging.d.ts +17 -0
  50. package/dist/lib/logging.js +79 -0
  51. package/dist/lib/net/HttpClient.d.ts +19 -0
  52. package/dist/lib/net/HttpClient.js +2 -0
  53. package/dist/lib/net/NodeHttpClient.d.ts +20 -0
  54. package/dist/lib/net/NodeHttpClient.js +203 -0
  55. package/dist/lib/net/RestClient.d.ts +6 -0
  56. package/dist/lib/net/RestClient.js +2 -0
  57. package/dist/lib/pagination.d.ts +9 -0
  58. package/dist/lib/pagination.js +2 -0
  59. package/dist/lib/queryParams.d.ts +7 -0
  60. package/dist/lib/queryParams.js +23 -0
  61. package/dist/lib/search.d.ts +3 -0
  62. package/dist/lib/search.js +2 -0
  63. package/dist/lib/utils.d.ts +9 -0
  64. package/dist/lib/utils.js +24 -0
  65. package/dist/package.json +49 -0
  66. package/package.json +58 -0
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailSubscriptionsEndpoint = void 0;
4
+ var endpoint_1 = require("./endpoint");
5
+ var EmailSubscriptionsEndpoint = /** @class */ (function () {
6
+ function EmailSubscriptionsEndpoint(artaClient) {
7
+ this.artaClient = artaClient;
8
+ this.path = '/email_subscriptions';
9
+ this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient);
10
+ }
11
+ EmailSubscriptionsEndpoint.prototype.getById = function (id, auth) {
12
+ return this.defaultEndpoint.getById(id, auth);
13
+ };
14
+ EmailSubscriptionsEndpoint.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
+ EmailSubscriptionsEndpoint.prototype.update = function (id, payload, auth) {
20
+ var emailNotificationPayload = {
21
+ email_subscription: payload,
22
+ };
23
+ return this.defaultEndpoint.update(id, emailNotificationPayload, auth);
24
+ };
25
+ EmailSubscriptionsEndpoint.prototype.create = function (payload, auth) {
26
+ return this.defaultEndpoint.create({ email_subscription: payload }, auth);
27
+ };
28
+ EmailSubscriptionsEndpoint.prototype.remove = function (id, auth) {
29
+ return this.defaultEndpoint.remove(id, auth);
30
+ };
31
+ return EmailSubscriptionsEndpoint;
32
+ }());
33
+ exports.EmailSubscriptionsEndpoint = EmailSubscriptionsEndpoint;
@@ -0,0 +1,26 @@
1
+ import { ArtaID } from '../ArtaClient';
2
+ import { RestClient } from '../net/RestClient';
3
+ import { DatedInterface } from '../utils';
4
+ import { Page } from '../pagination';
5
+ import { QueryParameters } from '../queryParams';
6
+ export interface Endpoint<T, U> {
7
+ list: (queryParam?: QueryParameters, auth?: string) => Promise<Page<T>>;
8
+ listAll: (auth?: string, onReturn?: (params: any) => T) => AsyncGenerator<T>;
9
+ getById: (id: ArtaID, auth?: string) => Promise<T>;
10
+ create: (payload: U, auth?: string) => Promise<T>;
11
+ update: (id: ArtaID, payload: Partial<U> | Partial<T>, auth?: string) => Promise<T>;
12
+ remove: (id: ArtaID, auth?: string) => Promise<void>;
13
+ }
14
+ export declare class DefaultEndpoint<T extends DatedInterface, U> implements Endpoint<T, U> {
15
+ private readonly artaClient;
16
+ private readonly onReturn?;
17
+ private readonly path;
18
+ constructor(path: string, artaClient: RestClient, onReturn?: ((params: any) => T) | undefined);
19
+ getById(id: ArtaID, auth?: string): Promise<T>;
20
+ list(queryParam?: QueryParameters, auth?: string): Promise<Page<T>>;
21
+ listAll(auth?: string): AsyncGenerator<T>;
22
+ create(payload: U, auth?: string): Promise<T>;
23
+ update(id: ArtaID, payload: Partial<U> | Partial<T>, auth?: string): Promise<T>;
24
+ remove(id: ArtaID, auth?: string): Promise<void>;
25
+ private processBody;
26
+ }
@@ -0,0 +1,168 @@
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;
13
+ return g = { next: verb(0), "throw": verb(1), "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 = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
43
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
44
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
45
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
46
+ function fulfill(value) { resume("next", value); }
47
+ function reject(value) { resume("throw", value); }
48
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.DefaultEndpoint = void 0;
52
+ var utils_1 = require("../utils");
53
+ var queryParams_1 = require("../queryParams");
54
+ var DefaultEndpoint = /** @class */ (function () {
55
+ function DefaultEndpoint(path, artaClient, onReturn) {
56
+ this.artaClient = artaClient;
57
+ this.onReturn = onReturn;
58
+ this.path = path.startsWith('/') ? path : "/".concat(path);
59
+ }
60
+ DefaultEndpoint.prototype.getById = function (id, auth) {
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ var req;
63
+ return __generator(this, function (_a) {
64
+ switch (_a.label) {
65
+ case 0: return [4 /*yield*/, this.artaClient.get("".concat(this.path, "/").concat(id), auth)];
66
+ case 1:
67
+ req = _a.sent();
68
+ return [2 /*return*/, this.processBody(req)];
69
+ }
70
+ });
71
+ });
72
+ };
73
+ DefaultEndpoint.prototype.list = function (queryParam, auth) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var toUseQueryParam, queryParams, body, items;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ toUseQueryParam = queryParam !== null && queryParam !== void 0 ? queryParam : queryParams_1.defaultQueryParams;
80
+ queryParams = (0, queryParams_1.parseQueryParams)(toUseQueryParam);
81
+ return [4 /*yield*/, this.artaClient.get("".concat(this.path).concat(queryParams), auth)];
82
+ case 1:
83
+ body = _a.sent();
84
+ items = body.items.map(this.processBody.bind(this));
85
+ return [2 /*return*/, { items: items, metadata: body.metadata }];
86
+ }
87
+ });
88
+ });
89
+ };
90
+ DefaultEndpoint.prototype.listAll = function (auth) {
91
+ return __asyncGenerator(this, arguments, function listAll_1() {
92
+ var page, returned_elements, body, _i, _a, item;
93
+ return __generator(this, function (_b) {
94
+ switch (_b.label) {
95
+ case 0:
96
+ page = 1;
97
+ returned_elements = 0;
98
+ _b.label = 1;
99
+ case 1: return [4 /*yield*/, __await(this.artaClient.get("".concat(this.path, "?page=").concat(page), auth))];
100
+ case 2:
101
+ body = _b.sent();
102
+ page = body.metadata.page + 1;
103
+ _i = 0, _a = body.items;
104
+ _b.label = 3;
105
+ case 3:
106
+ if (!(_i < _a.length)) return [3 /*break*/, 7];
107
+ item = _a[_i];
108
+ returned_elements++;
109
+ return [4 /*yield*/, __await(this.processBody(item))];
110
+ case 4: return [4 /*yield*/, _b.sent()];
111
+ case 5:
112
+ _b.sent();
113
+ _b.label = 6;
114
+ case 6:
115
+ _i++;
116
+ return [3 /*break*/, 3];
117
+ case 7:
118
+ if (body.metadata.total_count > returned_elements) return [3 /*break*/, 1];
119
+ _b.label = 8;
120
+ case 8: return [2 /*return*/];
121
+ }
122
+ });
123
+ });
124
+ };
125
+ DefaultEndpoint.prototype.create = function (payload, auth) {
126
+ return __awaiter(this, void 0, void 0, function () {
127
+ var body;
128
+ return __generator(this, function (_a) {
129
+ switch (_a.label) {
130
+ case 0: return [4 /*yield*/, this.artaClient.post(this.path, payload, auth)];
131
+ case 1:
132
+ body = _a.sent();
133
+ return [2 /*return*/, this.processBody(body)];
134
+ }
135
+ });
136
+ });
137
+ };
138
+ DefaultEndpoint.prototype.update = function (id, payload, auth) {
139
+ return __awaiter(this, void 0, void 0, function () {
140
+ var body;
141
+ return __generator(this, function (_a) {
142
+ switch (_a.label) {
143
+ case 0: return [4 /*yield*/, this.artaClient.patch("".concat(this.path, "/").concat(id), payload, auth)];
144
+ case 1:
145
+ body = _a.sent();
146
+ return [2 /*return*/, this.processBody(body)];
147
+ }
148
+ });
149
+ });
150
+ };
151
+ DefaultEndpoint.prototype.remove = function (id, auth) {
152
+ return __awaiter(this, void 0, void 0, function () {
153
+ return __generator(this, function (_a) {
154
+ switch (_a.label) {
155
+ case 0: return [4 /*yield*/, this.artaClient.delete("".concat(this.path, "/").concat(id), auth)];
156
+ case 1: return [2 /*return*/, _a.sent()];
157
+ }
158
+ });
159
+ });
160
+ };
161
+ DefaultEndpoint.prototype.processBody = function (payload) {
162
+ var resource = (0, utils_1.convertDatesToUtc)(payload);
163
+ resource = this.onReturn ? this.onReturn(resource) : resource;
164
+ return resource;
165
+ };
166
+ return DefaultEndpoint;
167
+ }());
168
+ exports.DefaultEndpoint = DefaultEndpoint;
@@ -0,0 +1,53 @@
1
+ import { ArtaID } from '../ArtaClient';
2
+ import { RestClient } from '../net/RestClient';
3
+ import { Page } from '../pagination';
4
+ import { AdditionalService, ArtaLocation, ArtaObject, Insurance, PaymentProcessType, QuoteType, QuoteRequestStatus } from '../MetadataTypes';
5
+ import { DatedInterface, Nullable, NullableString } from '../utils';
6
+ import { HostedSessionsSearch } from '../search';
7
+ export interface HostedSession extends DatedInterface {
8
+ id: ArtaID;
9
+ additional_services?: Nullable<AdditionalService[]>;
10
+ cancel_url?: NullableString;
11
+ destination?: Nullable<ArtaLocation>;
12
+ insurance?: Nullable<Insurance>;
13
+ internal_reference?: NullableString;
14
+ objects: ArtaObject[];
15
+ origin: ArtaLocation;
16
+ preferred_quote_types?: Nullable<QuoteType[]>;
17
+ public_reference?: NullableString;
18
+ shipping_notes?: NullableString;
19
+ success_url?: NullableString;
20
+ payment_process: PaymentProcessType;
21
+ private_token: string;
22
+ shortcode: string;
23
+ status: QuoteRequestStatus;
24
+ url?: NullableString;
25
+ cancel: (auth?: string) => Promise<HostedSession>;
26
+ }
27
+ export interface HostedSessionCreateBody {
28
+ additional_services?: Nullable<AdditionalService[]>;
29
+ cancel_url?: NullableString;
30
+ destination?: Nullable<ArtaLocation>;
31
+ insurance?: Nullable<Insurance>;
32
+ internal_reference?: NullableString;
33
+ objects: ArtaObject[];
34
+ origin: ArtaLocation;
35
+ preferred_quote_types?: Nullable<QuoteType[]>;
36
+ public_reference?: NullableString;
37
+ shipping_notes?: NullableString;
38
+ success_url?: NullableString;
39
+ }
40
+ export interface HostedSessionCreate {
41
+ hosted_session: HostedSessionCreateBody;
42
+ }
43
+ export declare class HostedSessionsEndpoint {
44
+ private readonly artaClient;
45
+ private readonly defaultEndpoint;
46
+ private readonly path;
47
+ constructor(artaClient: RestClient);
48
+ private withFunctionCalls;
49
+ getById(id: ArtaID, auth?: string): Promise<HostedSession>;
50
+ list(search?: HostedSessionsSearch, page?: number, pageSize?: number, auth?: string): Promise<Page<HostedSession>>;
51
+ create(payload: HostedSessionCreateBody, auth?: string): Promise<HostedSession>;
52
+ cancel(id: ArtaID, auth?: string): Promise<HostedSession>;
53
+ }
@@ -0,0 +1,81 @@
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;
13
+ return g = { next: verb(0), "throw": verb(1), "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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ 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) {
44
+ this.artaClient = artaClient;
45
+ this.path = '/hosted_sessions';
46
+ this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.withFunctionCalls.bind(this));
47
+ }
48
+ HostedSessionsEndpoint.prototype.withFunctionCalls = function (hostedSession) {
49
+ var _this = this;
50
+ hostedSession.cancel = function (auth) {
51
+ return _this.cancel(hostedSession.id, auth);
52
+ };
53
+ return hostedSession;
54
+ };
55
+ HostedSessionsEndpoint.prototype.getById = function (id, auth) {
56
+ 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) {
64
+ 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
+ }());
81
+ exports.HostedSessionsEndpoint = HostedSessionsEndpoint;
@@ -0,0 +1,24 @@
1
+ import { ArtaID } from '../ArtaClient';
2
+ import { SupportedCurrency } from '../MetadataTypes';
3
+ import { RestClient } from '../net/RestClient';
4
+ import { Page } from '../pagination';
5
+ import { DatedInterface, NullableString } from '../utils';
6
+ export interface InvoicePayment extends DatedInterface {
7
+ id: ArtaID;
8
+ amount: number;
9
+ amount_currency: SupportedCurrency;
10
+ credit_id: NullableString;
11
+ invoice_id: NullableString;
12
+ paid_on: Date;
13
+ payment_id?: NullableString;
14
+ shipment_id?: NullableString;
15
+ }
16
+ export declare class InvoicePaymentsEndpoint {
17
+ private readonly artaClient;
18
+ private readonly defaultEndpoint;
19
+ private readonly path;
20
+ constructor(artaClient: RestClient);
21
+ getById(id: ArtaID, auth?: string): Promise<InvoicePayment>;
22
+ list(page?: number, pageSize?: number, auth?: string): Promise<Page<InvoicePayment>>;
23
+ private enrichFields;
24
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvoicePaymentsEndpoint = void 0;
4
+ var endpoint_1 = require("./endpoint");
5
+ var InvoicePaymentsEndpoint = /** @class */ (function () {
6
+ function InvoicePaymentsEndpoint(artaClient) {
7
+ this.artaClient = artaClient;
8
+ this.path = '/invoice_payments';
9
+ this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields);
10
+ }
11
+ InvoicePaymentsEndpoint.prototype.getById = function (id, auth) {
12
+ return this.defaultEndpoint.getById(id, auth);
13
+ };
14
+ InvoicePaymentsEndpoint.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
+ InvoicePaymentsEndpoint.prototype.enrichFields = function (resource) {
20
+ resource.amount = Number(resource.amount);
21
+ resource.paid_on = new Date(resource.paid_on);
22
+ return resource;
23
+ };
24
+ return InvoicePaymentsEndpoint;
25
+ }());
26
+ exports.InvoicePaymentsEndpoint = InvoicePaymentsEndpoint;
@@ -0,0 +1,27 @@
1
+ import { ArtaID } from '../ArtaClient';
2
+ import { SupportedCurrency } from '../MetadataTypes';
3
+ import { RestClient } from '../net/RestClient';
4
+ import { Page } from '../pagination';
5
+ import { DatedInterface, Nullable, NullableString } from '../utils';
6
+ export interface Invoice extends DatedInterface {
7
+ amount_owed: number;
8
+ amount_owed_currency: SupportedCurrency;
9
+ amount_paid: number;
10
+ amount_paid_currency: SupportedCurrency;
11
+ created_at: Date;
12
+ invoice_url?: NullableString;
13
+ id: ArtaID;
14
+ issued_on: Nullable<Date>;
15
+ shipment_id: NullableString;
16
+ status: string;
17
+ updated_at: Date;
18
+ }
19
+ export declare class InvoicesEndpoint {
20
+ private readonly artaClient;
21
+ private readonly defaultEndpoint;
22
+ private readonly path;
23
+ constructor(artaClient: RestClient);
24
+ getById(id: ArtaID, auth?: string): Promise<Invoice>;
25
+ list(page?: number, pageSize?: number, auth?: string): Promise<Page<Invoice>>;
26
+ private enrichFields;
27
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InvoicesEndpoint = void 0;
4
+ var endpoint_1 = require("./endpoint");
5
+ var InvoicesEndpoint = /** @class */ (function () {
6
+ function InvoicesEndpoint(artaClient) {
7
+ this.artaClient = artaClient;
8
+ this.path = '/invoices';
9
+ this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields);
10
+ }
11
+ InvoicesEndpoint.prototype.getById = function (id, auth) {
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) {
20
+ resource.amount_owed = Number(resource.amount_owed);
21
+ resource.amount_paid = Number(resource.amount_paid);
22
+ resource.issued_on = resource.issued_on && new Date(resource.issued_on);
23
+ return resource;
24
+ };
25
+ return InvoicesEndpoint;
26
+ }());
27
+ exports.InvoicesEndpoint = InvoicesEndpoint;
@@ -0,0 +1,28 @@
1
+ import { ArtaID } from '../ArtaClient';
2
+ import { RestClient } from '../net/RestClient';
3
+ import { DatedInterface, NullableString } from '../utils';
4
+ import { Page } from '../pagination';
5
+ export interface Key extends DatedInterface {
6
+ id: ArtaID;
7
+ is_testing: boolean;
8
+ name?: NullableString;
9
+ token: string;
10
+ }
11
+ export interface KeyCreateBody {
12
+ is_testing: boolean;
13
+ name?: NullableString;
14
+ }
15
+ export interface KeyCreate {
16
+ api_key: KeyCreateBody;
17
+ }
18
+ export declare class KeysEndpoint {
19
+ private readonly artaClient;
20
+ private readonly defaultEndpoint;
21
+ private readonly path;
22
+ constructor(artaClient: RestClient);
23
+ getById(id: ArtaID, auth?: string): Promise<Key>;
24
+ list(page?: number, pageSize?: number, auth?: string): Promise<Page<Key>>;
25
+ listAll(auth?: string): AsyncGenerator<Key>;
26
+ create(payload: KeyCreateBody, auth?: string): Promise<Key>;
27
+ remove(id: ArtaID, auth?: string): Promise<void>;
28
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeysEndpoint = void 0;
4
+ var endpoint_1 = require("./endpoint");
5
+ var KeysEndpoint = /** @class */ (function () {
6
+ function KeysEndpoint(artaClient) {
7
+ this.artaClient = artaClient;
8
+ this.path = '/api_keys';
9
+ this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient);
10
+ }
11
+ KeysEndpoint.prototype.getById = function (id, auth) {
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) {
20
+ return this.defaultEndpoint.listAll(auth);
21
+ };
22
+ KeysEndpoint.prototype.create = function (payload, auth) {
23
+ return this.defaultEndpoint.create({ api_key: payload }, auth);
24
+ };
25
+ KeysEndpoint.prototype.remove = function (id, auth) {
26
+ return this.defaultEndpoint.remove(id, auth);
27
+ };
28
+ return KeysEndpoint;
29
+ }());
30
+ exports.KeysEndpoint = KeysEndpoint;
@@ -0,0 +1,29 @@
1
+ import { ArtaID } from '../ArtaClient';
2
+ import { RestClient } from '../net/RestClient';
3
+ import { Page } from '../pagination';
4
+ import { DatedInterface, NullableString } from '../utils';
5
+ export interface Log extends DatedInterface {
6
+ api_key_id: number;
7
+ arta_version: string;
8
+ end_at: Date;
9
+ id: ArtaID;
10
+ created_at: Date;
11
+ method: string;
12
+ path: string;
13
+ query_params: string;
14
+ request_body?: NullableString;
15
+ request_id: string;
16
+ response_body?: NullableString;
17
+ start_at: Date;
18
+ status: number;
19
+ updated_at: Date;
20
+ }
21
+ export declare class LogsEndpoint {
22
+ private readonly artaClient;
23
+ private readonly defaultEndpoint;
24
+ private readonly path;
25
+ constructor(artaClient: RestClient);
26
+ getById(id: ArtaID, auth?: string): Promise<Log>;
27
+ list(page?: number, pageSize?: number, auth?: string): Promise<Page<Log>>;
28
+ private enrichFields;
29
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogsEndpoint = void 0;
4
+ var utils_1 = require("../utils");
5
+ var endpoint_1 = require("./endpoint");
6
+ var LogsEndpoint = /** @class */ (function () {
7
+ function LogsEndpoint(artaClient) {
8
+ this.artaClient = artaClient;
9
+ this.path = '/logs';
10
+ this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields);
11
+ }
12
+ LogsEndpoint.prototype.getById = function (id, auth) {
13
+ return this.defaultEndpoint.getById(id, auth);
14
+ };
15
+ LogsEndpoint.prototype.list = function (page, pageSize, auth) {
16
+ if (page === void 0) { page = 1; }
17
+ if (pageSize === void 0) { pageSize = 20; }
18
+ return this.defaultEndpoint.list({ page: page, page_size: pageSize }, auth);
19
+ };
20
+ LogsEndpoint.prototype.enrichFields = function (resource) {
21
+ resource.start_at = (0, utils_1.createDateAsUTC)(resource.start_at);
22
+ resource.end_at = (0, utils_1.createDateAsUTC)(resource.end_at);
23
+ return resource;
24
+ };
25
+ return LogsEndpoint;
26
+ }());
27
+ exports.LogsEndpoint = LogsEndpoint;
@@ -0,0 +1,67 @@
1
+ import { AccessRestriction, APIStatus, ArtaTrackingServiceSubSubType, ArtaTrackingServiceSubType, ArtaTrackingServiceType, AuthTypes, EmailNotificationId, Insurance, ObjectMaterial, ObjectSubType, ObjectType, PackageStatus, PackingSubType, PackingType, ParcelTransportServices, PaymentProcessType, QuoteRequestStatus, QuoteType, Recipients, ShipmentStatus, SupportedCurrency } from '../MetadataTypes';
2
+ import { RestClient } from '../net/RestClient';
3
+ export interface APIVersionMetadata {
4
+ authentication: AuthTypes[];
5
+ description: string;
6
+ id: string;
7
+ status: APIStatus;
8
+ }
9
+ export interface CurrencyMetadata {
10
+ symbol: string;
11
+ id: SupportedCurrency;
12
+ name: string;
13
+ }
14
+ export interface EmailNotificationMetadata {
15
+ description: string;
16
+ optional_recipients: Recipients;
17
+ id: EmailNotificationId;
18
+ }
19
+ export interface BaseMetadata<T> {
20
+ description: string;
21
+ id: T;
22
+ name: string;
23
+ }
24
+ export type InsurancesMetadata = BaseMetadata<Insurance>;
25
+ export type LocationAccessRestrictionMetadata = BaseMetadata<AccessRestriction>;
26
+ export type ObjectMaterialsMetadata = BaseMetadata<ObjectMaterial>;
27
+ export interface ObjectMetadata extends BaseMetadata<ObjectType> {
28
+ subtypes: BaseMetadata<ObjectSubType>[];
29
+ }
30
+ export type PackageStatusesMetadata = BaseMetadata<PackageStatus>;
31
+ export interface PackingMetadata extends BaseMetadata<PackingType> {
32
+ subtypes: BaseMetadata<PackingSubType>[];
33
+ }
34
+ export type ParcelTransportServicesMetadata = BaseMetadata<ParcelTransportServices>;
35
+ export type PaymentProcessTypeMetadata = BaseMetadata<PaymentProcessType>;
36
+ export type QuotesMetadata = BaseMetadata<QuoteType>;
37
+ export type RequestStatusesMetadata = BaseMetadata<QuoteRequestStatus>;
38
+ export interface ServiceSubSubTypeMetadata extends BaseMetadata<ArtaTrackingServiceSubSubType> {
39
+ is_requestable: boolean;
40
+ }
41
+ export interface ServicesSubTypeMetadata extends BaseMetadata<ArtaTrackingServiceSubType> {
42
+ sub_subtypes: ServiceSubSubTypeMetadata[];
43
+ }
44
+ export interface ServicesMetadata extends BaseMetadata<ArtaTrackingServiceType> {
45
+ subtypes: ServicesSubTypeMetadata[];
46
+ }
47
+ export type ShipmentStatusesMetadata = BaseMetadata<ShipmentStatus>;
48
+ export declare class MetadataEndpoint {
49
+ private readonly artaClient;
50
+ private readonly path;
51
+ constructor(artaClient: RestClient);
52
+ apiVersions(auth?: string): Promise<APIVersionMetadata[]>;
53
+ currencies(auth?: string): Promise<CurrencyMetadata[]>;
54
+ emailNotifications(auth?: string): Promise<EmailNotificationMetadata[]>;
55
+ insurances(auth?: string): Promise<InsurancesMetadata[]>;
56
+ locationAccessRestrictions(auth?: string): Promise<LocationAccessRestrictionMetadata[]>;
57
+ objectMaterials(auth?: string): Promise<ObjectMaterialsMetadata[]>;
58
+ objects(auth?: string): Promise<ObjectMetadata[]>;
59
+ packageStatuses(auth?: string): Promise<PackageStatusesMetadata[]>;
60
+ packings(auth?: string): Promise<PackingMetadata[]>;
61
+ parcelTransportServices(auth?: string): Promise<ParcelTransportServicesMetadata[]>;
62
+ paymentProcessTypes(auth?: string): Promise<PaymentProcessTypeMetadata[]>;
63
+ quotes(auth?: string): Promise<QuotesMetadata[]>;
64
+ requestStatuses(auth?: string): Promise<RequestStatusesMetadata[]>;
65
+ services(auth?: string): Promise<ServicesMetadata[]>;
66
+ shipmentStatuses(auth?: string): Promise<ShipmentStatusesMetadata[]>;
67
+ }