@chift/chift-nodejs 1.0.17 → 1.0.18

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 (114) hide show
  1. package/package.json +5 -2
  2. package/.eslintignore +0 -1
  3. package/.eslintrc.json +0 -25
  4. package/.github/workflows/ci.yml +0 -75
  5. package/.husky/pre-commit +0 -4
  6. package/.prettierignore +0 -1
  7. package/.prettierrc.json +0 -7
  8. package/CHANGELOG.md +0 -108
  9. package/dist/src/helpers/openapi.d.ts +0 -3
  10. package/dist/src/helpers/openapi.js +0 -18
  11. package/dist/src/helpers/settings.d.ts +0 -4
  12. package/dist/src/helpers/settings.js +0 -5
  13. package/dist/src/index.d.ts +0 -1
  14. package/dist/src/modules/accounting.d.ts +0 -68
  15. package/dist/src/modules/accounting.js +0 -326
  16. package/dist/src/modules/api.d.ts +0 -18351
  17. package/dist/src/modules/api.js +0 -36
  18. package/dist/src/modules/consumer.d.ts +0 -3622
  19. package/dist/src/modules/consumer.js +0 -142
  20. package/dist/src/modules/consumers.d.ts +0 -18237
  21. package/dist/src/modules/consumers.js +0 -51
  22. package/dist/src/modules/custom.d.ts +0 -8
  23. package/dist/src/modules/custom.js +0 -36
  24. package/dist/src/modules/datastores.d.ts +0 -18
  25. package/dist/src/modules/datastores.js +0 -23
  26. package/dist/src/modules/ecommerce.d.ts +0 -24
  27. package/dist/src/modules/ecommerce.js +0 -97
  28. package/dist/src/modules/flow.d.ts +0 -15
  29. package/dist/src/modules/flow.js +0 -156
  30. package/dist/src/modules/integrations.d.ts +0 -23
  31. package/dist/src/modules/integrations.js +0 -23
  32. package/dist/src/modules/internalApi.d.ts +0 -24
  33. package/dist/src/modules/internalApi.js +0 -175
  34. package/dist/src/modules/invoicing.d.ts +0 -20
  35. package/dist/src/modules/invoicing.js +0 -90
  36. package/dist/src/modules/payment.d.ts +0 -14
  37. package/dist/src/modules/payment.js +0 -41
  38. package/dist/src/modules/pms.d.ts +0 -15
  39. package/dist/src/modules/pms.js +0 -47
  40. package/dist/src/modules/pos.d.ts +0 -26
  41. package/dist/src/modules/pos.js +0 -101
  42. package/dist/src/modules/sync.d.ts +0 -14654
  43. package/dist/src/modules/sync.js +0 -73
  44. package/dist/src/modules/syncs.d.ts +0 -11
  45. package/dist/src/modules/syncs.js +0 -39
  46. package/dist/src/modules/webhooks.d.ts +0 -58
  47. package/dist/src/modules/webhooks.js +0 -53
  48. package/dist/src/types/api.d.ts +0 -29
  49. package/dist/src/types/api.js +0 -2
  50. package/dist/src/types/consumers.d.ts +0 -8
  51. package/dist/src/types/consumers.js +0 -2
  52. package/dist/src/types/public-api/mappings.d.ts +0 -21
  53. package/dist/src/types/public-api/mappings.js +0 -2
  54. package/dist/src/types/sync.d.ts +0 -37
  55. package/dist/src/types/sync.js +0 -2
  56. package/dist/test/modules/accounting.test.d.ts +0 -1
  57. package/dist/test/modules/accounting.test.js +0 -590
  58. package/dist/test/modules/consumer.test.d.ts +0 -1
  59. package/dist/test/modules/consumer.test.js +0 -89
  60. package/dist/test/modules/consumers.test.d.ts +0 -1
  61. package/dist/test/modules/consumers.test.js +0 -109
  62. package/dist/test/modules/ecommerce.test.d.ts +0 -1
  63. package/dist/test/modules/ecommerce.test.js +0 -224
  64. package/dist/test/modules/integrations.test.d.ts +0 -1
  65. package/dist/test/modules/integrations.test.js +0 -54
  66. package/dist/test/modules/invoicing.test.d.ts +0 -1
  67. package/dist/test/modules/invoicing.test.js +0 -115
  68. package/dist/test/modules/payment.test.d.ts +0 -1
  69. package/dist/test/modules/payment.test.js +0 -88
  70. package/dist/test/modules/pms.test.d.ts +0 -1
  71. package/dist/test/modules/pms.test.js +0 -90
  72. package/dist/test/modules/pos.test.d.ts +0 -1
  73. package/dist/test/modules/pos.test.js +0 -179
  74. package/dist/test/modules/sync.test.d.ts +0 -1
  75. package/dist/test/modules/sync.test.js +0 -93
  76. package/dist/test/modules/syncs.test.d.ts +0 -1
  77. package/dist/test/modules/syncs.test.js +0 -53
  78. package/dist/test/modules/webhooks.test.d.ts +0 -1
  79. package/dist/test/modules/webhooks.test.js +0 -120
  80. package/jest.config.ts +0 -195
  81. package/src/helpers/openapi.ts +0 -22
  82. package/src/helpers/settings.ts +0 -3
  83. package/src/index.ts +0 -1
  84. package/src/modules/accounting.ts +0 -510
  85. package/src/modules/api.ts +0 -35
  86. package/src/modules/consumer.ts +0 -216
  87. package/src/modules/consumers.ts +0 -82
  88. package/src/modules/custom.ts +0 -36
  89. package/src/modules/datastores.ts +0 -19
  90. package/src/modules/ecommerce.ts +0 -129
  91. package/src/modules/flow.ts +0 -168
  92. package/src/modules/integrations.ts +0 -24
  93. package/src/modules/internalApi.ts +0 -182
  94. package/src/modules/invoicing.ts +0 -118
  95. package/src/modules/payment.ts +0 -59
  96. package/src/modules/pms.ts +0 -67
  97. package/src/modules/pos.ts +0 -144
  98. package/src/modules/sync.ts +0 -77
  99. package/src/modules/syncs.ts +0 -59
  100. package/src/modules/webhooks.ts +0 -86
  101. package/test/data/accounting_invoice.pdf +0 -0
  102. package/test/modules/accounting.test.ts +0 -647
  103. package/test/modules/consumer.test.ts +0 -68
  104. package/test/modules/consumers.test.ts +0 -85
  105. package/test/modules/ecommerce.test.ts +0 -213
  106. package/test/modules/integrations.test.ts +0 -22
  107. package/test/modules/invoicing.test.ts +0 -98
  108. package/test/modules/payment.test.ts +0 -65
  109. package/test/modules/pms.test.ts +0 -69
  110. package/test/modules/pos.test.ts +0 -164
  111. package/test/modules/sync.test.ts +0 -74
  112. package/test/modules/syncs.test.ts +0 -23
  113. package/test/modules/webhooks.test.ts +0 -92
  114. package/tsconfig.json +0 -107
