@orchesty/connector-upgates 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +95 -0
  2. package/dist/Batch/UpgatesCreateWebhooks.js +1 -0
  3. package/dist/Connector/UpgatesDeleteWebhooks.js +5 -1
  4. package/dist/package.json +5 -2
  5. package/package.json +5 -2
  6. package/CHANGELOG.md +0 -7
  7. package/coverage/clover.xml +0 -302
  8. package/coverage/coverage-final.json +0 -11
  9. package/coverage/lcov-report/base.css +0 -224
  10. package/coverage/lcov-report/block-navigation.js +0 -87
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +0 -161
  13. package/coverage/lcov-report/prettify.css +0 -1
  14. package/coverage/lcov-report/prettify.js +0 -2
  15. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  16. package/coverage/lcov-report/sorter.js +0 -210
  17. package/coverage/lcov-report/src/Batch/UpgatesCreateWebhooks.ts.html +0 -358
  18. package/coverage/lcov-report/src/Batch/UpgatesGetOrders.ts.html +0 -727
  19. package/coverage/lcov-report/src/Batch/UpgatesGetProducts.ts.html +0 -733
  20. package/coverage/lcov-report/src/Batch/index.html +0 -146
  21. package/coverage/lcov-report/src/Connector/UpgatesDeleteWebhooks.ts.html +0 -370
  22. package/coverage/lcov-report/src/Connector/UpgatesGetOrderStates.ts.html +0 -190
  23. package/coverage/lcov-report/src/Connector/UpgatesGetPayments.ts.html +0 -268
  24. package/coverage/lcov-report/src/Connector/UpgatesGetProductParameters.ts.html +0 -316
  25. package/coverage/lcov-report/src/Connector/UpgatesGetShipments.ts.html +0 -274
  26. package/coverage/lcov-report/src/Connector/index.html +0 -176
  27. package/coverage/lcov-report/src/UpgatesApplication.ts.html +0 -379
  28. package/coverage/lcov-report/src/index.html +0 -116
  29. package/coverage/lcov-report/test/dataProvider.ts.html +0 -223
  30. package/coverage/lcov-report/test/index.html +0 -116
  31. package/coverage/lcov.info +0 -485
  32. package/jest.config.js +0 -13
  33. package/src/Batch/UpgatesCreateWebhooks.ts +0 -91
  34. package/src/Batch/UpgatesGetOrders.ts +0 -214
  35. package/src/Batch/UpgatesGetProducts.ts +0 -216
  36. package/src/Batch/__tests__/Data/UpgatesCreateWebhooks/input.json +0 -6
  37. package/src/Batch/__tests__/Data/UpgatesCreateWebhooks/mock.json +0 -14
  38. package/src/Batch/__tests__/Data/UpgatesCreateWebhooks/output.json +0 -6
  39. package/src/Batch/__tests__/Data/UpgatesGetOrders/input.json +0 -6
  40. package/src/Batch/__tests__/Data/UpgatesGetOrders/lastRun-input.json +0 -6
  41. package/src/Batch/__tests__/Data/UpgatesGetOrders/lastRun-mock.json +0 -191
  42. package/src/Batch/__tests__/Data/UpgatesGetOrders/lastRun-output.json +0 -11
  43. package/src/Batch/__tests__/Data/UpgatesGetOrders/mock.json +0 -191
  44. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumber-input.json +0 -8
  45. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumber-mock.json +0 -191
  46. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumber-output.json +0 -11
  47. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumbers-input.json +0 -8
  48. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumbers-mock.json +0 -191
  49. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumbers-output.json +0 -11
  50. package/src/Batch/__tests__/Data/UpgatesGetOrders/output.json +0 -11
  51. package/src/Batch/__tests__/Data/UpgatesGetProducts/input.json +0 -6
  52. package/src/Batch/__tests__/Data/UpgatesGetProducts/lastRun-input.json +0 -6
  53. package/src/Batch/__tests__/Data/UpgatesGetProducts/lastRun-mock.json +0 -147
  54. package/src/Batch/__tests__/Data/UpgatesGetProducts/lastRun-output.json +0 -11
  55. package/src/Batch/__tests__/Data/UpgatesGetProducts/mock.json +0 -146
  56. package/src/Batch/__tests__/Data/UpgatesGetProducts/output.json +0 -11
  57. package/src/Batch/__tests__/Data/UpgatesGetProducts/productId-input.json +0 -8
  58. package/src/Batch/__tests__/Data/UpgatesGetProducts/productId-mock.json +0 -146
  59. package/src/Batch/__tests__/Data/UpgatesGetProducts/productId-output.json +0 -11
  60. package/src/Batch/__tests__/Data/UpgatesGetProducts/productIds-input.json +0 -8
  61. package/src/Batch/__tests__/Data/UpgatesGetProducts/productIds-mock.json +0 -146
  62. package/src/Batch/__tests__/Data/UpgatesGetProducts/productIds-output.json +0 -11
  63. package/src/Batch/__tests__/UpgatesCreateWebhooks.ts +0 -17
  64. package/src/Batch/__tests__/UpgatesGetOrders.ts +0 -33
  65. package/src/Batch/__tests__/UpgatesGetProducts.ts +0 -33
  66. package/src/Connector/UpgatesDeleteWebhooks.ts +0 -95
  67. package/src/Connector/UpgatesGetOrderStates.ts +0 -35
  68. package/src/Connector/UpgatesGetPayments.ts +0 -61
  69. package/src/Connector/UpgatesGetProductParameters.ts +0 -77
  70. package/src/Connector/UpgatesGetShipments.ts +0 -63
  71. package/src/Connector/UpgatesUpdateOrder.ts +0 -73
  72. package/src/Connector/UpgatesUpdateStock.ts +0 -59
  73. package/src/Connector/__tests__/Data/UpgatesDeleteWebhooks/input.json +0 -6
  74. package/src/Connector/__tests__/Data/UpgatesDeleteWebhooks/mock.json +0 -16
  75. package/src/Connector/__tests__/Data/UpgatesDeleteWebhooks/output.json +0 -6
  76. package/src/Connector/__tests__/Data/UpgatesGetOrderStates/input.json +0 -6
  77. package/src/Connector/__tests__/Data/UpgatesGetOrderStates/mock.json +0 -14
  78. package/src/Connector/__tests__/Data/UpgatesGetOrderStates/output.json +0 -15
  79. package/src/Connector/__tests__/Data/UpgatesGetPayments/input.json +0 -6
  80. package/src/Connector/__tests__/Data/UpgatesGetPayments/mock.json +0 -42
  81. package/src/Connector/__tests__/Data/UpgatesGetPayments/output.json +0 -43
  82. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/both-input.json +0 -9
  83. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/both-mock.json +0 -108
  84. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/both-output.json +0 -109
  85. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/input.json +0 -8
  86. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/mock.json +0 -108
  87. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/none-input.json +0 -6
  88. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/none-mock.json +0 -5
  89. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/none-output.json +0 -6
  90. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/output.json +0 -109
  91. package/src/Connector/__tests__/Data/UpgatesGetShipments/input.json +0 -6
  92. package/src/Connector/__tests__/Data/UpgatesGetShipments/mock.json +0 -58
  93. package/src/Connector/__tests__/Data/UpgatesGetShipments/output.json +0 -59
  94. package/src/Connector/__tests__/UpgatesDeleteWebhooks.ts +0 -61
  95. package/src/Connector/__tests__/UpgatesGetOrderStates.ts +0 -18
  96. package/src/Connector/__tests__/UpgatesGetPayments.ts +0 -18
  97. package/src/Connector/__tests__/UpgatesGetProductParameters.ts +0 -28
  98. package/src/Connector/__tests__/UpgatesGetShipments.ts +0 -18
  99. package/src/UpgatesApplication.ts +0 -98
  100. package/test/dataProvider.ts +0 -46
  101. package/tsconfig.json +0 -8
  102. package/tsconfig.prod.json +0 -13
  103. package/tsconfig.prod.tsbuildinfo +0 -1
