@orchesty/connector-fapi 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 (99) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +190 -0
  3. package/coverage/clover.xml +234 -0
  4. package/coverage/coverage-final.json +12 -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/Batch/AFapiListBatch.ts.html +373 -0
  14. package/coverage/lcov-report/src/Batch/FapiGetItemTemplateListBatch.ts.html +295 -0
  15. package/coverage/lcov-report/src/Batch/FapiGetLabelListBatch.ts.html +154 -0
  16. package/coverage/lcov-report/src/Batch/FapiGetProjectListBatch.ts.html +211 -0
  17. package/coverage/lcov-report/src/Batch/FapiGetShippingMethodListBatch.ts.html +238 -0
  18. package/coverage/lcov-report/src/Batch/FapiSubscribeWebhooksBatch.ts.html +364 -0
  19. package/coverage/lcov-report/src/Batch/FapiUnsubscribeWebhooksBatch.ts.html +247 -0
  20. package/coverage/lcov-report/src/Batch/index.html +206 -0
  21. package/coverage/lcov-report/src/Connector/FapiGetInvoiceConnector.ts.html +652 -0
  22. package/coverage/lcov-report/src/Connector/FapiPostInvoiceLabelConnector.ts.html +229 -0
  23. package/coverage/lcov-report/src/Connector/index.html +131 -0
  24. package/coverage/lcov-report/src/FapiApplication.ts.html +394 -0
  25. package/coverage/lcov-report/src/index.html +116 -0
  26. package/coverage/lcov-report/test/dataProvider.ts.html +187 -0
  27. package/coverage/lcov-report/test/index.html +116 -0
  28. package/coverage/lcov.info +380 -0
  29. package/dist/Batch/AFapiListBatch.d.ts +12 -0
  30. package/dist/Batch/AFapiListBatch.js +68 -0
  31. package/dist/Batch/FapiGetItemTemplateListBatch.d.ts +57 -0
  32. package/dist/Batch/FapiGetItemTemplateListBatch.js +18 -0
  33. package/dist/Batch/FapiGetLabelListBatch.d.ts +12 -0
  34. package/dist/Batch/FapiGetLabelListBatch.js +18 -0
  35. package/dist/Batch/FapiGetProjectListBatch.d.ts +29 -0
  36. package/dist/Batch/FapiGetProjectListBatch.js +18 -0
  37. package/dist/Batch/FapiGetShippingMethodListBatch.d.ts +38 -0
  38. package/dist/Batch/FapiGetShippingMethodListBatch.js +18 -0
  39. package/dist/Batch/FapiSubscribeWebhooksBatch.d.ts +7 -0
  40. package/dist/Batch/FapiSubscribeWebhooksBatch.js +62 -0
  41. package/dist/Batch/FapiUnsubscribeWebhooksBatch.d.ts +7 -0
  42. package/dist/Batch/FapiUnsubscribeWebhooksBatch.js +41 -0
  43. package/dist/Connector/FapiGetInvoiceConnector.d.ts +159 -0
  44. package/dist/Connector/FapiGetInvoiceConnector.js +26 -0
  45. package/dist/Connector/FapiPostInvoiceLabelConnector.d.ts +17 -0
  46. package/dist/Connector/FapiPostInvoiceLabelConnector.js +28 -0
  47. package/dist/FapiApplication.d.ts +24 -0
  48. package/dist/FapiApplication.js +99 -0
  49. package/dist/package.json +28 -0
  50. package/jest.config.js +13 -0
  51. package/package.json +28 -0
  52. package/src/Batch/AFapiListBatch.ts +96 -0
  53. package/src/Batch/FapiGetItemTemplateListBatch.ts +70 -0
  54. package/src/Batch/FapiGetLabelListBatch.ts +23 -0
  55. package/src/Batch/FapiGetProjectListBatch.ts +42 -0
  56. package/src/Batch/FapiGetShippingMethodListBatch.ts +51 -0
  57. package/src/Batch/FapiSubscribeWebhooksBatch.ts +93 -0
  58. package/src/Batch/FapiUnsubscribeWebhooksBatch.ts +54 -0
  59. package/src/Batch/__tests__/Data/FapiGetItemTemplateListBatch/input.json +7 -0
  60. package/src/Batch/__tests__/Data/FapiGetItemTemplateListBatch/mock.json +55 -0
  61. package/src/Batch/__tests__/Data/FapiGetItemTemplateListBatch/output.json +11 -0
  62. package/src/Batch/__tests__/Data/FapiGetLabelListBatch/input.json +7 -0
  63. package/src/Batch/__tests__/Data/FapiGetLabelListBatch/mock.json +14 -0
  64. package/src/Batch/__tests__/Data/FapiGetLabelListBatch/output.json +11 -0
  65. package/src/Batch/__tests__/Data/FapiGetProjectListBatch/input.json +7 -0
  66. package/src/Batch/__tests__/Data/FapiGetProjectListBatch/mock.json +26 -0
  67. package/src/Batch/__tests__/Data/FapiGetProjectListBatch/output.json +11 -0
  68. package/src/Batch/__tests__/Data/FapiGetShippingMethodListBatch/input.json +7 -0
  69. package/src/Batch/__tests__/Data/FapiGetShippingMethodListBatch/mock.json +31 -0
  70. package/src/Batch/__tests__/Data/FapiGetShippingMethodListBatch/output.json +11 -0
  71. package/src/Batch/__tests__/Data/FapiSubscribeWebhooksBatch/input.json +7 -0
  72. package/src/Batch/__tests__/Data/FapiSubscribeWebhooksBatch/mock.json +17 -0
  73. package/src/Batch/__tests__/Data/FapiSubscribeWebhooksBatch/output.json +6 -0
  74. package/src/Batch/__tests__/Data/FapiUnsubscribeWebhooksBatch/1-mock.json +5 -0
  75. package/src/Batch/__tests__/Data/FapiUnsubscribeWebhooksBatch/input.json +7 -0
  76. package/src/Batch/__tests__/Data/FapiUnsubscribeWebhooksBatch/mock.json +5 -0
  77. package/src/Batch/__tests__/Data/FapiUnsubscribeWebhooksBatch/output.json +9 -0
  78. package/src/Batch/__tests__/Data/FapiUnsubscribeWebhooksBatch/output1.json +7 -0
  79. package/src/Batch/__tests__/FapiGetItemTemplateListBatch.ts +17 -0
  80. package/src/Batch/__tests__/FapiGetLabelListBatch.ts +17 -0
  81. package/src/Batch/__tests__/FapiGetProjectListBatch.ts +17 -0
  82. package/src/Batch/__tests__/FapiGetShippingMethodListBatch.ts +17 -0
  83. package/src/Batch/__tests__/FapiSubscribeWebhooksBatch.ts +45 -0
  84. package/src/Batch/__tests__/FapiUnsubscribeWebhooksBatch.ts +57 -0
  85. package/src/Connector/FapiGetInvoiceConnector.ts +189 -0
  86. package/src/Connector/FapiPostInvoiceLabelConnector.ts +48 -0
  87. package/src/Connector/__tests__/Data/FapiGetInvoiceConnector/input.json +8 -0
  88. package/src/Connector/__tests__/Data/FapiGetInvoiceConnector/mock.json +223 -0
  89. package/src/Connector/__tests__/Data/FapiGetInvoiceConnector/output.json +224 -0
  90. package/src/Connector/__tests__/Data/FapiPostInvoiceLabelConnector/input.json +11 -0
  91. package/src/Connector/__tests__/Data/FapiPostInvoiceLabelConnector/mock.json +12 -0
  92. package/src/Connector/__tests__/Data/FapiPostInvoiceLabelConnector/output.json +13 -0
  93. package/src/Connector/__tests__/FapiGetInvoiceConnector.ts +17 -0
  94. package/src/Connector/__tests__/FapiPostInvoiceLabelConnector.ts +17 -0
  95. package/src/FapiApplication.ts +103 -0
  96. package/test/dataProvider.ts +34 -0
  97. package/tsconfig.json +8 -0
  98. package/tsconfig.prod.json +13 -0
  99. package/tsconfig.prod.tsbuildinfo +1 -0