@@ -1,89 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- const globals_1 = require("@jest/globals");
36
- const chift = __importStar(require("../../src/index"));
37
- const dotenv = __importStar(require("dotenv"));
38
- dotenv.config();
39
- const client = new chift.API({
40
- baseUrl: process.env.CHIFT_BACKBONE_API,
41
- clientId: process.env.CHIFT_TESTING_CLIENTID,
42
- clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
43
- accountId: process.env.CHIFT_TESTING_ACCOUNTID,
44
- });
45
- const consumerName = 'test consumer 2';
46
- const email = 'support@chift.eu';
47
- const redirect_url = 'https://chift.eu';
48
- let syncConsumer;
49
- let consumer;
50
- let connection;
51
- (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
52
- consumer = yield client.Consumers.createConsumer({
53
- email,
54
- redirect_url,
55
- name: consumerName,
56
- });
57
- syncConsumer = yield client.Consumers.getConsumerById(process.env.CHIFT_SYNC_CONSUMER_ID);
58
- }));
59
- (0, globals_1.test)('createConnection', () => __awaiter(void 0, void 0, void 0, function* () {
60
- const body = { integrationid: 1000, name: 'odoo test sdk' };
61
- const result = yield consumer.createConnection(body);
62
- (0, globals_1.expect)(result).toHaveProperty('url', globals_1.expect.any(String));
63
- }));
64
- let connections;
65
- (0, globals_1.test)('getConnections', () => __awaiter(void 0, void 0, void 0, function* () {
66
- connections = yield syncConsumer.getConnections();
67
- (0, globals_1.expect)(connections).toBeInstanceOf(Array);
68
- }));
69
- globals_1.test.skip('updateConnection', () => __awaiter(void 0, void 0, void 0, function* () {
70
- var _a;
71
- const updatedConnection = yield syncConsumer.updateConnection((_a = connections[0]) === null || _a === void 0 ? void 0 : _a.connectionid, {
72
- name: 'updated connection name',
73
- });
74
- (0, globals_1.expect)(updatedConnection).toHaveProperty('name', 'updated connection name');
75
- }));
76
- globals_1.test.skip('deleteConnection', () => __awaiter(void 0, void 0, void 0, function* () {
77
- yield consumer.deleteConnection(connection.connectionId);
78
- }));
79
- (0, globals_1.test)('getSyncUrl', () => __awaiter(void 0, void 0, void 0, function* () {
80
- const result = yield syncConsumer.getSyncUrl({
81
- syncid: process.env.CHIFT_TEST_SYNC_ID,
82
- integrationids: [],
83
- });
84
- (0, globals_1.expect)(result).toHaveProperty('url', globals_1.expect.any(String));
85
- }));
86
- (0, globals_1.test)('getSyncData', () => __awaiter(void 0, void 0, void 0, function* () {
87
- const syncData = yield syncConsumer.getSyncData(process.env.CHIFT_TEST_SYNC_ID);
88
- (0, globals_1.expect)(syncData).toBeTruthy();
89
- }));
@@ -1 +0,0 @@
1
- export {};
@@ -1,109 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- const globals_1 = require("@jest/globals");
39
- const chift = __importStar(require("../../src/index"));
40
- const axios_1 = __importDefault(require("axios"));
41
- const dotenv = __importStar(require("dotenv"));
42
- dotenv.config();
43
- const client = new chift.API({
44
- baseUrl: process.env.CHIFT_BACKBONE_API,
45
- clientId: process.env.CHIFT_TESTING_CLIENTID,
46
- clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
47
- accountId: process.env.CHIFT_TESTING_ACCOUNTID,
48
- });
49
- const consumerName = 'test consumer';
50
- const email = 'support@chift.eu';
51
- const redirect_url = 'https://chift.eu';
52
- let consumer;
53
- (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
54
- consumer = yield client.Consumers.createConsumer({
55
- email,
56
- redirect_url,
57
- name: consumerName,
58
- });
59
- }));
60
- (0, globals_1.test)('createConsumer', () => __awaiter(void 0, void 0, void 0, function* () {
61
- (0, globals_1.expect)(consumer).toHaveProperty('consumerId');
62
- (0, globals_1.expect)(consumer).toHaveProperty('getConnections');
63
- (0, globals_1.expect)(consumer).toHaveProperty('createConnection');
64
- (0, globals_1.expect)(consumer).toHaveProperty('updateConnection');
65
- (0, globals_1.expect)(consumer).toHaveProperty('deleteConnection');
66
- (0, globals_1.expect)(consumer).toHaveProperty('getSyncUrl');
67
- (0, globals_1.expect)(consumer).toHaveProperty('name', consumerName);
68
- (0, globals_1.expect)(consumer).toHaveProperty('redirect_url', redirect_url);
69
- (0, globals_1.expect)(consumer).toHaveProperty('email', email);
70
- (0, globals_1.expect)(consumer).toHaveProperty('pos');
71
- (0, globals_1.expect)(consumer).toHaveProperty('accounting');
72
- (0, globals_1.expect)(consumer).toHaveProperty('invoicing');
73
- (0, globals_1.expect)(consumer).toHaveProperty('ecommerce');
74
- (0, globals_1.expect)(consumer).toHaveProperty('custom');
75
- }));
76
- (0, globals_1.test)('getConsumers', () => __awaiter(void 0, void 0, void 0, function* () {
77
- const consumers = yield client.Consumers.getConsumers();
78
- (0, globals_1.expect)(consumers).toBeInstanceOf(Array);
79
- }));
80
- (0, globals_1.test)('getConsumersByName', () => __awaiter(void 0, void 0, void 0, function* () {
81
- const consumersWithName = yield client.Consumers.getConsumersByName(consumerName);
82
- (0, globals_1.expect)(consumersWithName).toBeInstanceOf(Array);
83
- (0, globals_1.expect)(consumersWithName.some((consumer) => consumer.name.includes(consumerName))).toBe(true);
84
- }));
85
- (0, globals_1.test)('getConsumerById', () => __awaiter(void 0, void 0, void 0, function* () {
86
- const consumerWithId = yield client.Consumers.getConsumerById(consumer.consumerId);
87
- (0, globals_1.expect)(consumerWithId).toHaveProperty('consumerId', consumer.consumerId);
88
- }));
89
- (0, globals_1.test)('updateConsumerById', () => __awaiter(void 0, void 0, void 0, function* () {
90
- const updatedName = 'updated test consumer';
91
- const updatedConsumer = yield client.Consumers.updateConsumerById(consumer.consumerId, {
92
- name: updatedName,
93
- });
94
- (0, globals_1.expect)(updatedConsumer).toHaveProperty('name', updatedName);
95
- }));
96
- (0, globals_1.test)('deleteConsumerById', () => __awaiter(void 0, void 0, void 0, function* () {
97
- globals_1.expect.assertions(1);
98
- try {
99
- yield client.Consumers.deleteConsumerById(consumer.consumerId);
100
- yield client.Consumers.getConsumerById(consumer.consumerId);
101
- }
102
- catch (e) {
103
- if (axios_1.default.isAxiosError(e)) {
104
- (0, globals_1.expect)(e.message).toMatch('Request failed with status code 404');
105
- return;
106
- }
107
- throw e;
108
- }
109
- }));
@@ -1 +0,0 @@
1
- export {};
@@ -1,224 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- const globals_1 = require("@jest/globals");
36
- const chift = __importStar(require("../../src/index"));
37
- const dotenv = __importStar(require("dotenv"));
38
- dotenv.config();
39
- const client = new chift.API({
40
- baseUrl: process.env.CHIFT_BACKBONE_API,
41
- clientId: process.env.CHIFT_TESTING_CLIENTID,
42
- clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
43
- accountId: process.env.CHIFT_TESTING_ACCOUNTID,
44
- });
45
- const consumerId = process.env.CHIFT_ECOMMERCE_CONSUMER_ID;
46
- let consumer;
47
- (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
48
- consumer = yield client.Consumers.getConsumerById(consumerId);
49
- }));
50
- let customers;
51
- (0, globals_1.test)('getCustomers', () => __awaiter(void 0, void 0, void 0, function* () {
52
- customers = yield consumer.ecommerce.getCustomers();
53
- (0, globals_1.expect)(customers).toBeInstanceOf(Array);
54
- (0, globals_1.expect)(customers.length).toBeGreaterThan(0);
55
- (0, globals_1.expect)(customers[0]).toHaveProperty('id', globals_1.expect.any(String));
56
- }));
57
- let products;
58
- (0, globals_1.test)('getProducts', () => __awaiter(void 0, void 0, void 0, function* () {
59
- products = yield consumer.ecommerce.getProducts();
60
- (0, globals_1.expect)(products).toBeInstanceOf(Array);
61
- (0, globals_1.expect)(products.length).toBeGreaterThan(0);
62
- (0, globals_1.expect)(products[0]).toHaveProperty('id', globals_1.expect.any(String));
63
- }));
64
- (0, globals_1.test)('getCustomer', () => __awaiter(void 0, void 0, void 0, function* () {
65
- const customer = yield consumer.ecommerce.getCustomer(customers[0].id);
66
- (0, globals_1.expect)(customer).toHaveProperty('id', customers[0].id);
67
- (0, globals_1.expect)(customer).toHaveProperty('first_name');
68
- (0, globals_1.expect)(customer).toHaveProperty('last_name');
69
- (0, globals_1.expect)(customer).toHaveProperty('phone');
70
- (0, globals_1.expect)(customer).toHaveProperty('email');
71
- (0, globals_1.expect)(customer).toHaveProperty('language');
72
- (0, globals_1.expect)(customer).toHaveProperty('internal_notes');
73
- (0, globals_1.expect)(customer).toHaveProperty('currency');
74
- (0, globals_1.expect)(customer).toHaveProperty('addresses');
75
- (0, globals_1.expect)(customer).toHaveProperty('created_on');
76
- }));
77
- (0, globals_1.test)('getProduct', () => __awaiter(void 0, void 0, void 0, function* () {
78
- const product = yield consumer.ecommerce.getProduct(products[0].id);
79
- (0, globals_1.expect)(product).toBeTruthy();
80
- (0, globals_1.expect)(product).toHaveProperty('id', products[0].id);
81
- (0, globals_1.expect)(product).toHaveProperty('name', globals_1.expect.any(String));
82
- (0, globals_1.expect)(product).toHaveProperty('description');
83
- (0, globals_1.expect)(product).toHaveProperty('description_html');
84
- (0, globals_1.expect)(product).toHaveProperty('categories');
85
- (0, globals_1.expect)(product).toHaveProperty('created_on');
86
- (0, globals_1.expect)(product).toHaveProperty('variants');
87
- (0, globals_1.expect)(product).toHaveProperty('status');
88
- (0, globals_1.expect)(product).toHaveProperty('common_attributes');
89
- (0, globals_1.expect)(product).toHaveProperty('variant_attributes_options');
90
- (0, globals_1.expect)(product).toHaveProperty('common_images');
91
- }));
92
- let productVariant;
93
- globals_1.test.skip('getProductVariantById', () => __awaiter(void 0, void 0, void 0, function* () {
94
- if (!(products === null || products === void 0 ? void 0 : products.length)) {
95
- throw new Error('No product to test');
96
- }
97
- if (!products[0].variants.length) {
98
- throw new Error('No product variant to test');
99
- }
100
- productVariant = yield consumer.ecommerce.getProductVariantById(products[0].variants[0].id);
101
- (0, globals_1.expect)(productVariant).toBeTruthy();
102
- (0, globals_1.expect)(productVariant).toHaveProperty('id', globals_1.expect.any(String));
103
- }));
104
- let locations;
105
- (0, globals_1.test)('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
106
- locations = yield consumer.ecommerce.getLocations();
107
- (0, globals_1.expect)(locations).toBeInstanceOf(Array);
108
- (0, globals_1.expect)(locations.length).toBeGreaterThan(0);
109
- (0, globals_1.expect)(locations[0]).toHaveProperty('id', globals_1.expect.any(String));
110
- (0, globals_1.expect)(locations[0]).toHaveProperty('name', globals_1.expect.any(String));
111
- }));
112
- globals_1.test.skip('updateAvailableQuantity', () => __awaiter(void 0, void 0, void 0, function* () {
113
- if (!productVariant) {
114
- throw new Error('No product variant found to update available quantity');
115
- }
116
- if (!(locations === null || locations === void 0 ? void 0 : locations.length)) {
117
- throw new Error('No location found to update available quantity');
118
- }
119
- const product = yield consumer.ecommerce.updateAvailableQuantity(productVariant.id, {
120
- location_id: locations[0].id,
121
- available_quantity: 1,
122
- });
123
- (0, globals_1.expect)(product).toBeTruthy();
124
- (0, globals_1.expect)(product).toHaveProperty('available_quantity', globals_1.expect.any(Number));
125
- }));
126
- // TODO: Fix create order test
127
- globals_1.test.skip('createOrder', () => __awaiter(void 0, void 0, void 0, function* () {
128
- const order = yield consumer.ecommerce.createOrder({
129
- customer: {
130
- email: 'test@test.com',
131
- },
132
- billing_address: {
133
- first_name: 'Test',
134
- last_name: 'Test',
135
- street: 'Test',
136
- number: '1',
137
- city: 'Test',
138
- country: 'BE',
139
- },
140
- shipping_address: {
141
- first_name: 'Test',
142
- last_name: 'Test',
143
- street: 'Test',
144
- number: '1',
145
- city: 'Test',
146
- country: 'BE',
147
- },
148
- currency: 'EUR',
149
- lines: [
150
- {
151
- variant_id: '1',
152
- quantity: 1,
153
- tax_rate: 21.0,
154
- unit_price: 10.0,
155
- },
156
- ],
157
- payment_method: 'bank-transfer',
158
- });
159
- (0, globals_1.expect)(order).toBeTruthy();
160
- (0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
161
- }));
162
- let orders;
163
- (0, globals_1.test)('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
164
- orders = yield consumer.ecommerce.getOrders({
165
- date_from: '2023-01-08',
166
- date_to: '2023-01-01',
167
- });
168
- (0, globals_1.expect)(orders).toBeInstanceOf(Array);
169
- }));
170
- globals_1.test.skip('getOrder', () => __awaiter(void 0, void 0, void 0, function* () {
171
- if (!(orders === null || orders === void 0 ? void 0 : orders.length)) {
172
- throw new Error('No orders found to test getOrder');
173
- }
174
- const order = yield consumer.ecommerce.getOrder(orders[0].id);
175
- (0, globals_1.expect)(order).toBeTruthy();
176
- (0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
177
- (0, globals_1.expect)(order).toHaveProperty('order_number');
178
- (0, globals_1.expect)(order).toHaveProperty('billing_address');
179
- (0, globals_1.expect)(order).toHaveProperty('shipping_address');
180
- (0, globals_1.expect)(order).toHaveProperty('created_on');
181
- (0, globals_1.expect)(order).toHaveProperty('confirmed_on');
182
- (0, globals_1.expect)(order).toHaveProperty('cancelled_on');
183
- (0, globals_1.expect)(order).toHaveProperty('status', globals_1.expect.any(String));
184
- (0, globals_1.expect)(order).toHaveProperty('discount_amount', globals_1.expect.any(Number));
185
- (0, globals_1.expect)(order).toHaveProperty('untaxed_amount_without_fees', globals_1.expect.any(Number));
186
- (0, globals_1.expect)(order).toHaveProperty('tax_amount_without_fees', globals_1.expect.any(Number));
187
- (0, globals_1.expect)(order).toHaveProperty('total_without_fees', globals_1.expect.any(Number));
188
- (0, globals_1.expect)(order).toHaveProperty('untaxed_amount', globals_1.expect.any(Number));
189
- (0, globals_1.expect)(order).toHaveProperty('tax_amount', globals_1.expect.any(Number));
190
- (0, globals_1.expect)(order).toHaveProperty('total', globals_1.expect.any(Number));
191
- (0, globals_1.expect)(order).toHaveProperty('refunded_amount', globals_1.expect.any(Number));
192
- (0, globals_1.expect)(order).toHaveProperty('currency');
193
- (0, globals_1.expect)(order).toHaveProperty('note');
194
- (0, globals_1.expect)(order).toHaveProperty('lines', globals_1.expect.any(Array));
195
- (0, globals_1.expect)(order).toHaveProperty('other_fees');
196
- }));
197
- (0, globals_1.test)('getPaymentMethods', () => __awaiter(void 0, void 0, void 0, function* () {
198
- const paymentMethods = yield consumer.ecommerce.getPaymentMethods();
199
- (0, globals_1.expect)(paymentMethods).toBeInstanceOf(Array);
200
- (0, globals_1.expect)(paymentMethods.length).toBeGreaterThan(0);
201
- (0, globals_1.expect)(paymentMethods[0]).toHaveProperty('id', globals_1.expect.any(String));
202
- (0, globals_1.expect)(paymentMethods[0]).toHaveProperty('name', globals_1.expect.any(String));
203
- }));
204
- (0, globals_1.test)('getProductCategories', () => __awaiter(void 0, void 0, void 0, function* () {
205
- const productCategories = yield consumer.ecommerce.getProductCategories();
206
- (0, globals_1.expect)(productCategories).toBeInstanceOf(Array);
207
- (0, globals_1.expect)(productCategories.length).toBeGreaterThan(0);
208
- (0, globals_1.expect)(productCategories[0]).toHaveProperty('id', globals_1.expect.any(String));
209
- (0, globals_1.expect)(productCategories[0]).toHaveProperty('name', globals_1.expect.any(String));
210
- }));
211
- (0, globals_1.test)('getCountries', () => __awaiter(void 0, void 0, void 0, function* () {
212
- const countries = yield consumer.ecommerce.getCountries();
213
- (0, globals_1.expect)(countries).toBeInstanceOf(Array);
214
- (0, globals_1.expect)(countries.length).toBeGreaterThan(0);
215
- (0, globals_1.expect)(countries[0]).toHaveProperty('code', globals_1.expect.any(String));
216
- (0, globals_1.expect)(countries[0]).toHaveProperty('name', globals_1.expect.any(String));
217
- }));
218
- (0, globals_1.test)('getTaxes', () => __awaiter(void 0, void 0, void 0, function* () {
219
- const taxes = yield consumer.ecommerce.getTaxes();
220
- (0, globals_1.expect)(taxes).toBeInstanceOf(Array);
221
- (0, globals_1.expect)(taxes.length).toBeGreaterThan(0);
222
- (0, globals_1.expect)(taxes[0]).toHaveProperty('id', globals_1.expect.any(String));
223
- (0, globals_1.expect)(taxes[0]).toHaveProperty('rate', globals_1.expect.any(Number));
224
- }));
@@ -1 +0,0 @@
1
- export {};
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- const globals_1 = require("@jest/globals");
36
- const chift = __importStar(require("../../src/index"));
37
- const dotenv = __importStar(require("dotenv"));
38
- dotenv.config();
39
- const client = new chift.API({
40
- baseUrl: process.env.CHIFT_BACKBONE_API,
41
- clientId: process.env.CHIFT_TESTING_CLIENTID,
42
- clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
43
- accountId: process.env.CHIFT_TESTING_ACCOUNTID,
44
- });
45
- (0, globals_1.test)('getIntegrations', () => __awaiter(void 0, void 0, void 0, function* () {
46
- const integrations = yield client.Integrations.getIntegrations();
47
- (0, globals_1.expect)(integrations).toBeInstanceOf(Array);
48
- (0, globals_1.expect)(integrations.length).toBeGreaterThan(0);
49
- (0, globals_1.expect)(integrations[0]).toHaveProperty('integrationid', globals_1.expect.any(Number));
50
- (0, globals_1.expect)(integrations[0]).toHaveProperty('name', globals_1.expect.any(String));
51
- (0, globals_1.expect)(integrations[0]).toHaveProperty('status', globals_1.expect.stringMatching(/^(active|inactive)$/));
52
- (0, globals_1.expect)(integrations[0]).toHaveProperty('api', globals_1.expect.any(String));
53
- (0, globals_1.expect)(integrations[0]).toHaveProperty('credentials', globals_1.expect.any(Array));
54
- }));
@@ -1 +0,0 @@
1
- export {};
@@ -1,115 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- const globals_1 = require("@jest/globals");
36
- const chift = __importStar(require("../../src/index"));
37
- const dotenv = __importStar(require("dotenv"));
38
- dotenv.config();
39
- const client = new chift.API({
40
- baseUrl: process.env.CHIFT_BACKBONE_API,
41
- clientId: process.env.CHIFT_TESTING_CLIENTID,
42
- clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
43
- accountId: process.env.CHIFT_TESTING_ACCOUNTID,
44
- });
45
- const consumerId = process.env.CHIFT_INVOICING_CONSUMER_ID;
46
- let consumer;
47
- (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
48
- consumer = yield client.Consumers.getConsumerById(consumerId);
49
- }));
50
- let invoices;
51
- (0, globals_1.test)('getInvoices', () => __awaiter(void 0, void 0, void 0, function* () {
52
- invoices = yield consumer.invoicing.getInvoices({
53
- invoice_type: 'customer_invoice',
54
- });
55
- (0, globals_1.expect)(invoices).toBeInstanceOf(Array);
56
- (0, globals_1.expect)(invoices.length).toBeGreaterThan(0);
57
- (0, globals_1.expect)(invoices[0]).toHaveProperty('id', globals_1.expect.any(String));
58
- }));
59
- (0, globals_1.test)('getInvoiceById', () => __awaiter(void 0, void 0, void 0, function* () {
60
- if (!invoices.length) {
61
- throw new Error('No invoices found to test getInvoiceById');
62
- }
63
- const invoice = yield consumer.invoicing.getInvoiceById(invoices[0].id, { include_pdf: false });
64
- (0, globals_1.expect)(invoice).toHaveProperty('id', globals_1.expect.any(String));
65
- }));
66
- let products;
67
- (0, globals_1.test)('getProducts', () => __awaiter(void 0, void 0, void 0, function* () {
68
- products = yield consumer.invoicing.getProducts();
69
- (0, globals_1.expect)(products).toBeInstanceOf(Array);
70
- (0, globals_1.expect)(products.length).toBeGreaterThan(0);
71
- (0, globals_1.expect)(products[0]).toHaveProperty('id', globals_1.expect.any(String));
72
- }));
73
- (0, globals_1.test)('getProductById', () => __awaiter(void 0, void 0, void 0, function* () {
74
- const product = yield consumer.invoicing.getProductById(products[0].id);
75
- (0, globals_1.expect)(product).toHaveProperty('id', globals_1.expect.any(String));
76
- }));
77
- let vatCodes;
78
- (0, globals_1.test)('getTaxes', () => __awaiter(void 0, void 0, void 0, function* () {
79
- vatCodes = yield consumer.invoicing.getTaxes();
80
- (0, globals_1.expect)(vatCodes).toBeInstanceOf(Array);
81
- (0, globals_1.expect)(vatCodes.length).toBeGreaterThan(0);
82
- (0, globals_1.expect)(vatCodes[0]).toHaveProperty('id', globals_1.expect.any(String));
83
- }));
84
- (0, globals_1.test)('getTaxById', () => __awaiter(void 0, void 0, void 0, function* () {
85
- const tax = yield consumer.invoicing.getTaxById(vatCodes[0].id);
86
- (0, globals_1.expect)(tax).toHaveProperty('id', globals_1.expect.any(String));
87
- }));
88
- let opportunities;
89
- globals_1.test.skip('getOpportunities', () => __awaiter(void 0, void 0, void 0, function* () {
90
- opportunities = yield consumer.invoicing.getOpportunities();
91
- (0, globals_1.expect)(opportunities).toBeInstanceOf(Array);
92
- (0, globals_1.expect)(opportunities.length).toBeGreaterThan(0);
93
- (0, globals_1.expect)(opportunities[0]).toHaveProperty('id', globals_1.expect.any(String));
94
- }));
95
- globals_1.test.skip('getOpportunitiesById', () => __awaiter(void 0, void 0, void 0, function* () {
96
- if (!opportunities.length) {
97
- throw new Error('No opportunities found to test getOpportunitiesById');
98
- }
99
- const opportunity = yield consumer.invoicing.getOpportunitiesById(opportunities[0].id);
100
- (0, globals_1.expect)(opportunity).toHaveProperty('id', globals_1.expect.any(String));
101
- }));
102
- let contacts;
103
- (0, globals_1.test)('getContacts', () => __awaiter(void 0, void 0, void 0, function* () {
104
- contacts = yield consumer.invoicing.getContacts();
105
- (0, globals_1.expect)(contacts).toBeInstanceOf(Array);
106
- (0, globals_1.expect)(contacts.length).toBeGreaterThan(0);
107
- (0, globals_1.expect)(contacts[0]).toHaveProperty('id', globals_1.expect.any(String));
108
- }));
109
- (0, globals_1.test)('getContactById', () => __awaiter(void 0, void 0, void 0, function* () {
110
- if (!contacts.length) {
111
- throw new Error('No contacts found to test getContactById');
112
- }
113
- const contact = yield consumer.invoicing.getContactById(contacts[0].id);
114
- (0, globals_1.expect)(contact).toHaveProperty('id', globals_1.expect.any(String));
115
- }));
@@ -1 +0,0 @@
1
- export {};