@@ -1,11 +0,0 @@
1
- {
2
- "headers": {
3
- "user": "TestUser"
4
- },
5
- "data": [
6
- {
7
- "body": "{\"code\":\"\",\"code_supplier\":\"\",\"supplier\":\"\",\"ean\":\"\",\"product_id\":0,\"active_yn\":false,\"archived_yn\":false,\"replacement_product_code\":\"\",\"can_add_to_basket_yn\":false,\"adult_yn\":false,\"descriptions\":[{\"language\":\"\",\"title\":\"\",\"short_description\":\"\",\"long_description\":\"\",\"url\":\"\",\"seo_title\":\"\",\"seo_description\":\"\",\"seo_url\":\"\",\"unit\":\"\"}],\"manufacturer\":\"\",\"stock\":0,\"stock_position\":\"\",\"availability\":\"\",\"availability_type\":\"OnRequest\",\"weight\":0,\"shipment_group\":\"\",\"images\":[{\"url\":\"\",\"main_yn\":false,\"list_yn\":false,\"position\":0,\"titles\":[{},\"language\",\"title\"]}],\"categories\":[{\"category_id\":0,\"code\":\"\",\"main_yn\":false,\"position\":0,\"name\":\"\"}],\"groups\":[],\"prices\":[{\"language\":\"\",\"currency\":\"\",\"pricelists\":[{\"name\":\"\",\"price_original\":0,\"product_discount\":0,\"product_discount_real`\":\"\",\"price_sale\":0,\"price_with_vat`\":\"\",\"price_without_vat`\":\"\"}],\"price_purchase\":0,\"price_common\":0,\"recycling_fee\":0}],\"vats\":{},\"variants\":[{\"code\":\"\",\"code_supplier\":\"\",\"ean\":\"\",\"variant_id\":0,\"active_yn\":false,\"can_add_to_basket_yn\":false,\"stock\":0,\"stock_position\":\"\",\"availability\":\"\",\"availability_type\":\"OnRequest\",\"weight\":\"\",\"image\":\"\",\"prices\":[{\"language\":\"\",\"currency\":\"\",\"pricelists\":[{\"name\":\"\",\"price_original\":0,\"product_discount\":0,\"product_discount_real`\":\"\",\"price_sale\":0,\"price_with_vat`\":\"\",\"price_without_vat`\":\"\"}],\"price_purchase\":0,\"price_common\":0}],\"metas\":[{\"key\":\"\",\"type\":\"radio\",\"value\":\"\",\"values\":[{\"language\":\"\",\"value\":\"\"}]}]}],\"metas\":[{\"key\":\"\",\"type\":\"radio\",\"value\":\"\",\"values\":[{\"language\":\"\",\"value\":\"\"}]}],\"admin_url\":\"\"}",
8
- "headers": {}
9
- }
10
- ]
11
- }
@@ -1,17 +0,0 @@
1
- import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
2
- import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
3
- import { init } from '../../../test/dataProvider';
4
- import { NAME as UPGATES_CREATE_WEBHOOKS } from '../UpgatesCreateWebhooks';
5
-
6
- let tester: NodeTester;
7
-
8
- describe('Tests for UpgatesCreateWebhooks', () => {
9
- beforeAll(() => {
10
- tester = new NodeTester(container, __filename);
11
- init();
12
- });
13
-
14
- it('process - ok', async () => {
15
- await tester.testBatch(UPGATES_CREATE_WEBHOOKS);
16
- });
17
- });
@@ -1,33 +0,0 @@
1
- import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
2
- import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
3
- import { init, mock } from '../../../test/dataProvider';
4
- import { NAME as UPGATES_GET_ORDERS } from '../UpgatesGetOrders';
5
-
6
- let tester: NodeTester;
7
-
8
- describe('Tests for UpgatesGetOrders', () => {
9
- beforeAll(() => {
10
- tester = new NodeTester(container, __filename);
11
- init();
12
- });
13
-
14
- it('process - ok', async () => {
15
- mock();
16
- await tester.testBatch(UPGATES_GET_ORDERS);
17
- });
18
-
19
- it('process - lastRun', async () => {
20
- mock({ orderLastRun: '2022-09-22T08:21:27.000Z' });
21
- await tester.testBatch(UPGATES_GET_ORDERS, 'lastRun');
22
- });
23
-
24
- it('process - orderNumber', async () => {
25
- mock();
26
- await tester.testBatch(UPGATES_GET_ORDERS, 'orderNumber');
27
- });
28
-
29
- it('process - orderNumbers', async () => {
30
- mock();
31
- await tester.testBatch(UPGATES_GET_ORDERS, 'orderNumbers');
32
- });
33
- });
@@ -1,33 +0,0 @@
1
- import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
2
- import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
3
- import { init, mock } from '../../../test/dataProvider';
4
- import { NAME as UPGATES_GET_PRODUCTS } from '../UpgatesGetProducts';
5
-
6
- let tester: NodeTester;
7
-
8
- describe('Tests for UpgatesGetProducts', () => {
9
- beforeAll(() => {
10
- tester = new NodeTester(container, __filename);
11
- init();
12
- });
13
-
14
- it('process - ok', async () => {
15
- mock();
16
- await tester.testBatch(UPGATES_GET_PRODUCTS);
17
- });
18
-
19
- it('process - lastRun', async () => {
20
- mock({ productLastRun: '2022-09-22T08:21:27.000Z' });
21
- await tester.testBatch(UPGATES_GET_PRODUCTS, 'lastRun');
22
- });
23
-
24
- it('process - productId', async () => {
25
- mock();
26
- await tester.testBatch(UPGATES_GET_PRODUCTS, 'productId');
27
- });
28
-
29
- it('process - productIds', async () => {
30
- mock();
31
- await tester.testBatch(UPGATES_GET_PRODUCTS, 'productIds');
32
- });
33
- });
@@ -1,95 +0,0 @@
1
- import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
2
- import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
3
- import WebhookRepository from '@orchesty/nodejs-sdk/dist/lib/Application/Database/WebhookRepository';
4
- import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
5
- import OnRepeatException from '@orchesty/nodejs-sdk/dist/lib/Exception/OnRepeatException';
6
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
7
- import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
8
- import { StatusCodes } from 'http-status-codes';
9
- import UpgatesApplication from '../UpgatesApplication';
10
-
11
- export const NAME = 'upgates-delete-webhooks';
12
- const UPGATES_DELETE_WEBHOOK_ENDPOINT = 'api/v2/webhooks';
13
-
14
- export default class UpgatesDeleteWebhooks extends AConnector {
15
-
16
- public getName(): string {
17
- return NAME;
18
- }
19
-
20
- public async processAction(dto: ProcessDto): Promise<ProcessDto> {
21
- const app = this.getApplication<UpgatesApplication>();
22
-
23
- let appInstall: ApplicationInstall;
24
- try {
25
- appInstall = await this.getApplicationInstallFromProcess(dto, null, true);
26
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
- } catch (e) {
28
- appInstall = await this.getApplicationInstallFromProcess(dto, null, false);
29
- }
30
-
31
- const repo = this.getDbClient().getRepository(Webhook) as WebhookRepository;
32
- const webhooks = (await repo.findMany({ users: [appInstall.getUser()], apps: [app.getName()] }))
33
- .filter((item) => !item.getUnsubscribeFailed());
34
-
35
- const webhooksIds: number[] = [];
36
-
37
- webhooks.forEach((webhook) => {
38
- webhooksIds.push(Number(webhook.getWebhookId()));
39
- });
40
-
41
- if (webhooks && webhooks.length > 0) {
42
- const requestDto = app.getRequestDto(
43
- dto,
44
- appInstall,
45
- HttpMethods.DELETE,
46
- `${UPGATES_DELETE_WEBHOOK_ENDPOINT}?ids=${webhooksIds.join(';')}`,
47
- );
48
- const res = await this.getSender().send<IResponse>(requestDto);
49
- if (res.getResponseCode() !== StatusCodes.OK && res.getResponseCode() !== StatusCodes.NOT_FOUND) {
50
- await Promise.all(
51
- webhooks.map(async (wantedDelete) => {
52
- wantedDelete.setUnsubscribeFailed(true);
53
- return repo.update(wantedDelete);
54
- }),
55
- );
56
- throw new OnRepeatException(60, 10, res.getBody());
57
- }
58
-
59
- let repeat = false;
60
- const resData = res.getJsonBody().webhooks;
61
- await Promise.all(
62
- webhooks.map(async (wantedDelete) => {
63
- const foundWebhook = resData?.find(
64
- (item) => String(item.id) === wantedDelete.getWebhookId(),
65
- );
66
- if (foundWebhook) {
67
- return repo.remove(wantedDelete);
68
- }
69
-
70
- repeat = true;
71
- wantedDelete.setUnsubscribeFailed(true);
72
- return repo.update(wantedDelete);
73
- }),
74
- );
75
-
76
- if (repeat) {
77
- throw new OnRepeatException(60, 10, res.getBody());
78
- }
79
- }
80
-
81
- return dto;
82
- }
83
-
84
- }
85
-
86
- export interface IResponse {
87
- webhooks: IWebhook[]
88
- }
89
-
90
- export interface IWebhook {
91
- id: string|number;
92
-
93
- deleted: boolean;
94
- messages: string[];
95
- }
@@ -1,35 +0,0 @@
1
- import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
- import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
-
5
- export const NAME = 'upgates-get-order-states';
6
- const GET_ORDER_STATES_ENDPOINT = 'api/v2/orders/states';
7
-
8
- export default class UpgatesGetOrderStates extends AConnector {
9
-
10
- public getName(): string {
11
- return NAME;
12
- }
13
-
14
- public async processAction(dto: ProcessDto): Promise<ProcessDto<IOutput>> {
15
- const req = await this.getApplication().getRequestDto(
16
- dto,
17
- await this.getApplicationInstallFromProcess(dto, null),
18
- HttpMethods.GET,
19
- GET_ORDER_STATES_ENDPOINT,
20
- );
21
- const resp = await this.getSender().send<IOutput>(req, [200]);
22
-
23
- return dto.setNewJsonData(resp.getJsonBody());
24
- }
25
-
26
- }
27
-
28
- export interface IOutput {
29
- states: {
30
- id: number;
31
- type: string;
32
- color: string;
33
- names: Record<string, string>;
34
- }[];
35
- }
@@ -1,61 +0,0 @@
1
- import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
- import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
-
5
- export const NAME = 'upgates-get-payments';
6
- const GET_PAYMENTS_ENDPOINT = 'api/v2/payments';
7
-
8
- export default class UpgatesGetPayments extends AConnector {
9
-
10
- public getName(): string {
11
- return NAME;
12
- }
13
-
14
- public async processAction(dto: ProcessDto): Promise<ProcessDto<IOutput>> {
15
- const req = await this.getApplication().getRequestDto(
16
- dto,
17
- await this.getApplicationInstallFromProcess(dto, null),
18
- HttpMethods.GET,
19
- GET_PAYMENTS_ENDPOINT,
20
- );
21
- const resp = await this.getSender().send<IOutput>(req, [200]);
22
-
23
- return dto.setNewJsonData(resp.getJsonBody());
24
- }
25
-
26
- }
27
-
28
- /* eslint-disable @typescript-eslint/naming-convention */
29
- export interface IOutput {
30
- current_page: number;
31
- current_page_items: number;
32
- number_of_pages: number;
33
- number_of_items: number;
34
- payments: IPayment[];
35
- }
36
-
37
- export interface IPayment {
38
- id: string;
39
- code: string;
40
- image_url: string;
41
- type: string;
42
- active_yn: boolean;
43
- descriptions: {
44
- language_id: string;
45
- name: string;
46
- description: string;
47
- price: number;
48
- price_type: string;
49
- free_from: number;
50
- }[];
51
- metas: {
52
- key: string;
53
- type: string;
54
- value: string;
55
- values: {
56
- language: string;
57
- value: string;
58
- }[];
59
- }[];
60
- }
61
- /* eslint-enable @typescript-eslint/naming-convention */
@@ -1,77 +0,0 @@
1
- import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
- import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
-
5
- export const NAME = 'upgates-get-product-parameters';
6
- const GET_PARAMETERS_ENDPOINT = 'api/v2/products/parameters/';
7
-
8
- export default class UpgatesGetProductParameters extends AConnector {
9
-
10
- public getName(): string {
11
- return NAME;
12
- }
13
-
14
- public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
15
- const { code, productId } = dto.getJsonData();
16
-
17
- if (!code && !productId) {
18
- throw new Error('At least one parameter must be inserted.');
19
- }
20
-
21
- let url = GET_PARAMETERS_ENDPOINT;
22
- if (code) {
23
- url = `${url}?code=${code}`;
24
- }
25
-
26
- if (productId) {
27
- const joinChar = url.includes('?') ? '&' : '?';
28
- url = `${url}${joinChar}product_id=${productId}`;
29
- }
30
-
31
- const req = await this.getApplication().getRequestDto(
32
- dto,
33
- await this.getApplicationInstallFromProcess(dto, null),
34
- HttpMethods.GET,
35
- url,
36
- );
37
- const resp = await this.getSender().send<IOutput>(req, [200]);
38
-
39
- return dto.setNewJsonData(resp.getJsonBody());
40
- }
41
-
42
- }
43
-
44
- export interface IInput {
45
- code?: string;
46
- productId?: string;
47
- }
48
-
49
- /* eslint-disable @typescript-eslint/naming-convention */
50
- export interface IOutput {
51
- current_page: number;
52
- current_page_items: number;
53
- number_of_pages: number;
54
- number_of_items: number;
55
- products: IProduct[];
56
- }
57
-
58
- export interface IProduct {
59
- code: string,
60
- parameters: {
61
- name: Record<string, string>,
62
- values: Record<string, string>[]
63
- }[],
64
- variants: [
65
- {
66
- code: string,
67
- parameters: [
68
- {
69
- name: Record<string, string>,
70
- values: Record<string, string>[]
71
- },
72
- ]
73
- },
74
- ],
75
- admin_url: string;
76
- }
77
- /* eslint-enable @typescript-eslint/naming-convention */
@@ -1,63 +0,0 @@
1
- import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
- import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
-
5
- export const NAME = 'upgates-get-shipments';
6
- const GET_SHIPMENTS_ENDPOINT = 'api/v2/shipments';
7
-
8
- export default class UpgatesGetShipments extends AConnector {
9
-
10
- public getName(): string {
11
- return NAME;
12
- }
13
-
14
- public async processAction(dto: ProcessDto): Promise<ProcessDto<IOutput>> {
15
- const req = await this.getApplication().getRequestDto(
16
- dto,
17
- await this.getApplicationInstallFromProcess(dto, null),
18
- HttpMethods.GET,
19
- GET_SHIPMENTS_ENDPOINT,
20
- );
21
- const resp = await this.getSender().send<IOutput>(req, [200]);
22
-
23
- return dto.setNewJsonData(resp.getJsonBody());
24
- }
25
-
26
- }
27
-
28
- /* eslint-disable @typescript-eslint/naming-convention */
29
- export interface IOutput {
30
- current_page: number;
31
- current_page_items: number;
32
- number_of_pages: number;
33
- number_of_items: number;
34
- shipments: IShipment[];
35
- }
36
-
37
- export interface IShipment {
38
- id: string;
39
- code: string;
40
- image_url: string;
41
- type: string;
42
- active_yn: boolean;
43
- affiliates_types: string[];
44
- tracking_url: string;
45
- internal_note: string;
46
- descriptions: {
47
- language_id: string;
48
- name: string;
49
- description: string;
50
- price: number;
51
- free_from: number;
52
- }[];
53
- metas: {
54
- key: string;
55
- type: string;
56
- value: string;
57
- values: {
58
- language: string;
59
- value: string;
60
- }[];
61
- }[];
62
- }
63
- /* eslint-enable @typescript-eslint/naming-convention */
@@ -1,73 +0,0 @@
1
- import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
- import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
- import UpgatesApplication from '../UpgatesApplication';
5
-
6
- const UPDATE_ORDER_ENDPOINT = 'api/v2/orders';
7
-
8
- export const NAME = 'upgates-update-order';
9
-
10
- export default class UpgatesUpdateOrder extends AConnector {
11
-
12
- public getName(): string {
13
- return NAME;
14
- }
15
-
16
- public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOrder[]>> {
17
- const app = this.getApplication<UpgatesApplication>();
18
- const { data } = dto.getJsonData();
19
-
20
- const appInstall = await this.getApplicationInstallFromProcess(dto);
21
- const requestDto = app.getRequestDto(
22
- dto,
23
- appInstall,
24
- HttpMethods.PUT,
25
- UPDATE_ORDER_ENDPOINT,
26
- JSON.stringify(data),
27
- );
28
-
29
- const { orders } = (await this.getSender().send<IResponseJson>(requestDto)).getJsonBody();
30
-
31
- return dto.setNewJsonData(orders);
32
- }
33
-
34
- }
35
-
36
- /* eslint-disable @typescript-eslint/naming-convention */
37
- export interface IInput {
38
- data: IUpdateOrders;
39
- }
40
-
41
- interface IUpdateOrders {
42
- orders: IUpdate[];
43
- send_emails_yn?: boolean;
44
- send_sms_yn?: boolean;
45
- }
46
-
47
- interface IUpdate {
48
- order_number: string;
49
- status?: string;
50
- status_id?: number;
51
- paid_date?: Date;
52
- tracking_code?: string;
53
- resolved_yn?: boolean;
54
- internal_note?: string;
55
- metas?: Record<string, string>[];
56
- }
57
-
58
- interface IResponseJson {
59
- orders: IOrder[];
60
- }
61
-
62
- interface IOrder {
63
- order_number: string;
64
- order_url: string;
65
- updated_yn: string;
66
- messages: IMessage[];
67
- }
68
-
69
- interface IMessage {
70
- object: string;
71
- property: string;
72
- message: string;
73
- }
@@ -1,59 +0,0 @@
1
- import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
2
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
- import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
4
- import UpgatesApplication from '../UpgatesApplication';
5
-
6
- const UPDATE_STOCK_ENDPOINT = 'api/v2/products';
7
-
8
- export const NAME = 'upgates-update-stock';
9
-
10
- export default class UpgatesUpdateStock extends AConnector {
11
-
12
- public getName(): string {
13
- return NAME;
14
- }
15
-
16
- public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto> {
17
- const app = this.getApplication<UpgatesApplication>();
18
- const {
19
- data,
20
- } = dto.getJsonData();
21
-
22
- const appInstall = await this.getApplicationInstallFromProcess(dto);
23
- const requestDto = app.getRequestDto(
24
- dto,
25
- appInstall,
26
- HttpMethods.PUT,
27
- UPDATE_STOCK_ENDPOINT,
28
- JSON.stringify(data),
29
- );
30
-
31
- const { products } = (await this.getSender().send<IResponseJson>(requestDto)).getJsonBody();
32
-
33
- return dto.setNewJsonData(products);
34
- }
35
-
36
- }
37
-
38
- /* eslint-disable @typescript-eslint/naming-convention */
39
- export interface IInput {
40
- data: IUpdateStock;
41
- }
42
-
43
- interface IUpdateStock {
44
- products?: {
45
- code: string;
46
- stock: number;
47
- }[];
48
- variants?: {
49
- code: string;
50
- stock: number;
51
- }[];
52
- }
53
-
54
- interface IResponseJson {
55
- products: {
56
- code: string;
57
- updated_yn: boolean;
58
- }[];
59
- }
@@ -1,6 +0,0 @@
1
- {
2
- "headers": {
3
- "user": "TestUser"
4
- },
5
- "data": {}
6
- }
@@ -1,16 +0,0 @@
1
- {
2
- "http": "DELETE https://private-anon-903e641b16-upgatesapiv2.apiary-mock.com/api/v2/webhooks?ids=1",
3
- "code": 200,
4
- "body": {
5
- "webhooks": [
6
- {
7
- "id": 1,
8
- "deleted": false,
9
- "messages": [
10
- "message"
11
- ]
12
- }
13
- ]
14
- }
15
- }
16
-
@@ -1,6 +0,0 @@
1
- {
2
- "headers": {
3
- "user": "TestUser"
4
- },
5
- "data": {}
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "headers": {
3
- "user": "TestUser"
4
- },
5
- "data": {}
6
- }
@@ -1,14 +0,0 @@
1
- {
2
- "http": "GET https://private-anon-903e641b16-upgatesapiv2.apiary-mock.com/api/v2/orders/states",
3
- "code": 200,
4
- "body": {
5
- "states": [
6
- {
7
- "id": 0,
8
- "type": "Received",
9
- "color": "",
10
- "names": {}
11
- }
12
- ]
13
- }
14
- }
@@ -1,15 +0,0 @@
1
- {
2
- "headers": {
3
- "user": "TestUser"
4
- },
5
- "data": {
6
- "states": [
7
- {
8
- "color": "",
9
- "id": 0,
10
- "names": {},
11
- "type": "Received"
12
- }
13
- ]
14
- }
15
- }
@@ -1,6 +0,0 @@
1
- {
2
- "headers": {
3
- "user": "TestUser"
4
- },
5
- "data": {}
6
- }