@artaio/node-api 0.32.3 → 1.0.1

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.
@@ -1,2 +0,0 @@
1
- import { Arta } from '../lib/index';
2
- export declare const arta: Arta;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.arta = void 0;
4
- var index_1 = require("../lib/index");
5
- exports.arta = new index_1.Arta(process.env.ARTA_API_KEY, {
6
- host: 'api.qa.arta.io',
7
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,71 +0,0 @@
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
- var _1 = require(".");
40
- var schemas_1 = require("../schemas");
41
- describe('tests keys Arta endpoint', function () {
42
- it('should be able CRUD api keys', function () { return __awaiter(void 0, void 0, void 0, function () {
43
- var keys, parsedKeys, key, parsedKey, key2, parsedKey2;
44
- return __generator(this, function (_a) {
45
- switch (_a.label) {
46
- case 0: return [4 /*yield*/, _1.arta.keys.list()];
47
- case 1:
48
- keys = _a.sent();
49
- parsedKeys = (0, schemas_1.createPaginatedResponseSchema)(schemas_1.keySchema).parse(keys);
50
- expect(parsedKeys.items.length).toBeGreaterThan(0);
51
- return [4 /*yield*/, _1.arta.keys.create({
52
- name: 'test key',
53
- is_testing: true
54
- })];
55
- case 2:
56
- key = _a.sent();
57
- parsedKey = schemas_1.keySchema.parse(key);
58
- expect(parsedKey.name).toBe('test key');
59
- return [4 /*yield*/, _1.arta.keys.getById(parsedKey.id)];
60
- case 3:
61
- key2 = _a.sent();
62
- parsedKey2 = schemas_1.keySchema.parse(key2);
63
- expect(parsedKey2.name).toBe('test key');
64
- return [4 /*yield*/, _1.arta.keys.remove(parsedKey.id)];
65
- case 4:
66
- _a.sent();
67
- return [2 /*return*/];
68
- }
69
- });
70
- }); });
71
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,87 +0,0 @@
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
- var _1 = require(".");
40
- var schemas_1 = require("../schemas");
41
- describe('tests requests Arta endpoint', function () {
42
- it('should be able to CRUD quote requests', function () { return __awaiter(void 0, void 0, void 0, function () {
43
- var request, parsedRequest, requests, parsedRequests, request2, parsedRequest2;
44
- return __generator(this, function (_a) {
45
- switch (_a.label) {
46
- case 0: return [4 /*yield*/, _1.arta.requests.create({
47
- destination: {
48
- postal_code: '90024',
49
- country: 'US',
50
- },
51
- objects: [
52
- {
53
- subtype: 'painting_unframed',
54
- width: 36,
55
- height: 24,
56
- weight: 1,
57
- value: 100,
58
- value_currency: 'USD',
59
- },
60
- ],
61
- origin: {
62
- country: 'US',
63
- postal_code: '11249',
64
- },
65
- })];
66
- case 1:
67
- request = _a.sent();
68
- parsedRequest = schemas_1.requestSchema.parse(request);
69
- expect(parsedRequest.status).toBe('quoted');
70
- return [4 /*yield*/, _1.arta.requests.list()];
71
- case 2:
72
- requests = _a.sent();
73
- parsedRequests = (0, schemas_1.createPaginatedResponseSchema)(schemas_1.requestListItemSchema).parse(requests);
74
- expect(parsedRequests.items.length).toBeGreaterThanOrEqual(1);
75
- return [4 /*yield*/, _1.arta.requests.cancel(parsedRequest.id)];
76
- case 3:
77
- _a.sent();
78
- return [4 /*yield*/, _1.arta.requests.getById(parsedRequest.id)];
79
- case 4:
80
- request2 = _a.sent();
81
- parsedRequest2 = schemas_1.requestSchema.parse(request2);
82
- expect(parsedRequest2.status).toBe('cancelled');
83
- return [2 /*return*/];
84
- }
85
- });
86
- }); });
87
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,114 +0,0 @@
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
- var _1 = require(".");
40
- var schemas_1 = require("../schemas");
41
- describe.only('tests shipments Arta endpoint', function () {
42
- var request;
43
- beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
44
- return __generator(this, function (_a) {
45
- switch (_a.label) {
46
- case 0: return [4 /*yield*/, _1.arta.requests.create({
47
- destination: {
48
- postal_code: '10019',
49
- country: 'US',
50
- address_line_1: '11 W 53rd St',
51
- contacts: [
52
- {
53
- 'name': 'John Doe',
54
- 'email_address': 'johndoe@test.test',
55
- 'phone_number': '1234567890',
56
- }
57
- ]
58
- },
59
- objects: [
60
- {
61
- subtype: 'painting_unframed',
62
- width: 36,
63
- height: 24,
64
- weight: 1,
65
- value: 100,
66
- value_currency: 'USD',
67
- },
68
- ],
69
- origin: {
70
- country: 'US',
71
- postal_code: '11249',
72
- address_line_1: '87 Richardson St',
73
- city: 'brooklyn',
74
- contacts: [
75
- {
76
- 'name': 'John Doe',
77
- 'email_address': 'johndoe@test.test',
78
- 'phone_number': '1234567890',
79
- }
80
- ]
81
- },
82
- })];
83
- case 1:
84
- request = _a.sent();
85
- return [2 /*return*/];
86
- }
87
- });
88
- }); });
89
- it('should be able to CRUD shipments', function () { return __awaiter(void 0, void 0, void 0, function () {
90
- var shipment, parsedShipment, shipments, parsedShipmentList, shipmentItem, parsedShipmentItem;
91
- return __generator(this, function (_a) {
92
- switch (_a.label) {
93
- case 0: return [4 /*yield*/, _1.arta.shipments.create({
94
- quote_id: request.quotes[0].id,
95
- })];
96
- case 1:
97
- shipment = _a.sent();
98
- parsedShipment = schemas_1.shipmentSchema.parse(shipment);
99
- expect(parsedShipment.status).toBe('pending');
100
- return [4 /*yield*/, _1.arta.shipments.list()];
101
- case 2:
102
- shipments = _a.sent();
103
- parsedShipmentList = (0, schemas_1.createPaginatedResponseSchema)(schemas_1.shipmentSchema).parse(shipments);
104
- expect(parsedShipmentList.items.length).toBeGreaterThanOrEqual(1);
105
- return [4 /*yield*/, _1.arta.shipments.getById(parsedShipment.id)];
106
- case 3:
107
- shipmentItem = _a.sent();
108
- parsedShipmentItem = schemas_1.shipmentSchema.parse(shipmentItem);
109
- expect(parsedShipmentItem.id).toBe(parsedShipment.id);
110
- return [2 /*return*/];
111
- }
112
- });
113
- }); });
114
- });