@orchesty/connector-authentica 1.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 (172) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +190 -0
  3. package/coverage/clover.xml +413 -0
  4. package/coverage/coverage-final.json +19 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +161 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +210 -0
  13. package/coverage/lcov-report/src/AuthenticaApplication.ts.html +496 -0
  14. package/coverage/lcov-report/src/Batch/AuthenticaGetStock.ts.html +316 -0
  15. package/coverage/lcov-report/src/Batch/AuthenticaGetStockAvailable.ts.html +262 -0
  16. package/coverage/lcov-report/src/Batch/index.html +131 -0
  17. package/coverage/lcov-report/src/Connector/AuthenticaCreateOrder.ts.html +244 -0
  18. package/coverage/lcov-report/src/Connector/AuthenticaCreateProduct.ts.html +247 -0
  19. package/coverage/lcov-report/src/Connector/AuthenticaCreateReceipt.ts.html +244 -0
  20. package/coverage/lcov-report/src/Connector/AuthenticaGetCarriersConnector.ts.html +205 -0
  21. package/coverage/lcov-report/src/Connector/AuthenticaGetOrder.ts.html +259 -0
  22. package/coverage/lcov-report/src/Connector/AuthenticaGetOrderStatus.ts.html +199 -0
  23. package/coverage/lcov-report/src/Connector/AuthenticaGetReceipt.ts.html +259 -0
  24. package/coverage/lcov-report/src/Connector/AuthenticaGetShippingMethods.ts.html +208 -0
  25. package/coverage/lcov-report/src/Connector/AuthenticaPostLabel.ts.html +196 -0
  26. package/coverage/lcov-report/src/Connector/AuthenticaPutOrders.ts.html +334 -0
  27. package/coverage/lcov-report/src/Connector/AuthenticaPutProducts.ts.html +250 -0
  28. package/coverage/lcov-report/src/Connector/AuthenticaUpdateOrder.ts.html +256 -0
  29. package/coverage/lcov-report/src/Connector/AuthenticaUpdateProduct.ts.html +259 -0
  30. package/coverage/lcov-report/src/Connector/AuthenticaUpdateReceipt.ts.html +193 -0
  31. package/coverage/lcov-report/src/Connector/index.html +311 -0
  32. package/coverage/lcov-report/src/index.html +116 -0
  33. package/coverage/lcov-report/test/dataProvider.ts.html +325 -0
  34. package/coverage/lcov-report/test/index.html +116 -0
  35. package/coverage/lcov.info +676 -0
  36. package/dist/AuthenticaApplication.d.ts +29 -0
  37. package/dist/AuthenticaApplication.js +128 -0
  38. package/dist/Batch/AuthenticaGetStock.d.ts +20 -0
  39. package/dist/Batch/AuthenticaGetStock.js +45 -0
  40. package/dist/Batch/AuthenticaGetStockAvailable.d.ts +13 -0
  41. package/dist/Batch/AuthenticaGetStockAvailable.js +36 -0
  42. package/dist/Connector/AuthenticaCreateOrder.d.ts +12 -0
  43. package/dist/Connector/AuthenticaCreateOrder.js +37 -0
  44. package/dist/Connector/AuthenticaCreateProduct.d.ts +12 -0
  45. package/dist/Connector/AuthenticaCreateProduct.js +37 -0
  46. package/dist/Connector/AuthenticaCreateReceipt.d.ts +11 -0
  47. package/dist/Connector/AuthenticaCreateReceipt.js +37 -0
  48. package/dist/Connector/AuthenticaGetCarriersConnector.d.ts +15 -0
  49. package/dist/Connector/AuthenticaGetCarriersConnector.js +23 -0
  50. package/dist/Connector/AuthenticaGetOrder.d.ts +14 -0
  51. package/dist/Connector/AuthenticaGetOrder.js +38 -0
  52. package/dist/Connector/AuthenticaGetOrderStatus.d.ts +11 -0
  53. package/dist/Connector/AuthenticaGetOrderStatus.js +20 -0
  54. package/dist/Connector/AuthenticaGetReceipt.d.ts +13 -0
  55. package/dist/Connector/AuthenticaGetReceipt.js +38 -0
  56. package/dist/Connector/AuthenticaGetShippingMethods.d.ts +14 -0
  57. package/dist/Connector/AuthenticaGetShippingMethods.js +20 -0
  58. package/dist/Connector/AuthenticaPostLabel.d.ts +12 -0
  59. package/dist/Connector/AuthenticaPostLabel.js +22 -0
  60. package/dist/Connector/AuthenticaPutOrders.d.ts +52 -0
  61. package/dist/Connector/AuthenticaPutOrders.js +22 -0
  62. package/dist/Connector/AuthenticaPutProducts.d.ts +24 -0
  63. package/dist/Connector/AuthenticaPutProducts.js +22 -0
  64. package/dist/Connector/AuthenticaUpdateOrder.d.ts +12 -0
  65. package/dist/Connector/AuthenticaUpdateOrder.js +39 -0
  66. package/dist/Connector/AuthenticaUpdateProduct.d.ts +12 -0
  67. package/dist/Connector/AuthenticaUpdateProduct.js +39 -0
  68. package/dist/Connector/AuthenticaUpdateReceipt.d.ts +9 -0
  69. package/dist/Connector/AuthenticaUpdateReceipt.js +22 -0
  70. package/dist/package.json +24 -0
  71. package/dist/types/order.d.ts +39 -0
  72. package/dist/types/order.js +2 -0
  73. package/dist/types/product.d.ts +20 -0
  74. package/dist/types/product.js +2 -0
  75. package/dist/types/receipt.d.ts +29 -0
  76. package/dist/types/receipt.js +1 -0
  77. package/jest.config.js +13 -0
  78. package/package.json +24 -0
  79. package/src/AuthenticaApplication.ts +137 -0
  80. package/src/Batch/AuthenticaGetStock.ts +77 -0
  81. package/src/Batch/AuthenticaGetStockAvailable.ts +59 -0
  82. package/src/Batch/__tests__/AuthenticaGetStock.ts +26 -0
  83. package/src/Batch/__tests__/AuthenticaGetStockAvailable.ts +22 -0
  84. package/src/Batch/__tests__/Data/AuthenticaGetStock/input.json +6 -0
  85. package/src/Batch/__tests__/Data/AuthenticaGetStock/mock.json +23 -0
  86. package/src/Batch/__tests__/Data/AuthenticaGetStock/nok-input.json +6 -0
  87. package/src/Batch/__tests__/Data/AuthenticaGetStock/nok-mock.json +20 -0
  88. package/src/Batch/__tests__/Data/AuthenticaGetStock/nok-output.json +13 -0
  89. package/src/Batch/__tests__/Data/AuthenticaGetStock/output.json +11 -0
  90. package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/1-mock.json +20 -0
  91. package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/input.json +6 -0
  92. package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/mock.json +21 -0
  93. package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/output.json +14 -0
  94. package/src/Batch/__tests__/Data/AuthenticaGetStockAvailable/output1.json +12 -0
  95. package/src/Connector/AuthenticaCreateOrder.ts +53 -0
  96. package/src/Connector/AuthenticaCreateProduct.ts +54 -0
  97. package/src/Connector/AuthenticaCreateReceipt.ts +53 -0
  98. package/src/Connector/AuthenticaGetCarriersConnector.ts +40 -0
  99. package/src/Connector/AuthenticaGetOrder.ts +58 -0
  100. package/src/Connector/AuthenticaGetOrderStatus.ts +38 -0
  101. package/src/Connector/AuthenticaGetReceipt.ts +58 -0
  102. package/src/Connector/AuthenticaGetShippingMethods.ts +41 -0
  103. package/src/Connector/AuthenticaPostLabel.ts +37 -0
  104. package/src/Connector/AuthenticaPutOrders.ts +83 -0
  105. package/src/Connector/AuthenticaPutProducts.ts +55 -0
  106. package/src/Connector/AuthenticaUpdateOrder.ts +57 -0
  107. package/src/Connector/AuthenticaUpdateProduct.ts +58 -0
  108. package/src/Connector/AuthenticaUpdateReceipt.ts +36 -0
  109. package/src/Connector/__tests__/AuthenticaCreateOrder.ts +22 -0
  110. package/src/Connector/__tests__/AuthenticaCreateProduct.ts +22 -0
  111. package/src/Connector/__tests__/AuthenticaCreateReceipt.ts +22 -0
  112. package/src/Connector/__tests__/AuthenticaGetCarriers.ts +22 -0
  113. package/src/Connector/__tests__/AuthenticaGetOrder.ts +22 -0
  114. package/src/Connector/__tests__/AuthenticaGetOrderStatus.ts +36 -0
  115. package/src/Connector/__tests__/AuthenticaGetReceipt.ts +22 -0
  116. package/src/Connector/__tests__/AuthenticaGetShippingMethods.ts +22 -0
  117. package/src/Connector/__tests__/AuthenticaPostLabel.ts +36 -0
  118. package/src/Connector/__tests__/AuthenticaPutOrders.ts +36 -0
  119. package/src/Connector/__tests__/AuthenticaPutProducts.ts +36 -0
  120. package/src/Connector/__tests__/AuthenticaUpdateOrder.ts +22 -0
  121. package/src/Connector/__tests__/AuthenticaUpdateProduct.ts +22 -0
  122. package/src/Connector/__tests__/AuthenticaUpdateReceipt.ts +22 -0
  123. package/src/Connector/__tests__/Data/AuthenticaCreateOrder/input.json +67 -0
  124. package/src/Connector/__tests__/Data/AuthenticaCreateOrder/mock.json +70 -0
  125. package/src/Connector/__tests__/Data/AuthenticaCreateOrder/output.json +71 -0
  126. package/src/Connector/__tests__/Data/AuthenticaCreateProduct/input.json +28 -0
  127. package/src/Connector/__tests__/Data/AuthenticaCreateProduct/mock.json +28 -0
  128. package/src/Connector/__tests__/Data/AuthenticaCreateProduct/output.json +29 -0
  129. package/src/Connector/__tests__/Data/AuthenticaCreateReceipt/input.json +47 -0
  130. package/src/Connector/__tests__/Data/AuthenticaCreateReceipt/mock.json +51 -0
  131. package/src/Connector/__tests__/Data/AuthenticaCreateReceipt/output.json +52 -0
  132. package/src/Connector/__tests__/Data/AuthenticaGetCarriers/input.json +6 -0
  133. package/src/Connector/__tests__/Data/AuthenticaGetCarriers/mock.json +18 -0
  134. package/src/Connector/__tests__/Data/AuthenticaGetCarriers/output.json +19 -0
  135. package/src/Connector/__tests__/Data/AuthenticaGetOrder/input.json +8 -0
  136. package/src/Connector/__tests__/Data/AuthenticaGetOrder/mock.json +63 -0
  137. package/src/Connector/__tests__/Data/AuthenticaGetOrder/output.json +64 -0
  138. package/src/Connector/__tests__/Data/AuthenticaGetOrderStatus/input.json +6 -0
  139. package/src/Connector/__tests__/Data/AuthenticaGetOrderStatus/mock.json +12 -0
  140. package/src/Connector/__tests__/Data/AuthenticaGetOrderStatus/output.json +11 -0
  141. package/src/Connector/__tests__/Data/AuthenticaGetReceipt/input.json +8 -0
  142. package/src/Connector/__tests__/Data/AuthenticaGetReceipt/mock.json +54 -0
  143. package/src/Connector/__tests__/Data/AuthenticaGetReceipt/output.json +55 -0
  144. package/src/Connector/__tests__/Data/AuthenticaGetShippingMethods/input.json +6 -0
  145. package/src/Connector/__tests__/Data/AuthenticaGetShippingMethods/mock.json +404 -0
  146. package/src/Connector/__tests__/Data/AuthenticaGetShippingMethods/output.json +403 -0
  147. package/src/Connector/__tests__/Data/AuthenticaPostLabel/input.json +10 -0
  148. package/src/Connector/__tests__/Data/AuthenticaPostLabel/mock.json +5 -0
  149. package/src/Connector/__tests__/Data/AuthenticaPostLabel/output.json +10 -0
  150. package/src/Connector/__tests__/Data/AuthenticaPutOrders/input.json +43 -0
  151. package/src/Connector/__tests__/Data/AuthenticaPutOrders/mock.json +44 -0
  152. package/src/Connector/__tests__/Data/AuthenticaPutOrders/output.json +43 -0
  153. package/src/Connector/__tests__/Data/AuthenticaPutProducts/input.json +19 -0
  154. package/src/Connector/__tests__/Data/AuthenticaPutProducts/mock.json +20 -0
  155. package/src/Connector/__tests__/Data/AuthenticaPutProducts/output.json +19 -0
  156. package/src/Connector/__tests__/Data/AuthenticaUpdateOrder/input.json +68 -0
  157. package/src/Connector/__tests__/Data/AuthenticaUpdateOrder/mock.json +70 -0
  158. package/src/Connector/__tests__/Data/AuthenticaUpdateOrder/output.json +71 -0
  159. package/src/Connector/__tests__/Data/AuthenticaUpdateProduct/input.json +32 -0
  160. package/src/Connector/__tests__/Data/AuthenticaUpdateProduct/mock.json +28 -0
  161. package/src/Connector/__tests__/Data/AuthenticaUpdateProduct/output.json +31 -0
  162. package/src/Connector/__tests__/Data/AuthenticaUpdateReceipt/input.json +45 -0
  163. package/src/Connector/__tests__/Data/AuthenticaUpdateReceipt/mock.json +51 -0
  164. package/src/Connector/__tests__/Data/AuthenticaUpdateReceipt/output.json +52 -0
  165. package/src/__tests__/AuthenticaApplication.ts +41 -0
  166. package/src/types/order.ts +40 -0
  167. package/src/types/product.ts +21 -0
  168. package/src/types/receipt.ts +30 -0
  169. package/test/dataProvider.ts +80 -0
  170. package/tsconfig.json +8 -0
  171. package/tsconfig.prod.json +13 -0
  172. package/tsconfig.prod.tsbuildinfo +1 -0