@@ -0,0 +1,11 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": [
6
+ {
7
+ "body": "{\"id\":12,\"hidden\":false,\"name\":\"test\",\"code\":\"12\",\"accounting_code\":null,\"description\":null,\"price_czk\":1066,\"price_eur\":39.42,\"price_usd\":null,\"repayment_amount_czk\":1500,\"repayment_amount_eur\":null,\"repayment_amount_usd\":null,\"prices\":[{\"type\":\"one_time\",\"price\":1066,\"currency_code\":\"CZK\"},{\"type\":\"one_time\",\"price\":39.42,\"currency_code\":\"EUR\"},{\"type\":\"repayment\",\"price\":1500,\"currency_code\":\"CZK\"}],\"vat\":0,\"including_vat\":false,\"count\":1,\"allow_change_count\":false,\"enable_stock\":false,\"stock\":0,\"show_stock_information\":false,\"type\":\"electronic-service\",\"pohoda_accounting\":null,\"pohoda_centre\":null,\"pohoda_store\":null,\"pohoda_stock_item\":null,\"mioweb_eshop\":false,\"mioweb_eshop_url\":null,\"disable_discount\":false,\"user\":3}",
8
+ "headers": {}
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ }
7
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "http": "GET https://api.fapi.cz/labels?limit=1000&offset=0",
3
+ "code": 200,
4
+ "body": {
5
+ "labels": [
6
+ {
7
+ "id": 1,
8
+ "user_id": 3,
9
+ "name": "štítek 1",
10
+ "color": "#A83232"
11
+ }
12
+ ]
13
+ }
14
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": [
6
+ {
7
+ "body": "{\"id\":1,\"user_id\":3,\"name\":\"štítek 1\",\"color\":\"#A83232\"}",
8
+ "headers": {}
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ }
7
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "http": "GET https://api.fapi.cz/projects?limit=1000&offset=0",
3
+ "code": 200,
4
+ "body": {
5
+ "projects": [
6
+ {
7
+ "id": 5864,
8
+ "hidden": false,
9
+ "name": "A - Test",
10
+ "code": "AT",
11
+ "email": null,
12
+ "is_default": false,
13
+ "has_different_logo": true,
14
+ "logo": 529,
15
+ "has_different_signature": false,
16
+ "signature": null,
17
+ "has_different_bank_account_set": false,
18
+ "bank_account_set": null,
19
+ "has_different_sender": false,
20
+ "sender_email": null,
21
+ "sender_name": null,
22
+ "sender_reply_to": null
23
+ }
24
+ ]
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": [
6
+ {
7
+ "body": "{\"id\":5864,\"hidden\":false,\"name\":\"A - Test\",\"code\":\"AT\",\"email\":null,\"is_default\":false,\"has_different_logo\":true,\"logo\":529,\"has_different_signature\":false,\"signature\":null,\"has_different_bank_account_set\":false,\"bank_account_set\":null,\"has_different_sender\":false,\"sender_email\":null,\"sender_name\":null,\"sender_reply_to\":null}",
8
+ "headers": {}
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ }
7
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "http": "GET https://api.fapi.cz/shipping-methods?limit=1000&offset=0",
3
+ "code": 200,
4
+ "body": {
5
+ "shipping_methods": [
6
+ {
7
+ "id": 1,
8
+ "user_id": 3,
9
+ "name": "Moje odběrové místo",
10
+ "type": "personal_collection",
11
+ "subtype": null,
12
+ "address_prices": [
13
+ {
14
+ "address": {
15
+ "simple_address": "test adresa"
16
+ },
17
+ "prices": [
18
+ {
19
+ "currency_code": "CZK",
20
+ "price": 100
21
+ }
22
+ ]
23
+ }
24
+ ],
25
+ "meta_data": null,
26
+ "including_vat": false,
27
+ "description": null
28
+ }
29
+ ]
30
+ }
31
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": [
6
+ {
7
+ "body": "{\"id\":1,\"user_id\":3,\"name\":\"Moje odběrové místo\",\"type\":\"personal_collection\",\"subtype\":null,\"address_prices\":[{\"address\":{\"simple_address\":\"test adresa\"},\"prices\":[{\"currency_code\":\"CZK\",\"price\":100}]}],\"meta_data\":null,\"including_vat\":false,\"description\":null}",
8
+ "headers": {}
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ }
7
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "http": "POST https://api.fapi.cz/connections",
3
+ "code": 200,
4
+ "body": {
5
+ "id": 35,
6
+ "user_id": 3,
7
+ "application": "global-webhook",
8
+ "credentials": {
9
+ "url": "https://test.cz/",
10
+ "event": "ordered"
11
+ },
12
+ "fields_mapping": [],
13
+ "meta_data": {
14
+ "description": "Webhook test"
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": []
6
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "http": "DELETE https://api.fapi.cz/connections/webhookId",
3
+ "code": 200,
4
+ "body": {}
5
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ }
7
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "http": "DELETE https://api.fapi.cz/connections/webhookId",
3
+ "code": 200,
4
+ "body": {}
5
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser",
4
+ "cursor": "1",
5
+ "result-code": "1011",
6
+ "result-message": "Message will be used as a iterator with cursor [1]. No follower will be called."
7
+ },
8
+ "data": []
9
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser",
4
+ "cursor": "1"
5
+ },
6
+ "data": []
7
+ }
@@ -0,0 +1,17 @@
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 FAPI_GET_ITEM_TEMPLATE_LIST_BATCH } from '../FapiGetItemTemplateListBatch';
5
+
6
+ let tester: NodeTester;
7
+
8
+ describe('Tests for FapiGetItemTemplateListBatch', () => {
9
+ beforeEach(() => {
10
+ tester = new NodeTester(container, __filename);
11
+ init();
12
+ });
13
+
14
+ it('process - ok', async () => {
15
+ await tester.testBatch(FAPI_GET_ITEM_TEMPLATE_LIST_BATCH);
16
+ });
17
+ });
@@ -0,0 +1,17 @@
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 FAPI_GET_LABEL_LIST_BATCH } from '../FapiGetLabelListBatch';
5
+
6
+ let tester: NodeTester;
7
+
8
+ describe('Tests for FapiGetLabelListBatch', () => {
9
+ beforeEach(() => {
10
+ tester = new NodeTester(container, __filename);
11
+ init();
12
+ });
13
+
14
+ it('process - ok', async () => {
15
+ await tester.testBatch(FAPI_GET_LABEL_LIST_BATCH);
16
+ });
17
+ });
@@ -0,0 +1,17 @@
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 FAPI_GET_PROJECT_LIST_BATCH } from '../FapiGetProjectListBatch';
5
+
6
+ let tester: NodeTester;
7
+
8
+ describe('Tests for FapiGetProjectListBatch', () => {
9
+ beforeEach(() => {
10
+ tester = new NodeTester(container, __filename);
11
+ init();
12
+ });
13
+
14
+ it('process - ok', async () => {
15
+ await tester.testBatch(FAPI_GET_PROJECT_LIST_BATCH);
16
+ });
17
+ });
@@ -0,0 +1,17 @@
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 FAPI_GET_SHIPPING_METHOD_LIST_BATCH } from '../FapiGetShippingMethodListBatch';
5
+
6
+ let tester: NodeTester;
7
+
8
+ describe('Tests for FapiGetShippingMethodListBatch', () => {
9
+ beforeEach(() => {
10
+ tester = new NodeTester(container, __filename);
11
+ init();
12
+ });
13
+
14
+ it('process - ok', async () => {
15
+ await tester.testBatch(FAPI_GET_SHIPPING_METHOD_LIST_BATCH);
16
+ });
17
+ });
@@ -0,0 +1,45 @@
1
+ import { DEFAULT_USER } from '@orchesty/nodejs-connectors/test/DataProvider';
2
+ import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
3
+ import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
4
+ import { orchestyOptions } from '@orchesty/nodejs-sdk/dist/lib/Config/Config';
5
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
6
+ import { mockOnce } from '@orchesty/nodejs-sdk/dist/test/MockServer';
7
+ import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
8
+ import init from '../../../test/dataProvider';
9
+ import { NAME as FAPI_APPLICATION } from '../../FapiApplication';
10
+ import { NAME as FAPI_SUBSCRIBE_WEBHOOKS_BATCH } from '../FapiSubscribeWebhooksBatch';
11
+
12
+ let tester: NodeTester;
13
+
14
+ describe('Tests for FapiSubscribeWebhooksBatch', () => {
15
+ beforeEach(() => {
16
+ tester = new NodeTester(container, __filename);
17
+ init();
18
+
19
+ const webhook = new Webhook()
20
+ .setApplication(FAPI_APPLICATION)
21
+ .setName('name')
22
+ .setNode('node')
23
+ .setToken('token')
24
+ .setTopology('topology')
25
+ .setUnsubscribeFailed(false)
26
+ .setUser(DEFAULT_USER)
27
+ .setWebhookId('webhookdId');
28
+
29
+ mockOnce([
30
+ {
31
+ request: {
32
+ method: HttpMethods.GET, url: new RegExp(`${orchestyOptions.workerApi}\\/document\\/Webhook.*`),
33
+ },
34
+ response: {
35
+ code: 200,
36
+ body: [{ ...webhook.toArray() }],
37
+ },
38
+ },
39
+ ]);
40
+ });
41
+
42
+ it('process - ok', async () => {
43
+ await tester.testBatch(FAPI_SUBSCRIBE_WEBHOOKS_BATCH);
44
+ });
45
+ });
@@ -0,0 +1,57 @@
1
+ import { DEFAULT_USER } from '@orchesty/nodejs-connectors/test/DataProvider';
2
+ import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
3
+ import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
4
+ import { orchestyOptions } from '@orchesty/nodejs-sdk/dist/lib/Config/Config';
5
+ import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
6
+ import { mockOnce } from '@orchesty/nodejs-sdk/dist/test/MockServer';
7
+ import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
8
+ import init from '../../../test/dataProvider';
9
+ import { NAME as FAPI_APPLICATION } from '../../FapiApplication';
10
+ import { NAME as FAPI_UNSUBSCRIBE_WEBHOOKS_BATCH } from '../FapiUnsubscribeWebhooksBatch';
11
+
12
+ let tester: NodeTester;
13
+
14
+ describe('Tests for FapiUnsubscribeWebhooksBatch', () => {
15
+ beforeEach(() => {
16
+ tester = new NodeTester(container, __filename);
17
+ init();
18
+
19
+ const webhook = new Webhook()
20
+ .setApplication(FAPI_APPLICATION)
21
+ .setName('name')
22
+ .setNode('node')
23
+ .setToken('token')
24
+ .setTopology('topology')
25
+ .setUnsubscribeFailed(false)
26
+ .setUser(DEFAULT_USER)
27
+ .setWebhookId('webhookId');
28
+
29
+ mockOnce([
30
+ {
31
+ request: {
32
+ method: HttpMethods.GET, url: new RegExp(`${orchestyOptions.workerApi}\\/document\\/Webhook.*`),
33
+ },
34
+ response: {
35
+ code: 200,
36
+ body: [{ ...webhook.toArray() }],
37
+ },
38
+ },
39
+ ]);
40
+
41
+ mockOnce([
42
+ {
43
+ request: {
44
+ method: HttpMethods.GET, url: new RegExp(`${orchestyOptions.workerApi}\\/document\\/Webhook.*`),
45
+ },
46
+ response: {
47
+ code: 200,
48
+ body: [],
49
+ },
50
+ },
51
+ ]);
52
+ });
53
+
54
+ it('process - ok', async () => {
55
+ await tester.testBatch(FAPI_UNSUBSCRIBE_WEBHOOKS_BATCH);
56
+ });
57
+ });
@@ -0,0 +1,189 @@
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 { StatusCodes } from 'http-status-codes';
5
+ import { getErrorInResponse, NAME as APPLICATION_NAME } from '../FapiApplication';
6
+
7
+ export const NAME = `${APPLICATION_NAME}-get-invoice-connector`;
8
+
9
+ export default class FapiGetInvoiceConnector extends AConnector {
10
+
11
+ public getName(): string {
12
+ return NAME;
13
+ }
14
+
15
+ public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
16
+ const { id } = dto.getJsonData();
17
+
18
+ const requestDto = await this.getApplication().getRequestDto(
19
+ dto,
20
+ await this.getApplicationInstallFromProcess(dto),
21
+ HttpMethods.GET,
22
+ `invoices/${id}`,
23
+ );
24
+
25
+ const responseDto = await this.getSender().send<IOutput>(requestDto, {
26
+ success: StatusCodes.OK,
27
+ stopAndFail: StatusCodes.NOT_FOUND,
28
+ }, undefined, undefined, getErrorInResponse);
29
+
30
+ return dto.setNewJsonData(responseDto.getJsonBody());
31
+ }
32
+
33
+ }
34
+
35
+ export interface IInput {
36
+ id: number;
37
+ }
38
+
39
+ export interface IOutput {
40
+ /* eslint-disable @typescript-eslint/naming-convention */
41
+ id: number;
42
+ number: string;
43
+ created_on: string;
44
+ last_modified_on: string;
45
+ create_date: string;
46
+ automatic_charge_date: string;
47
+ payday_date: string;
48
+ client: number;
49
+ type: string;
50
+ payment_type: string;
51
+ currency: string;
52
+ exchange_rate_czk: string;
53
+ exchange_rate: string;
54
+ language: string;
55
+ paid: boolean;
56
+ cancelled: boolean;
57
+ cancellation_reason: string;
58
+ reverse_charge: boolean;
59
+ tax_exempt: boolean;
60
+ round_function: string;
61
+ round_precision: number;
62
+ vat_recapitulation_algorithm: string;
63
+ payment_confirmation_mode: string;
64
+ preserve_vat_date_on_invoice: boolean;
65
+ has_credit_note: boolean;
66
+ create_invoice_automatically: boolean;
67
+ create_payment_confirmation: boolean;
68
+ create_simplified_invoice: boolean;
69
+ path: string;
70
+ recurring_gopay_payment_id: string;
71
+ campaign_code: string;
72
+ periodic_invoice: string;
73
+ periodic_invoice_number: string;
74
+ locked: boolean;
75
+ proforma: boolean;
76
+ payment_confirmation: boolean;
77
+ simplified_invoice: boolean;
78
+ credit_note: boolean;
79
+ show_vat_info: boolean;
80
+ shipping_method_id: number;
81
+ shipping_metadata: {
82
+ packatery_branch_name: string;
83
+ packatery_branch_id: number;
84
+ } | null;
85
+ paid_on: string;
86
+ variable_symbol: string;
87
+ vat_date: string;
88
+ supplier: {
89
+ name: string;
90
+ ic: string;
91
+ dic: string;
92
+ ic_dph: string;
93
+ swift: string;
94
+ iban: string;
95
+ bank_account: string;
96
+ address: {
97
+ street: string;
98
+ city: string;
99
+ zip: string;
100
+ country: string;
101
+ };
102
+ };
103
+ customer: {
104
+ name: string;
105
+ first_name: string;
106
+ last_name: string;
107
+ email: string;
108
+ phone: string;
109
+ address: {
110
+ street: string;
111
+ city: string;
112
+ zip: string;
113
+ country: string;
114
+ };
115
+ shipping_address: {
116
+ name: string;
117
+ surname: string;
118
+ street: string;
119
+ city: string;
120
+ zip: string;
121
+ country: string;
122
+ } | null;
123
+ };
124
+ form: number;
125
+ items: {
126
+ id: number;
127
+ invoice: number;
128
+ name: string;
129
+ code: string;
130
+ accounting_code: string;
131
+ price: number;
132
+ count: number;
133
+ round_item: boolean;
134
+ correction_item: boolean;
135
+ type: string;
136
+ moss: boolean;
137
+ pohoda_accounting: string;
138
+ pohoda_centre: string;
139
+ pohoda_store: string;
140
+ pohoda_stock_item: string;
141
+ vat: number;
142
+ including_vat: boolean;
143
+ }[];
144
+ custom_fields: {
145
+ invoice_custom_fields_data_id: number;
146
+ custom_field_id: number;
147
+ value: string;
148
+ name: string;
149
+ type: string;
150
+ }[];
151
+ shipping_method: {
152
+ id: number;
153
+ user_id: number;
154
+ name: string;
155
+ type: string;
156
+ subtype: string;
157
+ address_prices: {
158
+ address: {
159
+ country_code: string;
160
+ };
161
+ prices: {
162
+ currency_code: string;
163
+ price: number;
164
+ }[];
165
+ }[];
166
+ free_of_charges: string;
167
+ meta_data: string;
168
+ including_vat: number;
169
+ description: string;
170
+ disable_discount: number;
171
+ deleted: number;
172
+ };
173
+ total: number;
174
+ total_vat: number;
175
+ total_czk: number;
176
+ total_vat_czk: number;
177
+ total_native: number;
178
+ total_vat_native: number;
179
+ user: number;
180
+ form_url: string;
181
+ session_id: string;
182
+ labels: {
183
+ id: number;
184
+ name: string;
185
+ color: string;
186
+ }[];
187
+ parent?: string;
188
+ /* eslint-enable @typescript-eslint/naming-convention */
189
+ }
@@ -0,0 +1,48 @@
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 { StatusCodes } from 'http-status-codes';
5
+ import { getErrorInResponse, NAME as APPLICATION_NAME } from '../FapiApplication';
6
+
7
+ export const NAME = `${APPLICATION_NAME}-post-invoice-label-connector`;
8
+
9
+ export default class FapiPostInvoiceLabelConnector extends AConnector {
10
+
11
+ public getName(): string {
12
+ return NAME;
13
+ }
14
+
15
+ public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
16
+ const { id, labels } = dto.getJsonData();
17
+
18
+ const requestDto = await this.getApplication().getRequestDto(
19
+ dto,
20
+ await this.getApplicationInstallFromProcess(dto),
21
+ HttpMethods.POST,
22
+ `invoice-labels/${id}`,
23
+ {
24
+ labels,
25
+ },
26
+ );
27
+
28
+ const responseDto = await this.getSender().send<IOutput>(requestDto, {
29
+ success: StatusCodes.OK,
30
+ stopAndFail: [StatusCodes.BAD_REQUEST, StatusCodes.NOT_FOUND],
31
+ }, undefined, undefined, getErrorInResponse);
32
+
33
+ return dto.setNewJsonData(responseDto.getJsonBody());
34
+ }
35
+
36
+ }
37
+
38
+ export interface IInput {
39
+ id: number;
40
+ labels: string[];
41
+ }
42
+
43
+ export interface IOutput {
44
+ status: string;
45
+ message: string;
46
+ invoice_id: number,
47
+ labels: number[];
48
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ "id": 1
7
+ }
8
+ }