@artaio/node-api 0.30.1 → 0.32.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/README.md +3 -1
- package/dist/lib/ArtaClient.d.ts +5 -5
- package/dist/lib/ArtaClient.js +17 -4
- package/dist/lib/MetadataTypes.d.ts +1 -93
- package/dist/lib/MetadataTypes.js +15 -0
- package/dist/lib/arta.d.ts +1 -1
- package/dist/lib/arta.js +2 -2
- package/dist/lib/endpoint/attachment.d.ts +4 -10
- package/dist/lib/endpoint/emailRules.d.ts +6 -12
- package/dist/lib/endpoint/emailSubscriptions.d.ts +6 -12
- package/dist/lib/endpoint/endpoint.d.ts +5 -5
- package/dist/lib/endpoint/endpoint.js +3 -2
- package/dist/lib/endpoint/hostedSessions.d.ts +12 -29
- package/dist/lib/endpoint/invoicePayments.d.ts +7 -14
- package/dist/lib/endpoint/invoicePayments.js +13 -3
- package/dist/lib/endpoint/invoices.d.ts +4 -18
- package/dist/lib/endpoint/keys.d.ts +6 -16
- package/dist/lib/endpoint/logs.d.ts +7 -19
- package/dist/lib/endpoint/logs.js +12 -3
- package/dist/lib/endpoint/metadata.d.ts +3 -3
- package/dist/lib/endpoint/organization.d.ts +2 -14
- package/dist/lib/endpoint/payments.d.ts +7 -11
- package/dist/lib/endpoint/payments.js +13 -3
- package/dist/lib/endpoint/requests.d.ts +17 -41
- package/dist/lib/endpoint/requests.js +17 -5
- package/dist/lib/endpoint/shipments.d.ts +6 -73
- package/dist/lib/endpoint/shipments.js +19 -13
- package/dist/lib/endpoint/trackings.d.ts +3 -19
- package/dist/lib/endpoint/trackings.js +15 -6
- package/dist/lib/endpoint/uploads.d.ts +7 -18
- package/dist/lib/endpoint/webhookDeliveries.d.ts +4 -18
- package/dist/lib/endpoint/webhooks.d.ts +10 -13
- package/dist/lib/index.d.ts +9 -16
- package/dist/lib/net/FetchHttpClient.d.ts +13 -0
- package/dist/lib/net/FetchHttpClient.js +128 -0
- package/dist/lib/net/HttpClient.d.ts +6 -6
- package/dist/lib/net/RestClient.d.ts +3 -3
- package/dist/lib/types.d.ts +750 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/utils.d.ts +7 -2
- package/dist/lib/utils.js +16 -5
- package/dist/package.json +29 -21
- package/dist/schemas/generate.d.ts +1 -0
- package/dist/schemas/generate.js +51 -0
- package/dist/schemas/index.d.ts +3204 -0
- package/dist/schemas/index.js +733 -0
- package/dist/test-integration/index.d.ts +2 -0
- package/dist/test-integration/index.js +7 -0
- package/dist/test-integration/keys.test.d.ts +1 -0
- package/dist/test-integration/keys.test.js +71 -0
- package/dist/test-integration/requests.test.d.ts +1 -0
- package/dist/test-integration/requests.test.js +87 -0
- package/dist/test-integration/shipments.test.d.ts +1 -0
- package/dist/test-integration/shipments.test.js +114 -0
- package/package.json +29 -21
- package/dist/lib/net/NodeHttpClient.d.ts +0 -20
- package/dist/lib/net/NodeHttpClient.js +0 -203
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DatedInterface, NullableString } from '../utils';
|
|
4
|
-
export interface Organization extends DatedInterface {
|
|
5
|
-
api_version: string;
|
|
6
|
-
id: ArtaID;
|
|
7
|
-
name: string;
|
|
8
|
-
billing_terms?: NullableString;
|
|
9
|
-
company_name?: NullableString;
|
|
10
|
-
display_name?: NullableString;
|
|
11
|
-
shortcode?: NullableString;
|
|
12
|
-
status?: NullableString;
|
|
13
|
-
stripe_customer_id?: NullableString;
|
|
14
|
-
}
|
|
1
|
+
import type { RestClient } from '../net/RestClient';
|
|
2
|
+
import type { Organization } from '../types';
|
|
15
3
|
export declare class OrganizationsEndpoint {
|
|
16
4
|
private readonly artaClient;
|
|
17
5
|
private readonly path;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { ArtaID } from '../ArtaClient';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
amount: number;
|
|
9
|
-
amount_currency: SupportedCurrency;
|
|
10
|
-
context: PaymentContext;
|
|
11
|
-
paid_on: Date;
|
|
1
|
+
import type { ArtaID } from '../ArtaClient';
|
|
2
|
+
import type { RestClient } from '../net/RestClient';
|
|
3
|
+
import type { Page } from '../pagination';
|
|
4
|
+
import type { Payment } from '../types';
|
|
5
|
+
export interface UnparsedPayment extends Omit<Payment, 'paid_on' | 'amount'> {
|
|
6
|
+
paid_on: string;
|
|
7
|
+
amount: string;
|
|
12
8
|
}
|
|
13
9
|
export declare class PaymentsEndpoint {
|
|
14
10
|
private readonly artaClient;
|
|
@@ -1,6 +1,18 @@
|
|
|
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
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.PaymentsEndpoint = void 0;
|
|
15
|
+
var utils_1 = require("../utils");
|
|
4
16
|
var endpoint_1 = require("./endpoint");
|
|
5
17
|
var PaymentsEndpoint = /** @class */ (function () {
|
|
6
18
|
function PaymentsEndpoint(artaClient) {
|
|
@@ -17,9 +29,7 @@ var PaymentsEndpoint = /** @class */ (function () {
|
|
|
17
29
|
return this.defaultEndpoint.list({ page: page, page_size: pageSize }, auth);
|
|
18
30
|
};
|
|
19
31
|
PaymentsEndpoint.prototype.enrichFields = function (resource) {
|
|
20
|
-
resource
|
|
21
|
-
resource.paid_on = new Date(resource.paid_on);
|
|
22
|
-
return resource;
|
|
32
|
+
return __assign(__assign({}, resource), { amount: Number(resource.amount), paid_on: (0, utils_1.createDateAsUTC)(resource.paid_on) });
|
|
23
33
|
};
|
|
24
34
|
return PaymentsEndpoint;
|
|
25
35
|
}());
|
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
missing: string[];
|
|
13
|
-
ready: boolean;
|
|
14
|
-
};
|
|
15
|
-
destination: ArtaLocation;
|
|
16
|
-
disqualifications: Disqualification[];
|
|
17
|
-
insurance: Nullable<Insurance>;
|
|
18
|
-
internal_reference: NullableString;
|
|
19
|
-
log_request_id: string;
|
|
20
|
-
hosted_session_id: Nullable<number>;
|
|
21
|
-
object_count: number;
|
|
22
|
-
objects: ArtaObject[];
|
|
23
|
-
origin: ArtaLocation;
|
|
24
|
-
payment_process: PaymentProcessType;
|
|
25
|
-
preferred_quote_types?: Nullable<QuoteType[]>;
|
|
26
|
-
public_reference?: NullableString;
|
|
27
|
-
quote_types: QuoteType[];
|
|
28
|
-
shipping_notes?: NullableString;
|
|
29
|
-
shortcode: string;
|
|
30
|
-
quotes: Quote[];
|
|
31
|
-
status: QuoteRequestStatus;
|
|
32
|
-
updateContacts: (contacts: UpdateRequestsContactsBody, auth?: string) => Promise<QuoteRequest>;
|
|
33
|
-
requireCustomQuotes: (customQuote: CustomQuotePayload, auth?: string) => Promise<QuoteRequest>;
|
|
34
|
-
cancel: (auth?: string) => Promise<QuoteRequest>;
|
|
35
|
-
}
|
|
1
|
+
import type { AdditionalService, ArtaLocation, ArtaObject, Contact, Insurance, QuoteType, SupportedCurrency } from '../types';
|
|
2
|
+
import type { RestClient } from '../net/RestClient';
|
|
3
|
+
import type { Page } from '../pagination';
|
|
4
|
+
import type { RequestsSearch } from '../search';
|
|
5
|
+
import type { QuoteRequest, QuoteRequestListItem } from '../types';
|
|
6
|
+
import type { Nullable, NullableString } from '../utils';
|
|
7
|
+
export type EnrichRequest<T> = T & {
|
|
8
|
+
updateContacts: (contacts: UpdateRequestsContactsBody, auth?: string) => Promise<T>;
|
|
9
|
+
requireCustomQuotes: (customQuote: CustomQuotePayload, auth?: string) => Promise<T>;
|
|
10
|
+
cancel: (auth?: string) => Promise<T>;
|
|
11
|
+
};
|
|
36
12
|
export interface QuoteRequestCreateBody {
|
|
37
13
|
additional_services?: Nullable<AdditionalService[]>;
|
|
38
14
|
currency?: Nullable<SupportedCurrency>;
|
|
@@ -61,10 +37,10 @@ export declare class QuoteRequestsEndpoint {
|
|
|
61
37
|
private readonly path;
|
|
62
38
|
constructor(artaClient: RestClient);
|
|
63
39
|
private enrichFields;
|
|
64
|
-
getById(id:
|
|
65
|
-
list(search?: RequestsSearch, page?: number, pageSize?: number, auth?: string): Promise<Page<
|
|
66
|
-
create(payload: QuoteRequestCreateBody, auth?: string): Promise<QuoteRequest
|
|
67
|
-
updateContacts(id:
|
|
68
|
-
requireCustomQuotes(id:
|
|
69
|
-
cancel(id:
|
|
40
|
+
getById(id: string, auth?: string): Promise<EnrichRequest<QuoteRequest>>;
|
|
41
|
+
list(search?: RequestsSearch, page?: number, pageSize?: number, auth?: string): Promise<Page<EnrichRequest<QuoteRequestListItem>>>;
|
|
42
|
+
create(payload: QuoteRequestCreateBody, auth?: string): Promise<EnrichRequest<QuoteRequest>>;
|
|
43
|
+
updateContacts(id: string, contacts: UpdateRequestsContactsBody, auth?: string): Promise<EnrichRequest<QuoteRequest>>;
|
|
44
|
+
requireCustomQuotes(id: string, customQuote: CustomQuotePayload, auth?: string): Promise<QuoteRequest>;
|
|
45
|
+
cancel(id: string, auth?: string): Promise<QuoteRequest>;
|
|
70
46
|
}
|
|
@@ -1,4 +1,15 @@
|
|
|
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
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -47,16 +58,17 @@ var QuoteRequestsEndpoint = /** @class */ (function () {
|
|
|
47
58
|
}
|
|
48
59
|
QuoteRequestsEndpoint.prototype.enrichFields = function (resource) {
|
|
49
60
|
var _this = this;
|
|
50
|
-
resource
|
|
61
|
+
if (Object.prototype.hasOwnProperty.call(resource, 'quotes')) {
|
|
51
62
|
resource.quotes.forEach(function (q) {
|
|
52
63
|
q.total = Number(q.total);
|
|
53
64
|
q.included_services.forEach(utils_1.parseService);
|
|
54
65
|
q.optional_services.forEach(utils_1.parseService);
|
|
55
66
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return resource;
|
|
67
|
+
}
|
|
68
|
+
var updateContacts = function (contacts, auth) { return _this.updateContacts(resource.id, contacts, auth); };
|
|
69
|
+
var requireCustomQuotes = function (customQuote, auth) { return _this.requireCustomQuotes(resource.id, customQuote, auth); };
|
|
70
|
+
var cancel = function (auth) { return _this.cancel(resource.id, auth); };
|
|
71
|
+
return __assign(__assign({}, resource), { updateContacts: updateContacts, requireCustomQuotes: requireCustomQuotes, cancel: cancel });
|
|
60
72
|
};
|
|
61
73
|
QuoteRequestsEndpoint.prototype.getById = function (id, auth) {
|
|
62
74
|
return this.defaultEndpoint.getById(id, auth);
|
|
@@ -1,76 +1,9 @@
|
|
|
1
|
-
import { ArtaID } from '../ArtaClient';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
export interface Package {
|
|
8
|
-
depth: number;
|
|
9
|
-
eta: string;
|
|
10
|
-
handle_with_care: boolean;
|
|
11
|
-
height: number;
|
|
12
|
-
id: number;
|
|
13
|
-
is_sufficiently_packed: boolean;
|
|
14
|
-
objects: ArtaObject[];
|
|
15
|
-
packing_materials: PackingSubType[];
|
|
16
|
-
status: Nullable<PackageStatus>;
|
|
17
|
-
unit_of_measurement?: NullableString;
|
|
18
|
-
weight: number;
|
|
19
|
-
weight_unit: string;
|
|
20
|
-
width: number;
|
|
21
|
-
}
|
|
22
|
-
export type ShipmentExceptionStatus = 'in_progress' | 'new' | 'resolved';
|
|
23
|
-
export interface ShipmentException extends DatedInterface {
|
|
24
|
-
exception_type_label: NullableString;
|
|
25
|
-
id: ArtaID;
|
|
26
|
-
package_id: Nullable<number>;
|
|
27
|
-
resolution: NullableString;
|
|
28
|
-
status: ShipmentExceptionStatus;
|
|
29
|
-
type: ShipmentExceptionTypeId;
|
|
30
|
-
}
|
|
31
|
-
export interface ShipmentSchedule {
|
|
32
|
-
delivery_end: Nullable<Date>;
|
|
33
|
-
delivery_start: Nullable<Date>;
|
|
34
|
-
delivery_window_modifier: string;
|
|
35
|
-
pickup_end: Nullable<Date>;
|
|
36
|
-
pickup_start: Nullable<Date>;
|
|
37
|
-
pickup_window_modifier: string;
|
|
38
|
-
}
|
|
39
|
-
export interface ShipmentTracking {
|
|
40
|
-
carrier_name: string;
|
|
41
|
-
label_url?: NullableString;
|
|
42
|
-
package_id: number;
|
|
43
|
-
tracking_number: string;
|
|
44
|
-
url: string;
|
|
45
|
-
}
|
|
46
|
-
export interface Shipment extends DatedInterface {
|
|
47
|
-
id: ArtaID;
|
|
48
|
-
destination: ArtaLocation;
|
|
49
|
-
eei_form_status?: Nullable<EEIFormStatus>;
|
|
50
|
-
emissions?: Nullable<number>;
|
|
51
|
-
emissions_unit?: NullableString;
|
|
52
|
-
exceptions?: Nullable<ShipmentException[]>;
|
|
53
|
-
hosted_session_id?: Nullable<number>;
|
|
54
|
-
insurance_policy?: Nullable<InsurancePolicy>;
|
|
55
|
-
internal_reference?: NullableString;
|
|
56
|
-
log_request_id?: NullableString;
|
|
57
|
-
object_count: number;
|
|
58
|
-
origin: ArtaLocation;
|
|
59
|
-
package_count: number;
|
|
60
|
-
packages?: Nullable<Package[]>;
|
|
61
|
-
payment_process?: Nullable<PaymentProcessType>;
|
|
62
|
-
public_reference?: NullableString;
|
|
63
|
-
quote_type: QuoteType;
|
|
64
|
-
schedule?: Nullable<ShipmentSchedule>;
|
|
65
|
-
services?: Nullable<ArtaService[]>;
|
|
66
|
-
shipping_notes?: NullableString;
|
|
67
|
-
shortcode: string;
|
|
68
|
-
status: ShipmentStatus;
|
|
69
|
-
total: number;
|
|
70
|
-
total_currency: SupportedCurrency;
|
|
71
|
-
url?: NullableString;
|
|
72
|
-
tracking?: Nullable<ShipmentTracking[]>;
|
|
73
|
-
}
|
|
1
|
+
import type { ArtaID } from '../ArtaClient';
|
|
2
|
+
import type { RestClient } from '../net/RestClient';
|
|
3
|
+
import type { Page } from '../pagination';
|
|
4
|
+
import type { ShipmentsSearch } from '../search';
|
|
5
|
+
import type { NullableString } from '../utils';
|
|
6
|
+
import type { Shipment } from '../types';
|
|
74
7
|
export interface ShipmentCreateBody {
|
|
75
8
|
internal_reference?: NullableString;
|
|
76
9
|
public_reference?: NullableString;
|
|
@@ -9,27 +9,33 @@ var ShipmentsEndpoint = /** @class */ (function () {
|
|
|
9
9
|
this.path = '/shipments';
|
|
10
10
|
this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields.bind(this));
|
|
11
11
|
}
|
|
12
|
-
ShipmentsEndpoint.prototype.enrichFields = function (
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
12
|
+
ShipmentsEndpoint.prototype.enrichFields = function (s) {
|
|
13
|
+
s.total = Number(s.total);
|
|
14
|
+
if (s.emissions) {
|
|
15
|
+
s.emissions = Number(s.emissions);
|
|
16
16
|
}
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
if (s.schedule) {
|
|
18
|
+
s.schedule.delivery_end = (0, utils_1.createDateAsUTC)(s.schedule.delivery_end);
|
|
19
|
+
s.schedule.delivery_start = (0, utils_1.createDateAsUTC)(s.schedule.delivery_start);
|
|
20
|
+
s.schedule.pickup_end = (0, utils_1.createDateAsUTC)(s.schedule.pickup_end);
|
|
21
|
+
s.schedule.pickup_start = (0, utils_1.createDateAsUTC)(s.schedule.pickup_start);
|
|
22
22
|
}
|
|
23
|
-
if (
|
|
24
|
-
|
|
23
|
+
if (s.packages) {
|
|
24
|
+
s.packages.forEach(function (p) {
|
|
25
25
|
p.depth = Number(p.depth);
|
|
26
26
|
p.height = Number(p.height);
|
|
27
27
|
p.weight = Number(p.weight);
|
|
28
28
|
p.width = Number(p.width);
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if (s.exceptions) {
|
|
32
|
+
s.exceptions.forEach(function (e) {
|
|
33
|
+
e.created_at = (0, utils_1.createDateAsUTC)(e.created_at);
|
|
34
|
+
e.updated_at = (0, utils_1.createDateAsUTC)(e.updated_at);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
s.services && s.services.forEach(utils_1.parseService);
|
|
38
|
+
return s;
|
|
33
39
|
};
|
|
34
40
|
ShipmentsEndpoint.prototype.getById = function (id, auth) {
|
|
35
41
|
return this.defaultEndpoint.getById(id, auth);
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import { ArtaID } from '../ArtaClient';
|
|
2
|
-
import { RestClient } from '../net/RestClient';
|
|
3
|
-
|
|
4
|
-
code: string;
|
|
5
|
-
name: string;
|
|
6
|
-
phone_number: string;
|
|
7
|
-
url: string;
|
|
8
|
-
}
|
|
9
|
-
export interface TrackingEvent {
|
|
10
|
-
date: Date;
|
|
11
|
-
location: string;
|
|
12
|
-
summary: string;
|
|
13
|
-
}
|
|
14
|
-
export interface Tracking {
|
|
15
|
-
carrier: Carrier;
|
|
16
|
-
events: TrackingEvent[];
|
|
17
|
-
status: string;
|
|
18
|
-
tracking_number: string;
|
|
19
|
-
}
|
|
1
|
+
import type { ArtaID } from '../ArtaClient';
|
|
2
|
+
import type { RestClient } from '../net/RestClient';
|
|
3
|
+
import type { Tracking } from '../types';
|
|
20
4
|
export declare class TrackingsEndpoint {
|
|
21
5
|
private readonly artaClient;
|
|
22
6
|
private readonly path;
|
|
@@ -1,4 +1,15 @@
|
|
|
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
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -45,16 +56,14 @@ var TrackingsEndpoint = /** @class */ (function () {
|
|
|
45
56
|
}
|
|
46
57
|
TrackingsEndpoint.prototype.getById = function (id, auth) {
|
|
47
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
var
|
|
59
|
+
var unparsedTracking, parsedEvents;
|
|
49
60
|
return __generator(this, function (_a) {
|
|
50
61
|
switch (_a.label) {
|
|
51
62
|
case 0: return [4 /*yield*/, this.artaClient.get("".concat(this.path, "/").concat(id), auth)];
|
|
52
63
|
case 1:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
return [2 /*return*/, tracking];
|
|
64
|
+
unparsedTracking = _a.sent();
|
|
65
|
+
parsedEvents = unparsedTracking.events.map(function (event) { return (__assign(__assign({}, event), { date: (0, utils_1.createDateAsUTC)(event.date) })); });
|
|
66
|
+
return [2 /*return*/, __assign(__assign({}, unparsedTracking), { events: parsedEvents })];
|
|
58
67
|
}
|
|
59
68
|
});
|
|
60
69
|
});
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import { ArtaID } from '../ArtaClient';
|
|
2
|
-
import { RestClient } from '../net/RestClient';
|
|
3
|
-
import { Page } from '../pagination';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export interface Upload extends DatedInterface {
|
|
7
|
-
id: ArtaID;
|
|
8
|
-
document_type: DocumentType;
|
|
9
|
-
document_type_label?: NullableString;
|
|
10
|
-
download_url: NullableString;
|
|
11
|
-
file_name: string;
|
|
12
|
-
mime_type: MimeType;
|
|
13
|
-
size: number;
|
|
14
|
-
status: string;
|
|
15
|
-
presigned_url: string;
|
|
16
|
-
}
|
|
1
|
+
import type { ArtaID } from '../ArtaClient';
|
|
2
|
+
import type { RestClient } from '../net/RestClient';
|
|
3
|
+
import type { Page } from '../pagination';
|
|
4
|
+
import type { ArtaDocumentType, ArtaMimeType, Upload } from '../MetadataTypes';
|
|
5
|
+
import type { NullableString } from '../utils';
|
|
17
6
|
export interface UploadCreateBody {
|
|
18
|
-
document_type:
|
|
7
|
+
document_type: ArtaDocumentType;
|
|
19
8
|
document_type_label?: NullableString;
|
|
20
9
|
file_name: boolean;
|
|
21
10
|
size: string;
|
|
22
|
-
mime_type:
|
|
11
|
+
mime_type: ArtaMimeType;
|
|
23
12
|
}
|
|
24
13
|
export interface UploadCreate {
|
|
25
14
|
upload: UploadCreateBody;
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import { ArtaID } from '../ArtaClient';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DatedInterface, NullableString } from '../utils';
|
|
6
|
-
export interface WebhookDelivery extends DatedInterface {
|
|
7
|
-
id: ArtaID;
|
|
8
|
-
resource_id: number;
|
|
9
|
-
resource_type: WebhookResourceType;
|
|
10
|
-
response_status_code: number;
|
|
11
|
-
status: WebhookDeliveryStatus;
|
|
12
|
-
type: WebhookDeliveryType;
|
|
13
|
-
webhook_id: number;
|
|
14
|
-
webhook_url: string;
|
|
15
|
-
next_retry?: NullableString;
|
|
16
|
-
request_body?: NullableString;
|
|
17
|
-
response_body?: NullableString;
|
|
18
|
-
}
|
|
1
|
+
import type { ArtaID } from '../ArtaClient';
|
|
2
|
+
import type { RestClient } from '../net/RestClient';
|
|
3
|
+
import type { Page } from '../pagination';
|
|
4
|
+
import type { WebhookDelivery } from '../types';
|
|
19
5
|
export declare class WebhookDeliveriesEndpoint {
|
|
20
6
|
private readonly artaClient;
|
|
21
7
|
private readonly defaultEndpoint;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { ArtaID } from '../ArtaClient';
|
|
2
|
-
import { RestClient } from '../net/RestClient';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export interface
|
|
6
|
-
id: ArtaID;
|
|
7
|
-
name: string;
|
|
8
|
-
url: string;
|
|
1
|
+
import type { ArtaID } from '../ArtaClient';
|
|
2
|
+
import type { RestClient } from '../net/RestClient';
|
|
3
|
+
import type { Page } from '../pagination';
|
|
4
|
+
import type { Webhook } from '../types';
|
|
5
|
+
export interface ExtendedWebhook extends Webhook {
|
|
9
6
|
ping: (auth?: string) => Promise<void>;
|
|
10
7
|
getSecret: (auth?: string) => Promise<string>;
|
|
11
8
|
resetSecret: (auth?: string) => Promise<string>;
|
|
@@ -23,11 +20,11 @@ export declare class WebhooksEndpoint {
|
|
|
23
20
|
private readonly path;
|
|
24
21
|
constructor(artaClient: RestClient);
|
|
25
22
|
private withFunctionCalls;
|
|
26
|
-
getById(id: ArtaID, auth?: string): Promise<
|
|
27
|
-
list(page?: number, pageSize?: number, auth?: string): Promise<Page<
|
|
28
|
-
listAll(auth?: string): AsyncGenerator<
|
|
29
|
-
create(payload: WebhookCreateBody, auth?: string): Promise<
|
|
30
|
-
update(id: ArtaID, payload: Partial<WebhookCreateBody> | Partial<
|
|
23
|
+
getById(id: ArtaID, auth?: string): Promise<ExtendedWebhook>;
|
|
24
|
+
list(page?: number, pageSize?: number, auth?: string): Promise<Page<ExtendedWebhook>>;
|
|
25
|
+
listAll(auth?: string): AsyncGenerator<ExtendedWebhook>;
|
|
26
|
+
create(payload: WebhookCreateBody, auth?: string): Promise<ExtendedWebhook>;
|
|
27
|
+
update(id: ArtaID, payload: Partial<WebhookCreateBody> | Partial<ExtendedWebhook>, auth?: string): Promise<ExtendedWebhook>;
|
|
31
28
|
remove(id: ArtaID, auth?: string): Promise<void>;
|
|
32
29
|
ping(id: ArtaID, auth?: string): Promise<void>;
|
|
33
30
|
getSecret(id: ArtaID, auth?: string): Promise<string>;
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
export { Arta } from './arta';
|
|
2
2
|
export { Logger, LoggerVerbosity } from './logging';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export { Invoice } from './endpoint/invoices';
|
|
9
|
-
export { Key, KeyCreateBody } from './endpoint/keys';
|
|
10
|
-
export { Log } from './endpoint/logs';
|
|
3
|
+
export { AttachmentCreateBodyRequest, AttachmentCreateBodyShipment, AttachmentCreateBody, } from './endpoint/attachment';
|
|
4
|
+
export { EmailRuleCreateBody } from './endpoint/emailRules';
|
|
5
|
+
export { EmailSubscriptionCreateBody, } from './endpoint/emailSubscriptions';
|
|
6
|
+
export { HostedSessionCreateBody, } from './endpoint/hostedSessions';
|
|
7
|
+
export { KeyCreateBody } from './endpoint/keys';
|
|
11
8
|
export * from './MetadataTypes';
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export { Webhook, WebhookCreate } from './endpoint/webhooks';
|
|
17
|
-
export { Tracking, TrackingEvent, Carrier } from './endpoint/trackings';
|
|
18
|
-
export { QuoteRequest, QuoteRequestCreateBody, UpdateRequestsContactsBody, CustomQuotePayload, } from './endpoint/requests';
|
|
19
|
-
export { Package, ShipmentSchedule, ShipmentTracking, Shipment, ShipmentCreateBody, } from './endpoint/shipments';
|
|
9
|
+
export { UploadCreateBody } from './endpoint/uploads';
|
|
10
|
+
export { ExtendedWebhook as Webhook, WebhookCreate } from './endpoint/webhooks';
|
|
11
|
+
export { QuoteRequestCreateBody, UpdateRequestsContactsBody, CustomQuotePayload, } from './endpoint/requests';
|
|
12
|
+
export { ShipmentCreateBody, } from './endpoint/shipments';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HttpClient, HttpClientHeaders, HttpClientResponse, HttpRequestParameters } from './HttpClient';
|
|
2
|
+
export declare class FetchHttpClientResponse implements HttpClientResponse {
|
|
3
|
+
private readonly res;
|
|
4
|
+
statusCode?: number;
|
|
5
|
+
headers: HttpClientHeaders;
|
|
6
|
+
constructor(res: Response);
|
|
7
|
+
json<T>(): Promise<T>;
|
|
8
|
+
}
|
|
9
|
+
export declare class FetchHttpClient implements HttpClient {
|
|
10
|
+
private readonly logger;
|
|
11
|
+
constructor();
|
|
12
|
+
request(host: string, params?: Partial<HttpRequestParameters>): Promise<HttpClientResponse>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.FetchHttpClient = exports.FetchHttpClientResponse = void 0;
|
|
51
|
+
var logging_1 = require("../logging");
|
|
52
|
+
var FetchHttpClientResponse = /** @class */ (function () {
|
|
53
|
+
function FetchHttpClientResponse(res) {
|
|
54
|
+
var _this = this;
|
|
55
|
+
this.res = res;
|
|
56
|
+
this.headers = {};
|
|
57
|
+
this.statusCode = res.status;
|
|
58
|
+
res.headers.forEach(function (value, key) {
|
|
59
|
+
_this.headers[key] = value;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
FetchHttpClientResponse.prototype.json = function () {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0: return [4 /*yield*/, this.res.json()];
|
|
67
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
return FetchHttpClientResponse;
|
|
73
|
+
}());
|
|
74
|
+
exports.FetchHttpClientResponse = FetchHttpClientResponse;
|
|
75
|
+
function initParams(params) {
|
|
76
|
+
var defaultParams = {
|
|
77
|
+
protocol: 'https',
|
|
78
|
+
port: 443,
|
|
79
|
+
path: '/',
|
|
80
|
+
method: 'GET',
|
|
81
|
+
headers: {},
|
|
82
|
+
requestData: null,
|
|
83
|
+
timeout: 30000,
|
|
84
|
+
};
|
|
85
|
+
return __assign(__assign({}, defaultParams), params);
|
|
86
|
+
}
|
|
87
|
+
var FetchHttpClient = /** @class */ (function () {
|
|
88
|
+
function FetchHttpClient() {
|
|
89
|
+
this.logger = (0, logging_1.getLogger)();
|
|
90
|
+
}
|
|
91
|
+
FetchHttpClient.prototype.request = function (host, params) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
var _a, protocol, port, path, method, timeout, headers, requestData, url, fetchUrl, setTimeoutId, rejectTimeout, response;
|
|
94
|
+
return __generator(this, function (_b) {
|
|
95
|
+
switch (_b.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
_a = initParams(params), protocol = _a.protocol, port = _a.port, path = _a.path, method = _a.method, timeout = _a.timeout, headers = _a.headers, requestData = _a.requestData;
|
|
98
|
+
url = "".concat(protocol, "://").concat(host, ":").concat(port).concat(path);
|
|
99
|
+
this.logger.debug("[".concat(method, "] ").concat(url));
|
|
100
|
+
fetchUrl = fetch(url, {
|
|
101
|
+
method: method,
|
|
102
|
+
headers: headers,
|
|
103
|
+
body: requestData,
|
|
104
|
+
});
|
|
105
|
+
setTimeoutId = null;
|
|
106
|
+
rejectTimeout = new Promise(function (_, reject) {
|
|
107
|
+
setTimeoutId = setTimeout(function () {
|
|
108
|
+
reject(new Error("Request timed out to ".concat(host, ":").concat(port)));
|
|
109
|
+
}, timeout);
|
|
110
|
+
});
|
|
111
|
+
_b.label = 1;
|
|
112
|
+
case 1:
|
|
113
|
+
_b.trys.push([1, , 3, 4]);
|
|
114
|
+
return [4 /*yield*/, Promise.race([fetchUrl, rejectTimeout])];
|
|
115
|
+
case 2:
|
|
116
|
+
response = _b.sent();
|
|
117
|
+
return [2 /*return*/, new FetchHttpClientResponse(response)];
|
|
118
|
+
case 3:
|
|
119
|
+
setTimeoutId != null && clearTimeout(setTimeoutId);
|
|
120
|
+
return [7 /*endfinally*/];
|
|
121
|
+
case 4: return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
return FetchHttpClient;
|
|
127
|
+
}());
|
|
128
|
+
exports.FetchHttpClient = FetchHttpClient;
|