@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.
- package/README.md +95 -0
- package/dist/Batch/UpgatesCreateWebhooks.js +1 -0
- package/dist/Connector/UpgatesDeleteWebhooks.js +5 -1
- package/dist/package.json +5 -2
- package/package.json +5 -2
- package/CHANGELOG.md +0 -7
- package/coverage/clover.xml +0 -302
- package/coverage/coverage-final.json +0 -11
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -161
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/src/Batch/UpgatesCreateWebhooks.ts.html +0 -358
- package/coverage/lcov-report/src/Batch/UpgatesGetOrders.ts.html +0 -727
- package/coverage/lcov-report/src/Batch/UpgatesGetProducts.ts.html +0 -733
- package/coverage/lcov-report/src/Batch/index.html +0 -146
- package/coverage/lcov-report/src/Connector/UpgatesDeleteWebhooks.ts.html +0 -370
- package/coverage/lcov-report/src/Connector/UpgatesGetOrderStates.ts.html +0 -190
- package/coverage/lcov-report/src/Connector/UpgatesGetPayments.ts.html +0 -268
- package/coverage/lcov-report/src/Connector/UpgatesGetProductParameters.ts.html +0 -316
- package/coverage/lcov-report/src/Connector/UpgatesGetShipments.ts.html +0 -274
- package/coverage/lcov-report/src/Connector/index.html +0 -176
- package/coverage/lcov-report/src/UpgatesApplication.ts.html +0 -379
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/test/dataProvider.ts.html +0 -223
- package/coverage/lcov-report/test/index.html +0 -116
- package/coverage/lcov.info +0 -485
- package/jest.config.js +0 -13
- package/src/Batch/UpgatesCreateWebhooks.ts +0 -91
- package/src/Batch/UpgatesGetOrders.ts +0 -214
- package/src/Batch/UpgatesGetProducts.ts +0 -216
- package/src/Batch/__tests__/Data/UpgatesCreateWebhooks/input.json +0 -6
- package/src/Batch/__tests__/Data/UpgatesCreateWebhooks/mock.json +0 -14
- package/src/Batch/__tests__/Data/UpgatesCreateWebhooks/output.json +0 -6
- package/src/Batch/__tests__/Data/UpgatesGetOrders/input.json +0 -6
- package/src/Batch/__tests__/Data/UpgatesGetOrders/lastRun-input.json +0 -6
- package/src/Batch/__tests__/Data/UpgatesGetOrders/lastRun-mock.json +0 -191
- package/src/Batch/__tests__/Data/UpgatesGetOrders/lastRun-output.json +0 -11
- package/src/Batch/__tests__/Data/UpgatesGetOrders/mock.json +0 -191
- package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumber-input.json +0 -8
- package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumber-mock.json +0 -191
- package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumber-output.json +0 -11
- package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumbers-input.json +0 -8
- package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumbers-mock.json +0 -191
- package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumbers-output.json +0 -11
- package/src/Batch/__tests__/Data/UpgatesGetOrders/output.json +0 -11
- package/src/Batch/__tests__/Data/UpgatesGetProducts/input.json +0 -6
- package/src/Batch/__tests__/Data/UpgatesGetProducts/lastRun-input.json +0 -6
- package/src/Batch/__tests__/Data/UpgatesGetProducts/lastRun-mock.json +0 -147
- package/src/Batch/__tests__/Data/UpgatesGetProducts/lastRun-output.json +0 -11
- package/src/Batch/__tests__/Data/UpgatesGetProducts/mock.json +0 -146
- package/src/Batch/__tests__/Data/UpgatesGetProducts/output.json +0 -11
- package/src/Batch/__tests__/Data/UpgatesGetProducts/productId-input.json +0 -8
- package/src/Batch/__tests__/Data/UpgatesGetProducts/productId-mock.json +0 -146
- package/src/Batch/__tests__/Data/UpgatesGetProducts/productId-output.json +0 -11
- package/src/Batch/__tests__/Data/UpgatesGetProducts/productIds-input.json +0 -8
- package/src/Batch/__tests__/Data/UpgatesGetProducts/productIds-mock.json +0 -146
- package/src/Batch/__tests__/Data/UpgatesGetProducts/productIds-output.json +0 -11
- package/src/Batch/__tests__/UpgatesCreateWebhooks.ts +0 -17
- package/src/Batch/__tests__/UpgatesGetOrders.ts +0 -33
- package/src/Batch/__tests__/UpgatesGetProducts.ts +0 -33
- package/src/Connector/UpgatesDeleteWebhooks.ts +0 -95
- package/src/Connector/UpgatesGetOrderStates.ts +0 -35
- package/src/Connector/UpgatesGetPayments.ts +0 -61
- package/src/Connector/UpgatesGetProductParameters.ts +0 -77
- package/src/Connector/UpgatesGetShipments.ts +0 -63
- package/src/Connector/UpgatesUpdateOrder.ts +0 -73
- package/src/Connector/UpgatesUpdateStock.ts +0 -59
- package/src/Connector/__tests__/Data/UpgatesDeleteWebhooks/input.json +0 -6
- package/src/Connector/__tests__/Data/UpgatesDeleteWebhooks/mock.json +0 -16
- package/src/Connector/__tests__/Data/UpgatesDeleteWebhooks/output.json +0 -6
- package/src/Connector/__tests__/Data/UpgatesGetOrderStates/input.json +0 -6
- package/src/Connector/__tests__/Data/UpgatesGetOrderStates/mock.json +0 -14
- package/src/Connector/__tests__/Data/UpgatesGetOrderStates/output.json +0 -15
- package/src/Connector/__tests__/Data/UpgatesGetPayments/input.json +0 -6
- package/src/Connector/__tests__/Data/UpgatesGetPayments/mock.json +0 -42
- package/src/Connector/__tests__/Data/UpgatesGetPayments/output.json +0 -43
- package/src/Connector/__tests__/Data/UpgatesGetProductParameters/both-input.json +0 -9
- package/src/Connector/__tests__/Data/UpgatesGetProductParameters/both-mock.json +0 -108
- package/src/Connector/__tests__/Data/UpgatesGetProductParameters/both-output.json +0 -109
- package/src/Connector/__tests__/Data/UpgatesGetProductParameters/input.json +0 -8
- package/src/Connector/__tests__/Data/UpgatesGetProductParameters/mock.json +0 -108
- package/src/Connector/__tests__/Data/UpgatesGetProductParameters/none-input.json +0 -6
- package/src/Connector/__tests__/Data/UpgatesGetProductParameters/none-mock.json +0 -5
- package/src/Connector/__tests__/Data/UpgatesGetProductParameters/none-output.json +0 -6
- package/src/Connector/__tests__/Data/UpgatesGetProductParameters/output.json +0 -109
- package/src/Connector/__tests__/Data/UpgatesGetShipments/input.json +0 -6
- package/src/Connector/__tests__/Data/UpgatesGetShipments/mock.json +0 -58
- package/src/Connector/__tests__/Data/UpgatesGetShipments/output.json +0 -59
- package/src/Connector/__tests__/UpgatesDeleteWebhooks.ts +0 -61
- package/src/Connector/__tests__/UpgatesGetOrderStates.ts +0 -18
- package/src/Connector/__tests__/UpgatesGetPayments.ts +0 -18
- package/src/Connector/__tests__/UpgatesGetProductParameters.ts +0 -28
- package/src/Connector/__tests__/UpgatesGetShipments.ts +0 -18
- package/src/UpgatesApplication.ts +0 -98
- package/test/dataProvider.ts +0 -46
- package/tsconfig.json +0 -8
- package/tsconfig.prod.json +0 -13
- package/tsconfig.prod.tsbuildinfo +0 -1
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_USER } from '@orchesty/nodejs-connectors/test/DataProvider';
|
|
2
|
-
import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
|
|
3
|
-
import { orchestyOptions } from '@orchesty/nodejs-sdk/dist/lib/Config/Config';
|
|
4
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
5
|
-
import { mockOnce } from '@orchesty/nodejs-sdk/dist/test/MockServer';
|
|
6
|
-
import NodeTester from '@orchesty/nodejs-sdk/dist/test/Testers/NodeTester';
|
|
7
|
-
import { init, mock } from '../../../test/dataProvider';
|
|
8
|
-
import { NAME as UPGATES_DELETE_WEBHOOKS } from '../UpgatesDeleteWebhooks';
|
|
9
|
-
|
|
10
|
-
let tester: NodeTester;
|
|
11
|
-
|
|
12
|
-
describe('Tests for UpgatesDeleteWebhooks', () => {
|
|
13
|
-
beforeAll(() => {
|
|
14
|
-
tester = new NodeTester(container, __filename);
|
|
15
|
-
init();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('process - ok', async () => {
|
|
19
|
-
mock();
|
|
20
|
-
mockOnce([
|
|
21
|
-
{
|
|
22
|
-
request: {
|
|
23
|
-
url: new RegExp(`${orchestyOptions.workerApi}\\/document\\/Webhook.*`),
|
|
24
|
-
method: HttpMethods.GET,
|
|
25
|
-
},
|
|
26
|
-
response: {
|
|
27
|
-
body: [
|
|
28
|
-
{
|
|
29
|
-
name: 'orders/create',
|
|
30
|
-
user: DEFAULT_USER,
|
|
31
|
-
token: 'testToken',
|
|
32
|
-
node: 'testNode',
|
|
33
|
-
topology: 'testTopology',
|
|
34
|
-
application: 'shopify',
|
|
35
|
-
webhookId: '1',
|
|
36
|
-
unsubscribeFailed: false,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'orders/update',
|
|
40
|
-
user: DEFAULT_USER,
|
|
41
|
-
token: 'testToken',
|
|
42
|
-
node: 'testNode',
|
|
43
|
-
topology: 'testTopology',
|
|
44
|
-
application: 'shopify',
|
|
45
|
-
webhookId: '2',
|
|
46
|
-
unsubscribeFailed: true,
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
request: {
|
|
53
|
-
url: new RegExp(`${orchestyOptions.workerApi}\\/document\\/Webhook.*`),
|
|
54
|
-
method: HttpMethods.DELETE,
|
|
55
|
-
},
|
|
56
|
-
response: {},
|
|
57
|
-
},
|
|
58
|
-
]);
|
|
59
|
-
await tester.testConnector(UPGATES_DELETE_WEBHOOKS);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
@@ -1,18 +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_ORDER_STATES } from '../UpgatesGetOrderStates';
|
|
5
|
-
|
|
6
|
-
let tester: NodeTester;
|
|
7
|
-
|
|
8
|
-
describe('Tests for UpgatesGetOrderStates', () => {
|
|
9
|
-
beforeAll(() => {
|
|
10
|
-
tester = new NodeTester(container, __filename);
|
|
11
|
-
init();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('process - ok', async () => {
|
|
15
|
-
mock();
|
|
16
|
-
await tester.testConnector(UPGATES_GET_ORDER_STATES);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,18 +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_PAYMENTS } from '../UpgatesGetPayments';
|
|
5
|
-
|
|
6
|
-
let tester: NodeTester;
|
|
7
|
-
|
|
8
|
-
describe('Tests for UpgatesGetPayments', () => {
|
|
9
|
-
beforeAll(() => {
|
|
10
|
-
tester = new NodeTester(container, __filename);
|
|
11
|
-
init();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('process - ok', async () => {
|
|
15
|
-
mock();
|
|
16
|
-
await tester.testConnector(UPGATES_GET_PAYMENTS);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,28 +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_PRODUCT_PARAMETERS } from '../UpgatesGetProductParameters';
|
|
5
|
-
|
|
6
|
-
let tester: NodeTester;
|
|
7
|
-
|
|
8
|
-
describe('Tests for UpgatesGetProductParameters', () => {
|
|
9
|
-
beforeAll(() => {
|
|
10
|
-
tester = new NodeTester(container, __filename);
|
|
11
|
-
init();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('process - ok', async () => {
|
|
15
|
-
mock();
|
|
16
|
-
await tester.testConnector(UPGATES_GET_PRODUCT_PARAMETERS);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('process - ok - code + productId', async () => {
|
|
20
|
-
mock();
|
|
21
|
-
await tester.testConnector(UPGATES_GET_PRODUCT_PARAMETERS, 'both');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('process - ok - empty input', async () => {
|
|
25
|
-
mock();
|
|
26
|
-
await tester.testConnector(UPGATES_GET_PRODUCT_PARAMETERS, 'none', Error);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,18 +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_SHIPMENTS } from '../UpgatesGetShipments';
|
|
5
|
-
|
|
6
|
-
let tester: NodeTester;
|
|
7
|
-
|
|
8
|
-
describe('Tests for UpgatesGetShipments', () => {
|
|
9
|
-
beforeAll(() => {
|
|
10
|
-
tester = new NodeTester(container, __filename);
|
|
11
|
-
init();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('process - ok', async () => {
|
|
15
|
-
mock();
|
|
16
|
-
await tester.testConnector(UPGATES_GET_SHIPMENTS);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import CoreFormsEnum, { getFormName } from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
|
|
2
|
-
import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
|
|
3
|
-
import Field from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Field';
|
|
4
|
-
import FieldType from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FieldType';
|
|
5
|
-
import Form from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Form';
|
|
6
|
-
import FormStack from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack';
|
|
7
|
-
import WebhookSubscription from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Webhook/WebhookSubscription';
|
|
8
|
-
import {
|
|
9
|
-
ABasicApplication,
|
|
10
|
-
PASSWORD,
|
|
11
|
-
USER,
|
|
12
|
-
} from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/Basic/ABasicApplication';
|
|
13
|
-
import RequestDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto';
|
|
14
|
-
import { HttpMethods, parseHttpMethod } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
15
|
-
import AProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/AProcessDto';
|
|
16
|
-
import { encode } from '@orchesty/nodejs-sdk/dist/lib/Utils/Base64';
|
|
17
|
-
import { CommonHeaders, JSON_TYPE } from '@orchesty/nodejs-sdk/dist/lib/Utils/Headers';
|
|
18
|
-
|
|
19
|
-
export const NAME = 'upgates';
|
|
20
|
-
|
|
21
|
-
export const UPGATES_URL = 'upgatesUrl';
|
|
22
|
-
|
|
23
|
-
export default class UpgatesApplication extends ABasicApplication {
|
|
24
|
-
|
|
25
|
-
public getDescription(): string {
|
|
26
|
-
return 'Customizable e-shop solution that you can tailor to your needs and ideas';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public getName(): string {
|
|
30
|
-
return NAME;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public getPublicName(): string {
|
|
34
|
-
return 'Upgates';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public getLogo(): string {
|
|
38
|
-
return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI1LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IlZyc3R2YV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTAwIDEwMDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsLXJ1bGU6ZXZlbm9kZDtjbGlwLXJ1bGU6ZXZlbm9kZDtmaWxsOiNGOUEwM0I7fQoJLnN0MXtmaWxsOiNGOUEwM0I7fQo8L3N0eWxlPgo8ZyBpZD0iU3ltYm9sIj4KCTxwYXRoIGlkPSJQYXRoIiBjbGFzcz0ic3QwIiBkPSJNNDEuNCw1OC4zaDE2LjZ2MTIuNGMwLDE2LjEtMTMsMjkuMS0yOS4xLDI5LjFjLTE2LjEsMC0yOS4xLTEzLTI5LjEtMjkuMXYtNTRoMTYuNnY1NAoJCWMwLDYuOSw1LjYsMTIuNCwxMi40LDEyLjRjNi45LDAsMTIuNC01LjYsMTIuNC0xMi40VjU4LjN6Ii8+Cgk8cGF0aCBpZD0iUGF0aC0yIiBjbGFzcz0ic3QwIiBkPSJNNTguMSw1OC4zVjQxLjdoMTIuNGM2LjksMC4xLDEyLjUtNS41LDEyLjYtMTIuNGMwLjEtNi45LTUuNS0xMi41LTEyLjQtMTIuNkgxNi41VjAuMkg3MQoJCWMxNi4xLDAsMjkuMSwxMywyOS4xLDI5LjFjMCwxNi4xLTEzLDI5LjEtMjkuMSwyOS4xYzAsMCwwLDAsMCwwSDU4LjF6Ii8+Cgk8cGF0aCBpZD0iVE0iIGNsYXNzPSJzdDEiIGQ9Ik04OC4xLDk0Ljl2LTUuMmgydi0xLjRoLTUuNXYxLjRoMnY1LjJIODguMXogTTkyLjIsOTQuOXYtNC40bDEuOCw0LjRoMS4ybDEuOC00LjR2NC40aDEuNXYtNi43aC0yCgkJbC0xLjgsNC41bC0xLjgtNC41aC0xLjl2Ni43SDkyLjJ6Ii8+CjwvZz4KPC9zdmc+Cg==';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public getRequestDto(
|
|
42
|
-
dto: AProcessDto,
|
|
43
|
-
applicationInstall: ApplicationInstall,
|
|
44
|
-
method: HttpMethods | string,
|
|
45
|
-
url?: string,
|
|
46
|
-
data?: string,
|
|
47
|
-
): RequestDto {
|
|
48
|
-
const settings = applicationInstall.getSettings();
|
|
49
|
-
const base64 = encode(
|
|
50
|
-
`${settings[CoreFormsEnum.AUTHORIZATION_FORM][USER]?.trim()}:${settings[CoreFormsEnum.AUTHORIZATION_FORM][PASSWORD]?.trim()}`,
|
|
51
|
-
);
|
|
52
|
-
const headers = {
|
|
53
|
-
[CommonHeaders.AUTHORIZATION]: `Basic ${base64}`,
|
|
54
|
-
[CommonHeaders.ACCEPT]: JSON_TYPE,
|
|
55
|
-
[CommonHeaders.CONTENT_TYPE]: JSON_TYPE,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
let urlx = url ?? '';
|
|
59
|
-
if (!urlx.startsWith('http')) {
|
|
60
|
-
urlx = `${this.getDecoratedUrl(applicationInstall)}/${urlx}`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return new RequestDto(urlx, parseHttpMethod(method), dto, data, headers);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public getDecoratedUrl(app: ApplicationInstall): string {
|
|
67
|
-
let url = app.getSettings()?.[CoreFormsEnum.AUTHORIZATION_FORM]?.[UPGATES_URL] ?? '';
|
|
68
|
-
url = url.replace('api/v2', '');
|
|
69
|
-
if (url.endsWith('/')) {
|
|
70
|
-
url = url.substring(0, url.length - 1);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return url;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public getFormStack(): FormStack {
|
|
77
|
-
const form = new Form(CoreFormsEnum.AUTHORIZATION_FORM, getFormName(CoreFormsEnum.AUTHORIZATION_FORM))
|
|
78
|
-
.addField(new Field(FieldType.TEXT, USER, 'Login', undefined, true))
|
|
79
|
-
.addField(new Field(FieldType.TEXT, PASSWORD, 'Klíč API', undefined, true))
|
|
80
|
-
.addField(new Field(FieldType.URL, UPGATES_URL, 'Url', undefined, true));
|
|
81
|
-
|
|
82
|
-
return new FormStack().addForm(form);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public isAuthorized(applicationInstall: ApplicationInstall): boolean {
|
|
86
|
-
const authorizationForm = applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM];
|
|
87
|
-
return authorizationForm?.[USER] && authorizationForm?.[PASSWORD] && authorizationForm?.[UPGATES_URL];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public getIsoDateFromDate(date?: string): string {
|
|
91
|
-
return date ? new Date(date).toISOString().split('.')[0] : '';
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public getWebhookSubscriptions(): WebhookSubscription[] {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
}
|
package/test/dataProvider.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { appInstall, DEFAULT_PASSWORD, DEFAULT_USER } from '@orchesty/nodejs-connectors/test/DataProvider';
|
|
2
|
-
import { container } from '@orchesty/nodejs-connectors/test/TestAbstract';
|
|
3
|
-
import CoreFormsEnum from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
|
|
4
|
-
import {
|
|
5
|
-
ApplicationInstall,
|
|
6
|
-
IApplicationSettings,
|
|
7
|
-
} from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
|
|
8
|
-
import { PASSWORD, USER } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/Basic/ABasicApplication';
|
|
9
|
-
import UpgatesCreateWebhooks from '../src/Batch/UpgatesCreateWebhooks';
|
|
10
|
-
import UpgatesGetOrders from '../src/Batch/UpgatesGetOrders';
|
|
11
|
-
import UpgatesGetProducts from '../src/Batch/UpgatesGetProducts';
|
|
12
|
-
import UpgatesDeleteWebhooks from '../src/Connector/UpgatesDeleteWebhooks';
|
|
13
|
-
import UpgatesGetOrderStates from '../src/Connector/UpgatesGetOrderStates';
|
|
14
|
-
import UpgatesGetPayments from '../src/Connector/UpgatesGetPayments';
|
|
15
|
-
import UpgatesGetProductParameters from '../src/Connector/UpgatesGetProductParameters';
|
|
16
|
-
import UpgatesGetShipments from '../src/Connector/UpgatesGetShipments';
|
|
17
|
-
import UpgatesApplication, { NAME, UPGATES_URL } from '../src/UpgatesApplication';
|
|
18
|
-
|
|
19
|
-
export function mock(extraNonEncryptedSettings?: IApplicationSettings): ApplicationInstall {
|
|
20
|
-
return appInstall(
|
|
21
|
-
NAME,
|
|
22
|
-
DEFAULT_USER,
|
|
23
|
-
{
|
|
24
|
-
[CoreFormsEnum.AUTHORIZATION_FORM]: {
|
|
25
|
-
[USER]: DEFAULT_USER,
|
|
26
|
-
[PASSWORD]: DEFAULT_PASSWORD,
|
|
27
|
-
[UPGATES_URL]: 'https://private-anon-903e641b16-upgatesapiv2.apiary-mock.com',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
extraNonEncryptedSettings,
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function init(): void {
|
|
35
|
-
const upgatesApplication = new UpgatesApplication();
|
|
36
|
-
container.setApplication(upgatesApplication);
|
|
37
|
-
|
|
38
|
-
container.setNode(new UpgatesCreateWebhooks(), upgatesApplication);
|
|
39
|
-
container.setNode(new UpgatesDeleteWebhooks(), upgatesApplication);
|
|
40
|
-
container.setNode(new UpgatesGetOrders(), upgatesApplication);
|
|
41
|
-
container.setNode(new UpgatesGetProducts(), upgatesApplication);
|
|
42
|
-
container.setNode(new UpgatesGetOrderStates(), upgatesApplication);
|
|
43
|
-
container.setNode(new UpgatesGetShipments(), upgatesApplication);
|
|
44
|
-
container.setNode(new UpgatesGetPayments(), upgatesApplication);
|
|
45
|
-
container.setNode(new UpgatesGetProductParameters(), upgatesApplication);
|
|
46
|
-
}
|
package/tsconfig.json
DELETED