@@ -0,0 +1,77 @@
1
+ import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
2
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
+ import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
4
+ import ResultCode from '@orchesty/nodejs-sdk/dist/lib/Utils/ResultCode';
5
+ import { StatusCodes } from 'http-status-codes';
6
+
7
+ export const NAME = 'authentica-get-stock';
8
+
9
+ export default class AuthenticaGetStock extends ABatchNode {
10
+
11
+ public getName(): string {
12
+ return NAME;
13
+ }
14
+
15
+ public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
16
+ const page = dto.getBatchCursor('1');
17
+ const appInstall = await this.getApplicationInstallFromProcess(dto);
18
+ const req = await this.getApplication().getRequestDto(
19
+ dto,
20
+ appInstall,
21
+ HttpMethods.GET,
22
+ `applinth/stock?page=${page}&limit=50`,
23
+ );
24
+ const resp = await this.getSender().send<IResponse>(req, [200]);
25
+
26
+ if (resp.getResponseCode() === StatusCodes.NO_CONTENT) {
27
+ dto.setStopProcess(ResultCode.DO_NOT_CONTINUE, 'Empty body!');
28
+ return dto;
29
+ }
30
+
31
+ const response = resp.getJsonBody();
32
+
33
+ this.setItemsListToDto(dto, response.data ?? []);
34
+ if (response?.meta?.totalPages === undefined || response.meta.totalPages === null) {
35
+ dto.setStopProcess(ResultCode.STOP_AND_FAILED, 'Response not equal meta.totalPages');
36
+ return dto;
37
+ }
38
+
39
+ if (Number(page) < response.meta.totalPages) {
40
+ dto.setBatchCursor((Number(page) + 1).toString());
41
+ }
42
+
43
+ return dto;
44
+ }
45
+
46
+ protected setItemsListToDto(dto: BatchProcessDto, responseBody: IOutput[]): void {
47
+ dto.setItemList(responseBody);
48
+ }
49
+
50
+ }
51
+
52
+ interface IResponse {
53
+ data: IOutput[];
54
+ links: {
55
+ first: string;
56
+ last: string;
57
+ prev?: string | null;
58
+ next?: string | null;
59
+ };
60
+ meta: {
61
+ totalPages: number;
62
+ };
63
+ }
64
+
65
+ export interface IOutput {
66
+ sku: string;
67
+ productId: string;
68
+ timestamp: string;
69
+ event: EventEnum;
70
+ inStock?: string;
71
+ inStockDelta?: string;
72
+ }
73
+
74
+ export enum EventEnum {
75
+ AVAILABLE_STOCK_CHANGE = 'availableStockChange',
76
+ QUARANTINE_STOCK_CHANGE = 'quarantineStockChange',
77
+ }
@@ -0,0 +1,59 @@
1
+ import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
2
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
3
+ import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
4
+ import ResultCode from '@orchesty/nodejs-sdk/dist/lib/Utils/ResultCode';
5
+ import { StatusCodes } from 'http-status-codes';
6
+
7
+ export const NAME = 'authentica-get-stock-available';
8
+
9
+ export default class AuthenticaGetStockAvailable extends ABatchNode {
10
+
11
+ public getName(): string {
12
+ return NAME;
13
+ }
14
+
15
+ public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
16
+ const page = dto.getBatchCursor('1');
17
+ const appInstall = await this.getApplicationInstallFromProcess(dto);
18
+ const req = await this.getApplication().getRequestDto(
19
+ dto,
20
+ appInstall,
21
+ HttpMethods.GET,
22
+ `applinth/stock/available?page=${page}&limit=100`,
23
+ );
24
+ const resp = await this.getSender().send<IResponse>(req, [200]);
25
+
26
+ if (resp.getResponseCode() === StatusCodes.NO_CONTENT) {
27
+ dto.setStopProcess(ResultCode.DO_NOT_CONTINUE, 'Empty body!');
28
+ return dto;
29
+ }
30
+
31
+ const response = resp.getJsonBody();
32
+
33
+ this.setItemsListToDto(dto, response.data ?? []);
34
+
35
+ if (Number(page) < response.meta.totalPages) {
36
+ dto.setBatchCursor((Number(page) + 1).toString());
37
+ }
38
+
39
+ return dto;
40
+ }
41
+
42
+ protected setItemsListToDto(dto: BatchProcessDto, responseBody: IOutput[]): void {
43
+ dto.setItemList(responseBody);
44
+ }
45
+
46
+ }
47
+
48
+ interface IResponse {
49
+ data: IOutput[];
50
+ meta: {
51
+ totalPages: number;
52
+ };
53
+ }
54
+
55
+ export interface IOutput {
56
+ sku: string;
57
+ productId: string;
58
+ inStock: number;
59
+ }
@@ -0,0 +1,26 @@
1
+ import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
2
+ import Redis from '@orchesty/nodejs-sdk/dist/lib/Storage/Redis/Redis';
3
+ import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
4
+ import { initAuthenticaTest } from '../../../test/dataProvider';
5
+ import { NAME as AUTHENTICA_GET_STOCK } from '../AuthenticaGetStock';
6
+
7
+ let tester: NodeTester;
8
+
9
+ describe('Tests for AuthenticaGetStock', () => {
10
+ beforeAll(async () => {
11
+ tester = new NodeTester(container, __filename);
12
+ await initAuthenticaTest();
13
+ });
14
+
15
+ afterAll(async () => {
16
+ await container.get(Redis).close();
17
+ });
18
+
19
+ it('process - ok', async () => {
20
+ await tester.testBatch(AUTHENTICA_GET_STOCK);
21
+ });
22
+
23
+ it('process - nok', async () => {
24
+ await tester.testBatch(AUTHENTICA_GET_STOCK, 'nok');
25
+ });
26
+ });
@@ -0,0 +1,22 @@
1
+ import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
2
+ import Redis from '@orchesty/nodejs-sdk/dist/lib/Storage/Redis/Redis';
3
+ import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
4
+ import { initAuthenticaTest } from '../../../test/dataProvider';
5
+ import { NAME } from '../AuthenticaGetStockAvailable';
6
+
7
+ let tester: NodeTester;
8
+
9
+ describe('Test AuthenticaGetStockAvailable', () => {
10
+ beforeAll(async () => {
11
+ tester = new NodeTester(container, __filename);
12
+ await initAuthenticaTest();
13
+ });
14
+
15
+ afterAll(async () => {
16
+ await container.get(Redis).close();
17
+ });
18
+
19
+ it('process', async () => {
20
+ await tester.testBatch(NAME);
21
+ });
22
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {}
6
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "http": "GET https://app.authentica.cz/api/applinth/stock?page=1&limit=50",
3
+ "code": 200,
4
+ "body": {
5
+ "data": [
6
+ {
7
+ "sku": "01-006",
8
+ "inStock": "23",
9
+ "productId": "1",
10
+ "timestamp": "2023-01-25T00:00:00.000Z"
11
+ }
12
+ ],
13
+ "links": {
14
+ "first": "https://app.authentica.cz/api/applinth/stock?page=1&limit=100",
15
+ "last": "https://app.authentica.cz/api/applinth/stock?page=1&limit=100",
16
+ "prev": "https://app.authentica.cz/api/applinth/stock?page=1&limit=100",
17
+ "next": "https://app.authentica.cz/api/applinth/stock?page=1&limit=100"
18
+ },
19
+ "meta": {
20
+ "totalPages": 1
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {}
6
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "http": "GET https://app.authentica.cz/api/applinth/stock?page=1&limit=50",
3
+ "code": 200,
4
+ "body": {
5
+ "data": [
6
+ {
7
+ "sku": "01-006",
8
+ "inStock": "23",
9
+ "productId": "1",
10
+ "timestamp": "2023-01-25T00:00:00.000Z"
11
+ }
12
+ ],
13
+ "links": {
14
+ "first": "https://app.authentica.cz/api/applinth/stock?page=1&limit=100",
15
+ "last": "https://app.authentica.cz/api/applinth/stock?page=1&limit=100",
16
+ "prev": "https://app.authentica.cz/api/applinth/stock?page=1&limit=100",
17
+ "next": "https://app.authentica.cz/api/applinth/stock?page=1&limit=100"
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "headers": {
3
+ "result-code": "1006",
4
+ "result-message": "Response not equal meta.totalPages",
5
+ "user": "TestUser"
6
+ },
7
+ "data": [
8
+ {
9
+ "body": "{\"sku\":\"01-006\",\"inStock\":\"23\",\"productId\":\"1\",\"timestamp\":\"2023-01-25T00:00:00.000Z\"}",
10
+ "headers": {}
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": [
6
+ {
7
+ "body": "{\"sku\":\"01-006\",\"inStock\":\"23\",\"productId\":\"1\",\"timestamp\":\"2023-01-25T00:00:00.000Z\"}",
8
+ "headers": {}
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "http": "GET https://app.authentica.cz/api/applinth/stock/available?page=2&limit=100",
3
+ "code": 200,
4
+ "body": {
5
+ "data": [
6
+ {
7
+ "sku": "02-006",
8
+ "inStock": 3,
9
+ "productId": "2"
10
+ }
11
+ ],
12
+ "links": {
13
+ "first": "https://app.authentica.cz/api/applinth/stock/available?page=1&limit=100",
14
+ "last": "https://app.authentica.cz/api/applinth/stock/available?page=2&limit=100"
15
+ },
16
+ "meta": {
17
+ "totalPages": 2
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {}
6
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "http": "GET https://app.authentica.cz/api/applinth/stock/available?page=1&limit=100",
3
+ "code": 200,
4
+ "body": {
5
+ "data": [
6
+ {
7
+ "sku": "01-006",
8
+ "inStock": 23,
9
+ "productId": "1"
10
+ }
11
+ ],
12
+ "links": {
13
+ "first": "https://app.authentica.cz/api/applinth/stock/available?page=1&limit=100",
14
+ "last": "https://app.authentica.cz/api/applinth/stock/available?page=2&limit=100",
15
+ "next": "https://app.authentica.cz/api/applinth/stock/available?page=2&limit=100"
16
+ },
17
+ "meta": {
18
+ "totalPages": 2
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser",
4
+ "cursor": "2",
5
+ "result-code": "1010",
6
+ "result-message": "Message will be used as a iterator with cursor [2]. Data will be send to follower(s)."
7
+ },
8
+ "data": [
9
+ {
10
+ "body": "{\"sku\":\"01-006\",\"inStock\":23,\"productId\":\"1\"}",
11
+ "headers": {}
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser",
4
+ "cursor": "2"
5
+ },
6
+ "data": [
7
+ {
8
+ "body": "{\"sku\":\"02-006\",\"inStock\":3,\"productId\":\"2\"}",
9
+ "headers": {}
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,53 @@
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 { AuthenticaOrder } from '../types/order';
5
+
6
+ export const AUTHENTICA_CREATE_ORDER = 'authentica-create-order';
7
+
8
+ export default class AuthenticaCreateOrder extends AConnector {
9
+
10
+ public constructor(
11
+ protected dataKey: string | null = null,
12
+ ) {
13
+ super();
14
+ }
15
+
16
+ public getName(): string {
17
+ return AUTHENTICA_CREATE_ORDER;
18
+ }
19
+
20
+ public async processAction(
21
+ dto: ProcessDto<AuthenticaCreateOrderInput>,
22
+ ): Promise<ProcessDto<AuthenticaCreateOrderOutput>> {
23
+ let order = dto.getJsonData();
24
+ if (this.dataKey) {
25
+ // eslint-disable-next-line
26
+ order = (order as any)[this.dataKey];
27
+ }
28
+
29
+ const req = await this.getApplication().getRequestDto(
30
+ dto,
31
+ await this.getApplicationInstallFromProcess(dto),
32
+ HttpMethods.POST,
33
+ 'order',
34
+ order,
35
+ );
36
+
37
+ const resp = (await this.getSender().send<AuthenticaOrder>(req)).getJsonBody();
38
+ if (this.dataKey) {
39
+ // eslint-disable-next-line
40
+ const data = dto.getJsonData() as any;
41
+ data[this.dataKey] = resp;
42
+ dto.setNewJsonData(data);
43
+ } else {
44
+ dto.setNewJsonData(resp);
45
+ }
46
+
47
+ return dto as unknown as ProcessDto<AuthenticaCreateOrderOutput>;
48
+ }
49
+
50
+ }
51
+
52
+ export type AuthenticaCreateOrderInput = Omit<AuthenticaOrder, 'id' | 'status' | 'trackingNumbers' | 'trackingUrls'>;
53
+ export type AuthenticaCreateOrderOutput = AuthenticaOrder;
@@ -0,0 +1,54 @@
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 { AuthenticaProduct } from '../types/product';
5
+
6
+ export const AUTHENTICA_CREATE_PRODUCT = 'authentica-create-product';
7
+
8
+ export default class AuthenticaCreateProduct extends AConnector {
9
+
10
+ public constructor(
11
+ protected dataKey: string | null = null,
12
+ ) {
13
+ super();
14
+ }
15
+
16
+ public getName(): string {
17
+ return AUTHENTICA_CREATE_PRODUCT;
18
+ }
19
+
20
+ public async processAction(
21
+ dto: ProcessDto<AuthenticaCreateProductInput>,
22
+ ): Promise<ProcessDto<AuthenticaCreateProductOutput>> {
23
+ let product = dto.getJsonData();
24
+ if (this.dataKey) {
25
+ // eslint-disable-next-line
26
+ product = (product as any)[this.dataKey];
27
+ }
28
+
29
+ const req = await this.getApplication().getRequestDto(
30
+ dto,
31
+ await this.getApplicationInstallFromProcess(dto),
32
+ HttpMethods.POST,
33
+ 'product',
34
+ product,
35
+ );
36
+
37
+ const resp = (await this.getSender().send<AuthenticaProduct>(req)).getJsonBody();
38
+ if (this.dataKey) {
39
+ // eslint-disable-next-line
40
+ const data = dto.getJsonData() as any;
41
+ data[this.dataKey] = resp;
42
+ dto.setNewJsonData(data);
43
+ } else {
44
+ dto.setNewJsonData(resp);
45
+ }
46
+
47
+ return dto as unknown as ProcessDto<AuthenticaCreateProductOutput>;
48
+ }
49
+
50
+ }
51
+
52
+ export type AuthenticaCreateProductInput = Omit<AuthenticaProduct, 'id'>;
53
+
54
+ export type AuthenticaCreateProductOutput = AuthenticaProduct;
@@ -0,0 +1,53 @@
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 { AuthenticaOrder } from '../types/order';
5
+
6
+ export const AUTHENTICA_CREATE_RECEIPT = 'authentica-create-receipt';
7
+
8
+ export default class AuthenticaCreateReceipt extends AConnector {
9
+
10
+ public constructor(
11
+ protected dataKey: string | null = null,
12
+ ) {
13
+ super();
14
+ }
15
+
16
+ public getName(): string {
17
+ return AUTHENTICA_CREATE_RECEIPT;
18
+ }
19
+
20
+ public async processAction(
21
+ dto: ProcessDto<AuthenticaCreateReceiptInput>,
22
+ ): Promise<ProcessDto<AuthenticaCreateReceiptOutput>> {
23
+ let receipt = dto.getJsonData();
24
+ if (this.dataKey) {
25
+ // eslint-disable-next-line
26
+ receipt = (receipt as any)[this.dataKey];
27
+ }
28
+
29
+ const req = await this.getApplication().getRequestDto(
30
+ dto,
31
+ await this.getApplicationInstallFromProcess(dto),
32
+ HttpMethods.POST,
33
+ 'receipt',
34
+ receipt,
35
+ );
36
+
37
+ const resp = (await this.getSender().send<AuthenticaOrder>(req)).getJsonBody();
38
+ if (this.dataKey) {
39
+ // eslint-disable-next-line
40
+ const data = dto.getJsonData() as any;
41
+ data[this.dataKey] = resp;
42
+ dto.setNewJsonData(data);
43
+ } else {
44
+ dto.setNewJsonData(resp);
45
+ }
46
+
47
+ return dto as unknown as ProcessDto<AuthenticaCreateReceiptOutput>;
48
+ }
49
+
50
+ }
51
+
52
+ export type AuthenticaCreateReceiptInput = Omit<AuthenticaReceipt, 'id' | 'status' | 'trackingNumbers' | 'shipments'>;
53
+ export type AuthenticaCreateReceiptOutput = AuthenticaReceipt;
@@ -0,0 +1,40 @@
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 AUTHENTICA_GET_CARRIERS = 'authentica-get-carriers';
6
+
7
+ export class AuthenticaGetCarriers extends AConnector {
8
+
9
+ public getName(): string {
10
+ return AUTHENTICA_GET_CARRIERS;
11
+ }
12
+
13
+ public async processAction(dto: ProcessDto): Promise<ProcessDto<AuthenticaGetCarriersOutput>> {
14
+ const req = await this.getApplication().getRequestDto(
15
+ dto,
16
+ await this.getApplicationInstallFromProcess(dto),
17
+ HttpMethods.GET,
18
+ 'carrier',
19
+ );
20
+ const resp = (await this.getSender().send<Response>(req, [200])).getJsonBody();
21
+ await this.processItems(dto, resp);
22
+
23
+ return dto.setNewJsonData(resp);
24
+ }
25
+
26
+ protected async processItems(_dto: ProcessDto, _items: AuthenticaCarrier[]): Promise<void> {
27
+ }
28
+
29
+ }
30
+
31
+ export interface AuthenticaCarrier {
32
+ id: number;
33
+ name: string;
34
+ branchSupported: boolean;
35
+ branchRequired: boolean;
36
+ }
37
+
38
+ type Response = AuthenticaCarrier[];
39
+
40
+ export type AuthenticaGetCarriersOutput = AuthenticaCarrier[];
@@ -0,0 +1,58 @@
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 { AuthenticaOrder } from '../types/order';
5
+
6
+ export const AUTHENTICA_GET_ORDER = 'authentica-get-order';
7
+
8
+ export default class AuthenticaGetOrder extends AConnector {
9
+
10
+ public constructor(
11
+ protected dataKey: string | null = null,
12
+ ) {
13
+ super();
14
+ }
15
+
16
+ public getName(): string {
17
+ return AUTHENTICA_GET_ORDER;
18
+ }
19
+
20
+ public async processAction(
21
+ dto: ProcessDto<AuthenticaGetOrderInput>,
22
+ ): Promise<ProcessDto<AuthenticaGetOrderOutput>> {
23
+ const data = dto.getJsonData();
24
+ // eslint-disable-next-line
25
+ let id = data.id;
26
+ if (this.dataKey) {
27
+ // eslint-disable-next-line
28
+ id = (data as any)[this.dataKey].id;
29
+ }
30
+
31
+ const req = await this.getApplication().getRequestDto(
32
+ dto,
33
+ await this.getApplicationInstallFromProcess(dto),
34
+ HttpMethods.GET,
35
+ `order/${id}`,
36
+ );
37
+
38
+ const resp = (await this.getSender().send<AuthenticaOrder>(req)).getJsonBody();
39
+
40
+ if (this.dataKey) {
41
+ // eslint-disable-next-line
42
+ const data = dto.getJsonData() as any;
43
+ data[this.dataKey] = resp;
44
+ dto.setNewJsonData(data);
45
+ } else {
46
+ dto.setNewJsonData(resp);
47
+ }
48
+
49
+ return dto as unknown as ProcessDto<AuthenticaGetOrderOutput>;
50
+ }
51
+
52
+ }
53
+
54
+ export interface AuthenticaGetOrderInput {
55
+ id: number;
56
+ }
57
+
58
+ export type AuthenticaGetOrderOutput = AuthenticaOrder;
@@ -0,0 +1,38 @@
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 = 'authentica-get-order-status';
6
+
7
+ export default class AuthenticaGetOrderStatus extends AConnector {
8
+
9
+ public getName(): string {
10
+ return NAME;
11
+ }
12
+
13
+ public async processAction(dto: ProcessDto): Promise<ProcessDto<IOutputItem[]>> {
14
+ const requestDto = await this.getApplication().getRequestDto(
15
+ dto,
16
+ await this.getApplicationInstallFromProcess(dto),
17
+ HttpMethods.GET,
18
+ 'applinth/order-statuses',
19
+ );
20
+
21
+ const response = (await this.getSender().send<IResponse>(
22
+ requestDto.setTimeout(5000),
23
+ [200],
24
+ )).getJsonBody();
25
+
26
+ return dto.setNewJsonData(response.data);
27
+ }
28
+
29
+ }
30
+
31
+ export interface IOutputItem {
32
+ id: string;
33
+ title: string;
34
+ }
35
+
36
+ interface IResponse {
37
+ data: IOutputItem[];
38
+ }