@orchesty/connector-mergado 1.0.0 → 1.0.1
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/dist/package.json +4 -1
- package/package.json +4 -1
- package/CHANGELOG.md +0 -7
- package/coverage/clover.xml +0 -142
- package/coverage/coverage-final.json +0 -7
- 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/MergadoListAppsBatch.ts.html +0 -250
- package/coverage/lcov-report/src/Batch/index.html +0 -116
- package/coverage/lcov-report/src/Connector/MergadoCreateElementConnector.ts.html +0 -199
- package/coverage/lcov-report/src/Connector/MergadoGetProjectConnector.ts.html +0 -295
- package/coverage/lcov-report/src/Connector/MergadoGetUserConnector.ts.html +0 -247
- package/coverage/lcov-report/src/Connector/index.html +0 -146
- package/coverage/lcov-report/src/MergadoApplication.ts.html +0 -370
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/test/dataProvider.ts.html +0 -265
- package/coverage/lcov-report/test/index.html +0 -116
- package/coverage/lcov.info +0 -211
- package/jest.config.js +0 -13
- package/src/Batch/MergadoListAppsBatch.ts +0 -55
- package/src/Batch/__tests__/Data/MergadoListAppsBatch/input.json +0 -6
- package/src/Batch/__tests__/Data/MergadoListAppsBatch/mock.json +0 -19
- package/src/Batch/__tests__/Data/MergadoListAppsBatch/output.json +0 -11
- package/src/Batch/__tests__/MergadoListAppsBatch.ts +0 -17
- package/src/Connector/MergadoCreateElementConnector.ts +0 -38
- package/src/Connector/MergadoGetProjectConnector.ts +0 -70
- package/src/Connector/MergadoGetUserConnector.ts +0 -54
- package/src/Connector/__tests__/Data/MergadoCreateElementConnector/input.json +0 -10
- package/src/Connector/__tests__/Data/MergadoCreateElementConnector/mock.json +0 -11
- package/src/Connector/__tests__/Data/MergadoCreateElementConnector/output.json +0 -12
- package/src/Connector/__tests__/Data/MergadoGetProjectConnector/input.json +0 -8
- package/src/Connector/__tests__/Data/MergadoGetProjectConnector/mock.json +0 -41
- package/src/Connector/__tests__/Data/MergadoGetProjectConnector/output.json +0 -42
- package/src/Connector/__tests__/Data/MergadoGetUserConnector/input.json +0 -8
- package/src/Connector/__tests__/Data/MergadoGetUserConnector/mock.json +0 -27
- package/src/Connector/__tests__/Data/MergadoGetUserConnector/output.json +0 -28
- package/src/Connector/__tests__/MergadoCreateElementConnector.ts +0 -17
- package/src/Connector/__tests__/MergadoGetProjectConnector.ts +0 -17
- package/src/Connector/__tests__/MergadoGetUserConnector.ts +0 -17
- package/src/MergadoApplication.ts +0 -95
- package/test/dataProvider.ts +0 -60
- package/tsconfig.json +0 -8
- package/tsconfig.prod.json +0 -13
- package/tsconfig.prod.tsbuildinfo +0 -1
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"http": "GET https://api.mergado.com/apps/?limit=99&offset=0",
|
|
3
|
-
"code": 200,
|
|
4
|
-
"body": {
|
|
5
|
-
"data": [
|
|
6
|
-
{
|
|
7
|
-
"creation_date": "2016-11-02T09:12:09+00:00",
|
|
8
|
-
"forum_url": "bidding-fox",
|
|
9
|
-
"latest_release_date": "2016-11-02T09:12:10+00:00",
|
|
10
|
-
"title": "Bidding Fox",
|
|
11
|
-
"trial_period": 10,
|
|
12
|
-
"type": "project"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"limit": 10,
|
|
16
|
-
"total_results": 1,
|
|
17
|
-
"offset": 0
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"headers": {
|
|
3
|
-
"user": "TestUser"
|
|
4
|
-
},
|
|
5
|
-
"data": [
|
|
6
|
-
{
|
|
7
|
-
"body": "{\"creation_date\":\"2016-11-02T09:12:09+00:00\",\"forum_url\":\"bidding-fox\",\"latest_release_date\":\"2016-11-02T09:12:10+00:00\",\"title\":\"Bidding Fox\",\"trial_period\":10,\"type\":\"project\"}",
|
|
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 MERGADO_LIST_APPS_BATCH } from '../MergadoListAppsBatch';
|
|
5
|
-
|
|
6
|
-
let tester: NodeTester;
|
|
7
|
-
|
|
8
|
-
describe('Tests for MergadoListAppsBatch', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
tester = new NodeTester(container, __filename);
|
|
11
|
-
init();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('process - ok', async () => {
|
|
15
|
-
await tester.testBatch(MERGADO_LIST_APPS_BATCH);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,38 +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 = 'mergado-create-element-connector';
|
|
6
|
-
|
|
7
|
-
export default class MergadoCreateElementConnector extends AConnector {
|
|
8
|
-
|
|
9
|
-
public getName(): string {
|
|
10
|
-
return NAME;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
|
|
14
|
-
const { id, ...body } = dto.getJsonData();
|
|
15
|
-
|
|
16
|
-
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
17
|
-
const url = `projects/${id}/elements`;
|
|
18
|
-
const req = await this.getApplication().getRequestDto(dto, appInstall, HttpMethods.POST, url, body);
|
|
19
|
-
const resp = await this.getSender().send<IOutput>(req, [201]);
|
|
20
|
-
|
|
21
|
-
return dto.setNewJsonData(resp.getJsonBody());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface IInput {
|
|
27
|
-
id: string;
|
|
28
|
-
name: string;
|
|
29
|
-
hidden: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface IOutput {
|
|
33
|
-
id: string;
|
|
34
|
-
project_id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
type: string;
|
|
37
|
-
hidden: boolean;
|
|
38
|
-
}
|
|
@@ -1,70 +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 = 'mergado-get-project-connector';
|
|
6
|
-
|
|
7
|
-
export default class MergadoGetProjectConnector extends AConnector {
|
|
8
|
-
|
|
9
|
-
public getName(): string {
|
|
10
|
-
return NAME;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
|
|
14
|
-
const { id } = dto.getJsonData();
|
|
15
|
-
|
|
16
|
-
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
17
|
-
const url = `projects/${id}/`;
|
|
18
|
-
const req = await this.getApplication().getRequestDto(dto, appInstall, HttpMethods.GET, url);
|
|
19
|
-
const resp = await this.getSender().send<IOutput>(req, [200]);
|
|
20
|
-
|
|
21
|
-
return dto.setNewJsonData(resp.getJsonBody());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
27
|
-
|
|
28
|
-
export interface IInput {
|
|
29
|
-
id: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface IOutput {
|
|
33
|
-
id: string;
|
|
34
|
-
shop_id: string;
|
|
35
|
-
creator_id: string;
|
|
36
|
-
name: string;
|
|
37
|
-
url: string;
|
|
38
|
-
activated: boolean;
|
|
39
|
-
created: Date;
|
|
40
|
-
exported_items: number;
|
|
41
|
-
input_format: string;
|
|
42
|
-
output_format: string;
|
|
43
|
-
pairing_elements: string;
|
|
44
|
-
readonly: boolean;
|
|
45
|
-
is_paused: boolean;
|
|
46
|
-
rules_changed_at: Date;
|
|
47
|
-
slug: string;
|
|
48
|
-
turned_off: boolean;
|
|
49
|
-
update_period: number;
|
|
50
|
-
last_access: Date;
|
|
51
|
-
xml_synced_at: Date;
|
|
52
|
-
xml_updated_at: Date;
|
|
53
|
-
is_dirty: boolean;
|
|
54
|
-
metadata: {
|
|
55
|
-
stats_ga_medium: string;
|
|
56
|
-
stats_ga_source: string;
|
|
57
|
-
generator: string;
|
|
58
|
-
};
|
|
59
|
-
number_of_elements: number;
|
|
60
|
-
all_products_query_id: string;
|
|
61
|
-
sync_schedule: {
|
|
62
|
-
minute: string;
|
|
63
|
-
hour: string;
|
|
64
|
-
day_of_week: string;
|
|
65
|
-
day_of_month: string;
|
|
66
|
-
month_of_year: string;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
@@ -1,54 +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 = 'mergado-get-user-connector';
|
|
6
|
-
|
|
7
|
-
export default class MergadoGetUserConnector extends AConnector {
|
|
8
|
-
|
|
9
|
-
public getName(): string {
|
|
10
|
-
return NAME;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
|
|
14
|
-
const { id } = dto.getJsonData();
|
|
15
|
-
|
|
16
|
-
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
17
|
-
const url = `users/${id}/`;
|
|
18
|
-
const req = await this.getApplication().getRequestDto(dto, appInstall, HttpMethods.GET, url);
|
|
19
|
-
const resp = await this.getSender().send<IOutput>(req, [200]);
|
|
20
|
-
|
|
21
|
-
return dto.setNewJsonData(resp.getJsonBody());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
27
|
-
|
|
28
|
-
export interface IInput {
|
|
29
|
-
id: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface IOutput {
|
|
33
|
-
id: string;
|
|
34
|
-
first_name: string;
|
|
35
|
-
last_name: string;
|
|
36
|
-
name: string;
|
|
37
|
-
username: string;
|
|
38
|
-
email: string;
|
|
39
|
-
city: string;
|
|
40
|
-
company: string;
|
|
41
|
-
country: string;
|
|
42
|
-
dic: string;
|
|
43
|
-
ico: string;
|
|
44
|
-
invoice_months: number;
|
|
45
|
-
last_access: Date;
|
|
46
|
-
locale: string;
|
|
47
|
-
postcode: string;
|
|
48
|
-
registered_at: Date;
|
|
49
|
-
street: string;
|
|
50
|
-
timezone: string;
|
|
51
|
-
send_summary: boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"http": "GET https://api.mergado.com/projects/8/",
|
|
3
|
-
"code": 200,
|
|
4
|
-
"body": {
|
|
5
|
-
"id": "8",
|
|
6
|
-
"shop_id": "1",
|
|
7
|
-
"creator_id": "1",
|
|
8
|
-
"name": "Billiger.de",
|
|
9
|
-
"url": "https://dummy.mergado.com/example-com.xml",
|
|
10
|
-
"activated": true,
|
|
11
|
-
"created": "2015-11-11T15:42:33+00:00",
|
|
12
|
-
"exported_items": 0,
|
|
13
|
-
"input_format": "zbozi.cz",
|
|
14
|
-
"output_format": "billiger.de",
|
|
15
|
-
"pairing_elements": "URL",
|
|
16
|
-
"readonly": false,
|
|
17
|
-
"is_paused": false,
|
|
18
|
-
"rules_changed_at": "2015-11-11T15:43:07+00:00",
|
|
19
|
-
"slug": "example-com-heureka-cz-asdf",
|
|
20
|
-
"turned_off": true,
|
|
21
|
-
"update_period": 14400,
|
|
22
|
-
"last_access": "2015-12-10T12:51:59+00:00",
|
|
23
|
-
"xml_synced_at": "2015-11-18T13:19:59+00:00",
|
|
24
|
-
"xml_updated_at": "2015-11-11T15:42:50+00:00",
|
|
25
|
-
"is_dirty": false,
|
|
26
|
-
"metadata": {
|
|
27
|
-
"stats_ga_medium": "agregator",
|
|
28
|
-
"stats_ga_source": "heureka.*.",
|
|
29
|
-
"generator": "mergado.magento.marketingpack.0_1"
|
|
30
|
-
},
|
|
31
|
-
"number_of_elements": 28,
|
|
32
|
-
"all_products_query_id": "1",
|
|
33
|
-
"sync_schedule": {
|
|
34
|
-
"minute": "50",
|
|
35
|
-
"hour": "*/1",
|
|
36
|
-
"day_of_week": "*",
|
|
37
|
-
"day_of_month": "*",
|
|
38
|
-
"month_of_year": "*"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"headers": {
|
|
3
|
-
"user": "TestUser"
|
|
4
|
-
},
|
|
5
|
-
"data": {
|
|
6
|
-
"id": "8",
|
|
7
|
-
"shop_id": "1",
|
|
8
|
-
"creator_id": "1",
|
|
9
|
-
"name": "Billiger.de",
|
|
10
|
-
"url": "https://dummy.mergado.com/example-com.xml",
|
|
11
|
-
"activated": true,
|
|
12
|
-
"created": "2015-11-11T15:42:33+00:00",
|
|
13
|
-
"exported_items": 0,
|
|
14
|
-
"input_format": "zbozi.cz",
|
|
15
|
-
"output_format": "billiger.de",
|
|
16
|
-
"pairing_elements": "URL",
|
|
17
|
-
"readonly": false,
|
|
18
|
-
"is_paused": false,
|
|
19
|
-
"rules_changed_at": "2015-11-11T15:43:07+00:00",
|
|
20
|
-
"slug": "example-com-heureka-cz-asdf",
|
|
21
|
-
"turned_off": true,
|
|
22
|
-
"update_period": 14400,
|
|
23
|
-
"last_access": "2015-12-10T12:51:59+00:00",
|
|
24
|
-
"xml_synced_at": "2015-11-18T13:19:59+00:00",
|
|
25
|
-
"xml_updated_at": "2015-11-11T15:42:50+00:00",
|
|
26
|
-
"is_dirty": false,
|
|
27
|
-
"metadata": {
|
|
28
|
-
"stats_ga_medium": "agregator",
|
|
29
|
-
"stats_ga_source": "heureka.*.",
|
|
30
|
-
"generator": "mergado.magento.marketingpack.0_1"
|
|
31
|
-
},
|
|
32
|
-
"number_of_elements": 28,
|
|
33
|
-
"all_products_query_id": "1",
|
|
34
|
-
"sync_schedule": {
|
|
35
|
-
"minute": "50",
|
|
36
|
-
"hour": "*/1",
|
|
37
|
-
"day_of_week": "*",
|
|
38
|
-
"day_of_month": "*",
|
|
39
|
-
"month_of_year": "*"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"http": "GET https://api.mergado.com/users/6/",
|
|
3
|
-
"code": 200,
|
|
4
|
-
"body": {
|
|
5
|
-
"id": "6",
|
|
6
|
-
"first_name": "Lorem",
|
|
7
|
-
"last_name": "Ipsum",
|
|
8
|
-
"name": "Lorem Ipsum",
|
|
9
|
-
"username": "loremipsum",
|
|
10
|
-
"email": "lorem.ipsum@example.com",
|
|
11
|
-
"city": "Brno",
|
|
12
|
-
"company": "Mergado",
|
|
13
|
-
"country": "cz",
|
|
14
|
-
"dic": "00000000",
|
|
15
|
-
"ico": "00000000",
|
|
16
|
-
"fakturoid_id": null,
|
|
17
|
-
"invoice_months": 1,
|
|
18
|
-
"last_access": "2016-03-21T16:32:32+00:00",
|
|
19
|
-
"locale": "cs_CZ",
|
|
20
|
-
"postcode": "61200",
|
|
21
|
-
"registered_at": "2015-11-03T16:08:17+00:00",
|
|
22
|
-
"street": "Palackého 123/456",
|
|
23
|
-
"timezone": "Europe/Prague",
|
|
24
|
-
"timezone_offset": null,
|
|
25
|
-
"send_summary": false
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"headers": {
|
|
3
|
-
"user": "TestUser"
|
|
4
|
-
},
|
|
5
|
-
"data": {
|
|
6
|
-
"id": "6",
|
|
7
|
-
"first_name": "Lorem",
|
|
8
|
-
"last_name": "Ipsum",
|
|
9
|
-
"name": "Lorem Ipsum",
|
|
10
|
-
"username": "loremipsum",
|
|
11
|
-
"email": "lorem.ipsum@example.com",
|
|
12
|
-
"city": "Brno",
|
|
13
|
-
"company": "Mergado",
|
|
14
|
-
"country": "cz",
|
|
15
|
-
"dic": "00000000",
|
|
16
|
-
"ico": "00000000",
|
|
17
|
-
"fakturoid_id": null,
|
|
18
|
-
"invoice_months": 1,
|
|
19
|
-
"last_access": "2016-03-21T16:32:32+00:00",
|
|
20
|
-
"locale": "cs_CZ",
|
|
21
|
-
"postcode": "61200",
|
|
22
|
-
"registered_at": "2015-11-03T16:08:17+00:00",
|
|
23
|
-
"street": "Palackého 123/456",
|
|
24
|
-
"timezone": "Europe/Prague",
|
|
25
|
-
"timezone_offset": null,
|
|
26
|
-
"send_summary": false
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -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 MERGADO_CREATE_ELEMENT_CONNECTOR } from '../MergadoCreateElementConnector';
|
|
5
|
-
|
|
6
|
-
let tester: NodeTester;
|
|
7
|
-
|
|
8
|
-
describe('Tests for MergadoCreateElementConnector', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
tester = new NodeTester(container, __filename, true);
|
|
11
|
-
init();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('process - ok', async () => {
|
|
15
|
-
await tester.testConnector(MERGADO_CREATE_ELEMENT_CONNECTOR);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -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 MERGADO_GET_PROJECT_CONNECTOR } from '../MergadoGetProjectConnector';
|
|
5
|
-
|
|
6
|
-
let tester: NodeTester;
|
|
7
|
-
|
|
8
|
-
describe('Tests for MergadoGetProjectConnector', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
tester = new NodeTester(container, __filename, true);
|
|
11
|
-
init();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('process - ok', async () => {
|
|
15
|
-
await tester.testConnector(MERGADO_GET_PROJECT_CONNECTOR);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -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 MERGADO_GET_USER_CONNECTOR } from '../MergadoGetUserConnector';
|
|
5
|
-
|
|
6
|
-
let tester: NodeTester;
|
|
7
|
-
|
|
8
|
-
describe('Tests for MergadoGetUserConnector', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
tester = new NodeTester(container, __filename, true);
|
|
11
|
-
init();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('process - ok', async () => {
|
|
15
|
-
await tester.testConnector(MERGADO_GET_USER_CONNECTOR);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,95 +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 ScopeSeparatorEnum from '@orchesty/nodejs-sdk/dist/lib/Authorization/ScopeSeparatorEnum';
|
|
8
|
-
import AOAuth2Application from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/AOAuth2Application';
|
|
9
|
-
import { CLIENT_ID, CLIENT_SECRET } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application';
|
|
10
|
-
import RequestDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto';
|
|
11
|
-
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
12
|
-
import AProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/AProcessDto';
|
|
13
|
-
import { CommonHeaders, JSON_TYPE } from '@orchesty/nodejs-sdk/dist/lib/Utils/Headers';
|
|
14
|
-
|
|
15
|
-
export const NAME = 'mergado';
|
|
16
|
-
export default class MergadoApplication extends AOAuth2Application {
|
|
17
|
-
|
|
18
|
-
public getName(): string {
|
|
19
|
-
return NAME;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public getPublicName(): string {
|
|
23
|
-
return 'Mergado';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public getDescription(): string {
|
|
27
|
-
return 'Software with which you can automate the data flowing from your e-shop to search engines and other advertising systems';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public getAuthUrl(): string {
|
|
31
|
-
return 'https://app.mergado.com/oauth2/authorize/';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public getTokenUrl(): string {
|
|
35
|
-
return 'https://app.mergado.com/oauth2/token/';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public getLogo(): string {
|
|
39
|
-
return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI1LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IlZyc3R2YV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTAwIDEwMDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiM3RkI5MkY7fQoJLnN0MXtmaWxsOiM0MjdCMjc7fQoJLnN0MntmaWxsOiM0NEE4Qjc7fQo8L3N0eWxlPgo8Zz4KCTxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik0wLDBsNTAsNTBMMCwxMDBWMHoiLz4KCTxwYXRoIGNsYXNzPSJzdDEiIGQ9Ik01MCw1MGw1MCw1MEgwTDUwLDUweiIvPgoJPHBhdGggY2xhc3M9InN0MiIgZD0iTTUwLDUwbDUwLTUwdjEwMEw1MCw1MHoiLz4KPC9nPgo8L3N2Zz4K';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public getRequestDto(
|
|
43
|
-
dto: AProcessDto,
|
|
44
|
-
applicationInstall: ApplicationInstall,
|
|
45
|
-
method: HttpMethods,
|
|
46
|
-
_url?: string,
|
|
47
|
-
data?: unknown,
|
|
48
|
-
): RequestDto {
|
|
49
|
-
const url = `https://api.mergado.com/${_url}`;
|
|
50
|
-
const request = new RequestDto(url ?? '', method, dto);
|
|
51
|
-
request.setHeaders({
|
|
52
|
-
[CommonHeaders.CONTENT_TYPE]: JSON_TYPE,
|
|
53
|
-
[CommonHeaders.ACCEPT]: JSON_TYPE,
|
|
54
|
-
[CommonHeaders.AUTHORIZATION]: `Bearer ${this.getAccessToken(applicationInstall)}`,
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
if (data) {
|
|
59
|
-
request.setJsonBody(data);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return request;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public getFormStack(): FormStack {
|
|
66
|
-
const form = new Form(CoreFormsEnum.AUTHORIZATION_FORM, getFormName(CoreFormsEnum.AUTHORIZATION_FORM))
|
|
67
|
-
.addField(new Field(FieldType.TEXT, CLIENT_ID, 'Client Id', null, true))
|
|
68
|
-
.addField(new Field(FieldType.TEXT, CLIENT_SECRET, 'Client Secret', null, true));
|
|
69
|
-
|
|
70
|
-
return new FormStack()
|
|
71
|
-
.addForm(form);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public isAuthorized(applicationInstall: ApplicationInstall): boolean {
|
|
75
|
-
const authorizationForm = applicationInstall.getSettings()[CoreFormsEnum.AUTHORIZATION_FORM];
|
|
76
|
-
return super.isAuthorized(applicationInstall)
|
|
77
|
-
&& authorizationForm?.[CLIENT_ID]
|
|
78
|
-
&& authorizationForm?.[CLIENT_SECRET];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
82
|
-
public getScopes(applicationInstall: ApplicationInstall): string[] {
|
|
83
|
-
return [
|
|
84
|
-
'shop.read',
|
|
85
|
-
'user.read',
|
|
86
|
-
'project.read',
|
|
87
|
-
'project.elements.write',
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
protected _getScopesSeparator(): string {
|
|
92
|
-
return ScopeSeparatorEnum.SPACE;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
}
|
package/test/dataProvider.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
appInstall,
|
|
3
|
-
DEFAULT_ACCESS_TOKEN,
|
|
4
|
-
DEFAULT_CLIENT_ID,
|
|
5
|
-
DEFAULT_CLIENT_SECRET,
|
|
6
|
-
DEFAULT_USER,
|
|
7
|
-
} from '@orchesty/nodejs-connectors/test/DataProvider';
|
|
8
|
-
import {
|
|
9
|
-
container, db, oauth2Provider, sender,
|
|
10
|
-
} from '@orchesty/nodejs-connectors/test/TestAbstract';
|
|
11
|
-
import CoreFormsEnum from '@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum';
|
|
12
|
-
import { ACCESS_TOKEN } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Provider/OAuth2/OAuth2Provider';
|
|
13
|
-
import { TOKEN } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/Basic/ABasicApplication';
|
|
14
|
-
import { CLIENT_ID, CLIENT_SECRET } from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application';
|
|
15
|
-
import MergadoListAppsBatch from '../src/Batch/MergadoListAppsBatch';
|
|
16
|
-
import MergadoCreateElementConnector from '../src/Connector/MergadoCreateElementConnector';
|
|
17
|
-
import MergadoGetProjectConnector from '../src/Connector/MergadoGetProjectConnector';
|
|
18
|
-
import MergadoGetUserConnector from '../src/Connector/MergadoGetUserConnector';
|
|
19
|
-
import MergadoApplication, { NAME as MERGADO_APP } from '../src/MergadoApplication';
|
|
20
|
-
|
|
21
|
-
export default function init(): void {
|
|
22
|
-
appInstall(MERGADO_APP, DEFAULT_USER, {
|
|
23
|
-
[CoreFormsEnum.AUTHORIZATION_FORM]: {
|
|
24
|
-
[CLIENT_ID]: DEFAULT_CLIENT_ID,
|
|
25
|
-
[CLIENT_SECRET]: DEFAULT_CLIENT_SECRET,
|
|
26
|
-
[TOKEN]: {
|
|
27
|
-
[ACCESS_TOKEN]: DEFAULT_ACCESS_TOKEN,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const app = new MergadoApplication(oauth2Provider);
|
|
33
|
-
container.setApplication(app);
|
|
34
|
-
|
|
35
|
-
const listApps = new MergadoListAppsBatch();
|
|
36
|
-
const getUser = new MergadoGetUserConnector();
|
|
37
|
-
const getProject = new MergadoGetProjectConnector();
|
|
38
|
-
const createElement = new MergadoCreateElementConnector();
|
|
39
|
-
|
|
40
|
-
listApps
|
|
41
|
-
.setSender(sender)
|
|
42
|
-
.setDb(db)
|
|
43
|
-
.setApplication(app);
|
|
44
|
-
container.setBatch(listApps);
|
|
45
|
-
getUser
|
|
46
|
-
.setSender(sender)
|
|
47
|
-
.setDb(db)
|
|
48
|
-
.setApplication(app);
|
|
49
|
-
container.setConnector(getUser);
|
|
50
|
-
getProject
|
|
51
|
-
.setSender(sender)
|
|
52
|
-
.setDb(db)
|
|
53
|
-
.setApplication(app);
|
|
54
|
-
container.setConnector(getProject);
|
|
55
|
-
createElement
|
|
56
|
-
.setSender(sender)
|
|
57
|
-
.setDb(db)
|
|
58
|
-
.setApplication(app);
|
|
59
|
-
container.setConnector(createElement);
|
|
60
|
-
}
|
package/tsconfig.json
DELETED