@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.
- package/LICENSE.md +21 -0
- package/README.md +48 -0
- package/dist/lib/ArtaClient.d.ts +21 -0
- package/dist/lib/ArtaClient.js +155 -0
- package/dist/lib/MetadataTypes.d.ts +96 -0
- package/dist/lib/MetadataTypes.js +2 -0
- package/dist/lib/arta.d.ts +45 -0
- package/dist/lib/arta.js +57 -0
- package/dist/lib/endpoint/attachment.d.ts +32 -0
- package/dist/lib/endpoint/attachment.js +27 -0
- package/dist/lib/endpoint/emailRules.d.ts +30 -0
- package/dist/lib/endpoint/emailRules.js +33 -0
- package/dist/lib/endpoint/emailSubscriptions.d.ts +32 -0
- package/dist/lib/endpoint/emailSubscriptions.js +33 -0
- package/dist/lib/endpoint/endpoint.d.ts +26 -0
- package/dist/lib/endpoint/endpoint.js +168 -0
- package/dist/lib/endpoint/hostedSessions.d.ts +53 -0
- package/dist/lib/endpoint/hostedSessions.js +81 -0
- package/dist/lib/endpoint/invoicePayments.d.ts +24 -0
- package/dist/lib/endpoint/invoicePayments.js +26 -0
- package/dist/lib/endpoint/invoices.d.ts +27 -0
- package/dist/lib/endpoint/invoices.js +27 -0
- package/dist/lib/endpoint/keys.d.ts +28 -0
- package/dist/lib/endpoint/keys.js +30 -0
- package/dist/lib/endpoint/logs.d.ts +29 -0
- package/dist/lib/endpoint/logs.js +27 -0
- package/dist/lib/endpoint/metadata.d.ts +67 -0
- package/dist/lib/endpoint/metadata.js +56 -0
- package/dist/lib/endpoint/organization.d.ts +31 -0
- package/dist/lib/endpoint/organization.js +84 -0
- package/dist/lib/endpoint/payments.d.ts +21 -0
- package/dist/lib/endpoint/payments.js +26 -0
- package/dist/lib/endpoint/requests.d.ts +80 -0
- package/dist/lib/endpoint/requests.js +113 -0
- package/dist/lib/endpoint/shipments.d.ts +80 -0
- package/dist/lib/endpoint/shipments.js +44 -0
- package/dist/lib/endpoint/trackings.d.ts +25 -0
- package/dist/lib/endpoint/trackings.js +64 -0
- package/dist/lib/endpoint/uploads.d.ts +36 -0
- package/dist/lib/endpoint/uploads.js +27 -0
- package/dist/lib/endpoint/webhookDeliveries.d.ts +26 -0
- package/dist/lib/endpoint/webhookDeliveries.js +21 -0
- package/dist/lib/endpoint/webhooks.d.ts +35 -0
- package/dist/lib/endpoint/webhooks.js +124 -0
- package/dist/lib/error.d.ts +8 -0
- package/dist/lib/error.js +54 -0
- package/dist/lib/index.d.ts +19 -0
- package/dist/lib/index.js +20 -0
- package/dist/lib/logging.d.ts +17 -0
- package/dist/lib/logging.js +79 -0
- package/dist/lib/net/HttpClient.d.ts +19 -0
- package/dist/lib/net/HttpClient.js +2 -0
- package/dist/lib/net/NodeHttpClient.d.ts +20 -0
- package/dist/lib/net/NodeHttpClient.js +203 -0
- package/dist/lib/net/RestClient.d.ts +6 -0
- package/dist/lib/net/RestClient.js +2 -0
- package/dist/lib/pagination.d.ts +9 -0
- package/dist/lib/pagination.js +2 -0
- package/dist/lib/queryParams.d.ts +7 -0
- package/dist/lib/queryParams.js +23 -0
- package/dist/lib/search.d.ts +3 -0
- package/dist/lib/search.js +2 -0
- package/dist/lib/utils.d.ts +9 -0
- package/dist/lib/utils.js +24 -0
- package/dist/package.json +49 -0
- package/package.json +58 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetadataEndpoint = void 0;
|
|
4
|
+
var MetadataEndpoint = /** @class */ (function () {
|
|
5
|
+
function MetadataEndpoint(artaClient) {
|
|
6
|
+
this.artaClient = artaClient;
|
|
7
|
+
this.path = '/metadata';
|
|
8
|
+
}
|
|
9
|
+
MetadataEndpoint.prototype.apiVersions = function (auth) {
|
|
10
|
+
return this.artaClient.get("".concat(this.path, "/api_versions"), auth);
|
|
11
|
+
};
|
|
12
|
+
MetadataEndpoint.prototype.currencies = function (auth) {
|
|
13
|
+
return this.artaClient.get("".concat(this.path, "/currencies"), auth);
|
|
14
|
+
};
|
|
15
|
+
MetadataEndpoint.prototype.emailNotifications = function (auth) {
|
|
16
|
+
return this.artaClient.get("".concat(this.path, "/email_notifications"), auth);
|
|
17
|
+
};
|
|
18
|
+
MetadataEndpoint.prototype.insurances = function (auth) {
|
|
19
|
+
return this.artaClient.get("".concat(this.path, "/insurances"), auth);
|
|
20
|
+
};
|
|
21
|
+
MetadataEndpoint.prototype.locationAccessRestrictions = function (auth) {
|
|
22
|
+
return this.artaClient.get("".concat(this.path, "/location_access_restrictions"), auth);
|
|
23
|
+
};
|
|
24
|
+
MetadataEndpoint.prototype.objectMaterials = function (auth) {
|
|
25
|
+
return this.artaClient.get("".concat(this.path, "/object_materials"), auth);
|
|
26
|
+
};
|
|
27
|
+
MetadataEndpoint.prototype.objects = function (auth) {
|
|
28
|
+
return this.artaClient.get("".concat(this.path, "/objects"), auth);
|
|
29
|
+
};
|
|
30
|
+
MetadataEndpoint.prototype.packageStatuses = function (auth) {
|
|
31
|
+
return this.artaClient.get("".concat(this.path, "/package_statuses"), auth);
|
|
32
|
+
};
|
|
33
|
+
MetadataEndpoint.prototype.packings = function (auth) {
|
|
34
|
+
return this.artaClient.get("".concat(this.path, "/packings"), auth);
|
|
35
|
+
};
|
|
36
|
+
MetadataEndpoint.prototype.parcelTransportServices = function (auth) {
|
|
37
|
+
return this.artaClient.get("".concat(this.path, "/parcel_transport_services"), auth);
|
|
38
|
+
};
|
|
39
|
+
MetadataEndpoint.prototype.paymentProcessTypes = function (auth) {
|
|
40
|
+
return this.artaClient.get("".concat(this.path, "/payment_process_types"), auth);
|
|
41
|
+
};
|
|
42
|
+
MetadataEndpoint.prototype.quotes = function (auth) {
|
|
43
|
+
return this.artaClient.get("".concat(this.path, "/quotes"), auth);
|
|
44
|
+
};
|
|
45
|
+
MetadataEndpoint.prototype.requestStatuses = function (auth) {
|
|
46
|
+
return this.artaClient.get("".concat(this.path, "/request_statuses"), auth);
|
|
47
|
+
};
|
|
48
|
+
MetadataEndpoint.prototype.services = function (auth) {
|
|
49
|
+
return this.artaClient.get("".concat(this.path, "/services"), auth);
|
|
50
|
+
};
|
|
51
|
+
MetadataEndpoint.prototype.shipmentStatuses = function (auth) {
|
|
52
|
+
return this.artaClient.get("".concat(this.path, "/shipment_statuses"), auth);
|
|
53
|
+
};
|
|
54
|
+
return MetadataEndpoint;
|
|
55
|
+
}());
|
|
56
|
+
exports.MetadataEndpoint = MetadataEndpoint;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ArtaID } from '../ArtaClient';
|
|
2
|
+
import { RestClient } from '../net/RestClient';
|
|
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
|
+
}
|
|
15
|
+
export declare class OrganizationsEndpoint {
|
|
16
|
+
private readonly artaClient;
|
|
17
|
+
private readonly path;
|
|
18
|
+
constructor(artaClient: RestClient);
|
|
19
|
+
/** Retrieves the Organization associated with the API Key
|
|
20
|
+
* @param [auth] An optional API key.
|
|
21
|
+
* @returns The Organization
|
|
22
|
+
* @throws ArtaSDKError thrown if some problem happened while communicating with the API.
|
|
23
|
+
*/
|
|
24
|
+
get(auth?: string): Promise<Organization>;
|
|
25
|
+
/** Updates the Organization associated with the API Key
|
|
26
|
+
* @param [auth] An optional API key.
|
|
27
|
+
* @returns The Organization
|
|
28
|
+
* @throws ArtaSDKError thrown if some problem happened while communicating with the API.
|
|
29
|
+
*/
|
|
30
|
+
update(organization: Partial<Organization>, auth?: string): Promise<Organization>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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.OrganizationsEndpoint = void 0;
|
|
40
|
+
var utils_1 = require("../utils");
|
|
41
|
+
var OrganizationsEndpoint = /** @class */ (function () {
|
|
42
|
+
function OrganizationsEndpoint(artaClient) {
|
|
43
|
+
this.artaClient = artaClient;
|
|
44
|
+
this.path = '/organization';
|
|
45
|
+
}
|
|
46
|
+
/** Retrieves the Organization associated with the API Key
|
|
47
|
+
* @param [auth] An optional API key.
|
|
48
|
+
* @returns The Organization
|
|
49
|
+
* @throws ArtaSDKError thrown if some problem happened while communicating with the API.
|
|
50
|
+
*/
|
|
51
|
+
OrganizationsEndpoint.prototype.get = function (auth) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
var artaResponse;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0: return [4 /*yield*/, this.artaClient.get(this.path, auth)];
|
|
57
|
+
case 1:
|
|
58
|
+
artaResponse = _a.sent();
|
|
59
|
+
return [2 /*return*/, (0, utils_1.convertDatesToUtc)(artaResponse)];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
/** Updates the Organization associated with the API Key
|
|
65
|
+
* @param [auth] An optional API key.
|
|
66
|
+
* @returns The Organization
|
|
67
|
+
* @throws ArtaSDKError thrown if some problem happened while communicating with the API.
|
|
68
|
+
*/
|
|
69
|
+
OrganizationsEndpoint.prototype.update = function (organization, auth) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
+
var artaResponse;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0: return [4 /*yield*/, this.artaClient.patch(this.path, { organization: organization }, auth)];
|
|
75
|
+
case 1:
|
|
76
|
+
artaResponse = _a.sent();
|
|
77
|
+
return [2 /*return*/, (0, utils_1.convertDatesToUtc)(artaResponse)];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
return OrganizationsEndpoint;
|
|
83
|
+
}());
|
|
84
|
+
exports.OrganizationsEndpoint = OrganizationsEndpoint;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ArtaID } from '../ArtaClient';
|
|
2
|
+
import { PaymentContext, SupportedCurrency } from '../MetadataTypes';
|
|
3
|
+
import { RestClient } from '../net/RestClient';
|
|
4
|
+
import { Page } from '../pagination';
|
|
5
|
+
import { DatedInterface } from '../utils';
|
|
6
|
+
export interface Payment extends DatedInterface {
|
|
7
|
+
id: ArtaID;
|
|
8
|
+
amount: number;
|
|
9
|
+
amount_currency: SupportedCurrency;
|
|
10
|
+
context: PaymentContext;
|
|
11
|
+
paid_on: Date;
|
|
12
|
+
}
|
|
13
|
+
export declare class PaymentsEndpoint {
|
|
14
|
+
private readonly artaClient;
|
|
15
|
+
private readonly defaultEndpoint;
|
|
16
|
+
private readonly path;
|
|
17
|
+
constructor(artaClient: RestClient);
|
|
18
|
+
getById(id: ArtaID, auth?: string): Promise<Payment>;
|
|
19
|
+
list(page?: number, pageSize?: number, auth?: string): Promise<Page<Payment>>;
|
|
20
|
+
private enrichFields;
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentsEndpoint = void 0;
|
|
4
|
+
var endpoint_1 = require("./endpoint");
|
|
5
|
+
var PaymentsEndpoint = /** @class */ (function () {
|
|
6
|
+
function PaymentsEndpoint(artaClient) {
|
|
7
|
+
this.artaClient = artaClient;
|
|
8
|
+
this.path = '/payments';
|
|
9
|
+
this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields);
|
|
10
|
+
}
|
|
11
|
+
PaymentsEndpoint.prototype.getById = function (id, auth) {
|
|
12
|
+
return this.defaultEndpoint.getById(id, auth);
|
|
13
|
+
};
|
|
14
|
+
PaymentsEndpoint.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
|
+
PaymentsEndpoint.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 PaymentsEndpoint;
|
|
25
|
+
}());
|
|
26
|
+
exports.PaymentsEndpoint = PaymentsEndpoint;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ArtaID } from '../ArtaClient';
|
|
2
|
+
import { AdditionalService, ArtaLocation, ArtaObject, ArtaService, Contact, Disqualification, Insurance, InsurancePolicy, PaymentProcessType, QuoteRequestStatus, QuoteType, SupportedCurrency } from '../MetadataTypes';
|
|
3
|
+
import { RestClient } from '../net/RestClient';
|
|
4
|
+
import { Page } from '../pagination';
|
|
5
|
+
import { RequestsSearch } from '../search';
|
|
6
|
+
import { DatedInterface, Nullable, NullableString } from '../utils';
|
|
7
|
+
export interface Quote {
|
|
8
|
+
id: number;
|
|
9
|
+
included_services: ArtaService[];
|
|
10
|
+
included_insurance_policy?: Nullable<InsurancePolicy>;
|
|
11
|
+
optional_services: ArtaService[];
|
|
12
|
+
quote_type: QuoteType;
|
|
13
|
+
status: string;
|
|
14
|
+
total: number;
|
|
15
|
+
total_currency: SupportedCurrency;
|
|
16
|
+
}
|
|
17
|
+
export interface QuoteRequest extends DatedInterface {
|
|
18
|
+
id: ArtaID;
|
|
19
|
+
currency: SupportedCurrency;
|
|
20
|
+
additional_services: AdditionalService[];
|
|
21
|
+
bookable: {
|
|
22
|
+
missing: string[];
|
|
23
|
+
ready: boolean;
|
|
24
|
+
};
|
|
25
|
+
destination: ArtaLocation;
|
|
26
|
+
disqualifications: Disqualification[];
|
|
27
|
+
insurance: Nullable<Insurance>;
|
|
28
|
+
internal_reference: NullableString;
|
|
29
|
+
log_request_id: string;
|
|
30
|
+
hosted_session_id: Nullable<number>;
|
|
31
|
+
object_count: number;
|
|
32
|
+
objects: ArtaObject[];
|
|
33
|
+
origin: ArtaLocation;
|
|
34
|
+
payment_process: PaymentProcessType;
|
|
35
|
+
preferred_quote_types?: Nullable<QuoteType[]>;
|
|
36
|
+
public_reference?: NullableString;
|
|
37
|
+
quote_types: QuoteType[];
|
|
38
|
+
shipping_notes?: NullableString;
|
|
39
|
+
shortcode: string;
|
|
40
|
+
quotes: Quote[];
|
|
41
|
+
status: QuoteRequestStatus;
|
|
42
|
+
updateContacts: (contacts: UpdateRequestsContactsBody, auth?: string) => Promise<QuoteRequest>;
|
|
43
|
+
requireCustomQuotes: (customQuote: CustomQuotePayload, auth?: string) => Promise<QuoteRequest>;
|
|
44
|
+
cancel: (auth?: string) => Promise<QuoteRequest>;
|
|
45
|
+
}
|
|
46
|
+
export interface QuoteRequestCreateBody {
|
|
47
|
+
additional_services?: Nullable<AdditionalService[]>;
|
|
48
|
+
currency?: Nullable<SupportedCurrency>;
|
|
49
|
+
destination: ArtaLocation;
|
|
50
|
+
insurance?: Nullable<Insurance>;
|
|
51
|
+
internal_reference?: NullableString;
|
|
52
|
+
objects: ArtaObject[];
|
|
53
|
+
origin: ArtaLocation;
|
|
54
|
+
preferred_quote_types?: Nullable<QuoteType[]>;
|
|
55
|
+
public_reference?: NullableString;
|
|
56
|
+
shipping_notes?: NullableString;
|
|
57
|
+
}
|
|
58
|
+
export interface QuoteRequestCreate {
|
|
59
|
+
request: QuoteRequestCreateBody;
|
|
60
|
+
}
|
|
61
|
+
export interface UpdateRequestsContactsBody {
|
|
62
|
+
origin?: Nullable<Contact[]>;
|
|
63
|
+
destination?: Nullable<Contact[]>;
|
|
64
|
+
}
|
|
65
|
+
export interface CustomQuotePayload {
|
|
66
|
+
note: string;
|
|
67
|
+
}
|
|
68
|
+
export declare class QuoteRequestsEndpoint {
|
|
69
|
+
private readonly artaClient;
|
|
70
|
+
private readonly defaultEndpoint;
|
|
71
|
+
private readonly path;
|
|
72
|
+
constructor(artaClient: RestClient);
|
|
73
|
+
private enrichFields;
|
|
74
|
+
getById(id: ArtaID, auth?: string): Promise<QuoteRequest>;
|
|
75
|
+
list(search?: RequestsSearch, page?: number, pageSize?: number, auth?: string): Promise<Page<QuoteRequest>>;
|
|
76
|
+
create(payload: QuoteRequestCreateBody, auth?: string): Promise<QuoteRequest>;
|
|
77
|
+
updateContacts(id: ArtaID, contacts: UpdateRequestsContactsBody, auth?: string): Promise<QuoteRequest>;
|
|
78
|
+
requireCustomQuotes(id: ArtaID, customQuote: CustomQuotePayload, auth?: string): Promise<QuoteRequest>;
|
|
79
|
+
cancel(id: ArtaID, auth?: string): Promise<QuoteRequest>;
|
|
80
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
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.QuoteRequestsEndpoint = void 0;
|
|
40
|
+
var utils_1 = require("../utils");
|
|
41
|
+
var endpoint_1 = require("./endpoint");
|
|
42
|
+
var QuoteRequestsEndpoint = /** @class */ (function () {
|
|
43
|
+
function QuoteRequestsEndpoint(artaClient) {
|
|
44
|
+
this.artaClient = artaClient;
|
|
45
|
+
this.path = '/requests';
|
|
46
|
+
this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields.bind(this));
|
|
47
|
+
}
|
|
48
|
+
QuoteRequestsEndpoint.prototype.enrichFields = function (resource) {
|
|
49
|
+
var _this = this;
|
|
50
|
+
resource.quotes &&
|
|
51
|
+
resource.quotes.forEach(function (q) {
|
|
52
|
+
q.total = Number(q.total);
|
|
53
|
+
q.included_services.forEach(utils_1.parseService);
|
|
54
|
+
q.optional_services.forEach(utils_1.parseService);
|
|
55
|
+
});
|
|
56
|
+
resource.updateContacts = function (contacts, auth) { return _this.updateContacts(resource.id, contacts, auth); };
|
|
57
|
+
resource.requireCustomQuotes = function (customQuote, auth) { return _this.requireCustomQuotes(resource.id, customQuote, auth); };
|
|
58
|
+
resource.cancel = function (auth) { return _this.cancel(resource.id, auth); };
|
|
59
|
+
return resource;
|
|
60
|
+
};
|
|
61
|
+
QuoteRequestsEndpoint.prototype.getById = function (id, auth) {
|
|
62
|
+
return this.defaultEndpoint.getById(id, auth);
|
|
63
|
+
};
|
|
64
|
+
QuoteRequestsEndpoint.prototype.list = function (search, page, pageSize, auth) {
|
|
65
|
+
if (page === void 0) { page = 1; }
|
|
66
|
+
if (pageSize === void 0) { pageSize = 20; }
|
|
67
|
+
return this.defaultEndpoint.list({ page: page, page_size: pageSize, search: search }, auth);
|
|
68
|
+
};
|
|
69
|
+
QuoteRequestsEndpoint.prototype.create = function (payload, auth) {
|
|
70
|
+
return this.defaultEndpoint.create({ request: payload }, auth);
|
|
71
|
+
};
|
|
72
|
+
QuoteRequestsEndpoint.prototype.updateContacts = function (id, contacts, auth) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var rawReq;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0: return [4 /*yield*/, this.artaClient.patch("".concat(this.path, "/").concat(id, "/contacts"), contacts, auth)];
|
|
78
|
+
case 1:
|
|
79
|
+
rawReq = _a.sent();
|
|
80
|
+
return [2 /*return*/, this.enrichFields(rawReq)];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
QuoteRequestsEndpoint.prototype.requireCustomQuotes = function (id, customQuote, auth) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var rawReq;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0: return [4 /*yield*/, this.artaClient.patch("".concat(this.path, "/").concat(id, "/custom"), customQuote, auth)];
|
|
91
|
+
case 1:
|
|
92
|
+
rawReq = _a.sent();
|
|
93
|
+
return [2 /*return*/, this.enrichFields(rawReq)];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
QuoteRequestsEndpoint.prototype.cancel = function (id, auth) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
+
var rawReq;
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
103
|
+
case 0: return [4 /*yield*/, this.artaClient.patch("".concat(this.path, "/").concat(id, "/cancel"), undefined, auth)];
|
|
104
|
+
case 1:
|
|
105
|
+
rawReq = _a.sent();
|
|
106
|
+
return [2 /*return*/, this.enrichFields(rawReq)];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return QuoteRequestsEndpoint;
|
|
112
|
+
}());
|
|
113
|
+
exports.QuoteRequestsEndpoint = QuoteRequestsEndpoint;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ArtaID } from '../ArtaClient';
|
|
2
|
+
import { ArtaLocation, ArtaObject, ArtaService, EEIFormStatus, InsurancePolicy, PackageStatus, PackingSubType, PaymentProcessType, QuoteType, ShipmentStatus, SupportedCurrency } from '../MetadataTypes';
|
|
3
|
+
import { RestClient } from '../net/RestClient';
|
|
4
|
+
import { Page } from '../pagination';
|
|
5
|
+
import { ShipmentsSearch } from '../search';
|
|
6
|
+
import { DatedInterface, Nullable, NullableString } from '../utils';
|
|
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 interface ShipmentSchedule {
|
|
23
|
+
delivery_end: Nullable<Date>;
|
|
24
|
+
delivery_start: Nullable<Date>;
|
|
25
|
+
delivery_window_modifier: string;
|
|
26
|
+
pickup_end: Nullable<Date>;
|
|
27
|
+
pickup_start: Nullable<Date>;
|
|
28
|
+
pickup_window_modifier: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ShipmentTracking {
|
|
31
|
+
carrier_name: string;
|
|
32
|
+
label_url?: NullableString;
|
|
33
|
+
package_id: number;
|
|
34
|
+
tracking_number: string;
|
|
35
|
+
url: string;
|
|
36
|
+
}
|
|
37
|
+
export interface Shipment extends DatedInterface {
|
|
38
|
+
id: ArtaID;
|
|
39
|
+
destination: ArtaLocation;
|
|
40
|
+
eei_form_status?: Nullable<EEIFormStatus>;
|
|
41
|
+
hosted_session_id?: Nullable<number>;
|
|
42
|
+
insurance_policy?: Nullable<InsurancePolicy>;
|
|
43
|
+
internal_reference?: NullableString;
|
|
44
|
+
log_request_id?: NullableString;
|
|
45
|
+
object_count: number;
|
|
46
|
+
origin: ArtaLocation;
|
|
47
|
+
package_count: number;
|
|
48
|
+
packages?: Nullable<Package[]>;
|
|
49
|
+
payment_process?: Nullable<PaymentProcessType>;
|
|
50
|
+
public_reference?: NullableString;
|
|
51
|
+
quote_type: QuoteType;
|
|
52
|
+
schedule?: Nullable<ShipmentSchedule>;
|
|
53
|
+
services?: Nullable<ArtaService[]>;
|
|
54
|
+
shipping_notes?: NullableString;
|
|
55
|
+
shortcode: string;
|
|
56
|
+
status: ShipmentStatus;
|
|
57
|
+
total: number;
|
|
58
|
+
total_currency: SupportedCurrency;
|
|
59
|
+
url?: NullableString;
|
|
60
|
+
tracking?: Nullable<ShipmentTracking[]>;
|
|
61
|
+
}
|
|
62
|
+
export interface ShipmentCreateBody {
|
|
63
|
+
internal_reference?: NullableString;
|
|
64
|
+
public_reference?: NullableString;
|
|
65
|
+
quote_id: number;
|
|
66
|
+
shipping_notes?: NullableString;
|
|
67
|
+
}
|
|
68
|
+
export interface ShipmentCreate {
|
|
69
|
+
shipment: ShipmentCreateBody;
|
|
70
|
+
}
|
|
71
|
+
export declare class ShipmentsEndpoint {
|
|
72
|
+
private readonly artaClient;
|
|
73
|
+
private readonly defaultEndpoint;
|
|
74
|
+
private readonly path;
|
|
75
|
+
constructor(artaClient: RestClient);
|
|
76
|
+
private enrichFields;
|
|
77
|
+
getById(id: ArtaID, auth?: string): Promise<Shipment>;
|
|
78
|
+
list(search?: ShipmentsSearch, page?: number, pageSize?: number, auth?: string): Promise<Page<Shipment>>;
|
|
79
|
+
create(payload: ShipmentCreateBody, auth?: string): Promise<Shipment>;
|
|
80
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShipmentsEndpoint = void 0;
|
|
4
|
+
var utils_1 = require("../utils");
|
|
5
|
+
var endpoint_1 = require("./endpoint");
|
|
6
|
+
var ShipmentsEndpoint = /** @class */ (function () {
|
|
7
|
+
function ShipmentsEndpoint(artaClient) {
|
|
8
|
+
this.artaClient = artaClient;
|
|
9
|
+
this.path = '/shipments';
|
|
10
|
+
this.defaultEndpoint = new endpoint_1.DefaultEndpoint(this.path, this.artaClient, this.enrichFields.bind(this));
|
|
11
|
+
}
|
|
12
|
+
ShipmentsEndpoint.prototype.enrichFields = function (r) {
|
|
13
|
+
r.total = Number(r.total);
|
|
14
|
+
if (r.schedule) {
|
|
15
|
+
r.schedule.delivery_end = new Date(r.schedule.delivery_end);
|
|
16
|
+
r.schedule.delivery_start = new Date(r.schedule.delivery_start);
|
|
17
|
+
r.schedule.pickup_end = new Date(r.schedule.pickup_end);
|
|
18
|
+
r.schedule.pickup_start = new Date(r.schedule.pickup_start);
|
|
19
|
+
}
|
|
20
|
+
if (r.packages) {
|
|
21
|
+
r.packages.forEach(function (p) {
|
|
22
|
+
p.depth = Number(p.depth);
|
|
23
|
+
p.height = Number(p.height);
|
|
24
|
+
p.weight = Number(p.weight);
|
|
25
|
+
p.width = Number(p.width);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
r.services && r.services.forEach(utils_1.parseService);
|
|
29
|
+
return r;
|
|
30
|
+
};
|
|
31
|
+
ShipmentsEndpoint.prototype.getById = function (id, auth) {
|
|
32
|
+
return this.defaultEndpoint.getById(id, auth);
|
|
33
|
+
};
|
|
34
|
+
ShipmentsEndpoint.prototype.list = function (search, page, pageSize, auth) {
|
|
35
|
+
if (page === void 0) { page = 1; }
|
|
36
|
+
if (pageSize === void 0) { pageSize = 20; }
|
|
37
|
+
return this.defaultEndpoint.list({ page: page, page_size: pageSize, search: search }, auth);
|
|
38
|
+
};
|
|
39
|
+
ShipmentsEndpoint.prototype.create = function (payload, auth) {
|
|
40
|
+
return this.defaultEndpoint.create({ shipment: payload }, auth);
|
|
41
|
+
};
|
|
42
|
+
return ShipmentsEndpoint;
|
|
43
|
+
}());
|
|
44
|
+
exports.ShipmentsEndpoint = ShipmentsEndpoint;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ArtaID } from '../ArtaClient';
|
|
2
|
+
import { RestClient } from '../net/RestClient';
|
|
3
|
+
export interface Carrier {
|
|
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
|
+
}
|
|
20
|
+
export declare class TrackingsEndpoint {
|
|
21
|
+
private readonly artaClient;
|
|
22
|
+
private readonly path;
|
|
23
|
+
constructor(artaClient: RestClient);
|
|
24
|
+
getById(id: ArtaID, auth?: string): Promise<Tracking>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.TrackingsEndpoint = void 0;
|
|
40
|
+
var utils_1 = require("../utils");
|
|
41
|
+
var TrackingsEndpoint = /** @class */ (function () {
|
|
42
|
+
function TrackingsEndpoint(artaClient) {
|
|
43
|
+
this.artaClient = artaClient;
|
|
44
|
+
this.path = '/trackings';
|
|
45
|
+
}
|
|
46
|
+
TrackingsEndpoint.prototype.getById = function (id, auth) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var tracking;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0: return [4 /*yield*/, this.artaClient.get("".concat(this.path, "/").concat(id), auth)];
|
|
52
|
+
case 1:
|
|
53
|
+
tracking = _a.sent();
|
|
54
|
+
tracking.events.forEach(function (e) {
|
|
55
|
+
e.date = (0, utils_1.createDateAsUTC)(e.date);
|
|
56
|
+
});
|
|
57
|
+
return [2 /*return*/, tracking];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return TrackingsEndpoint;
|
|
63
|
+
}());
|
|
64
|
+
exports.TrackingsEndpoint = TrackingsEndpoint;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ArtaID } from '../ArtaClient';
|
|
2
|
+
import { RestClient } from '../net/RestClient';
|
|
3
|
+
import { Page } from '../pagination';
|
|
4
|
+
import { DocumentType, MimeType } from '../MetadataTypes';
|
|
5
|
+
import { DatedInterface, NullableString } from '../utils';
|
|
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
|
+
}
|
|
17
|
+
export interface UploadCreateBody {
|
|
18
|
+
document_type: DocumentType;
|
|
19
|
+
document_type_label?: NullableString;
|
|
20
|
+
file_name: boolean;
|
|
21
|
+
size: string;
|
|
22
|
+
mime_type: MimeType;
|
|
23
|
+
}
|
|
24
|
+
export interface UploadCreate {
|
|
25
|
+
upload: UploadCreateBody;
|
|
26
|
+
}
|
|
27
|
+
export declare class UploadsEndpoint {
|
|
28
|
+
private readonly artaClient;
|
|
29
|
+
private readonly defaultEndpoint;
|
|
30
|
+
private readonly path;
|
|
31
|
+
constructor(artaClient: RestClient);
|
|
32
|
+
getById(id: ArtaID, auth?: string): Promise<Upload>;
|
|
33
|
+
list(page?: number, pageSize?: number, auth?: string): Promise<Page<Upload>>;
|
|
34
|
+
create(payload: UploadCreateBody, auth?: string): Promise<Upload>;
|
|
35
|
+
remove(id: ArtaID, auth?: string): Promise<void>;
|
|
36
|
+
}
|