@orchesty/connector-mergado 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.
- package/CHANGELOG.md +7 -0
- package/LICENSE +190 -0
- package/coverage/clover.xml +142 -0
- package/coverage/coverage-final.json +7 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +161 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/Batch/MergadoListAppsBatch.ts.html +250 -0
- package/coverage/lcov-report/src/Batch/index.html +116 -0
- package/coverage/lcov-report/src/Connector/MergadoCreateElementConnector.ts.html +199 -0
- package/coverage/lcov-report/src/Connector/MergadoGetProjectConnector.ts.html +295 -0
- package/coverage/lcov-report/src/Connector/MergadoGetUserConnector.ts.html +247 -0
- package/coverage/lcov-report/src/Connector/index.html +146 -0
- package/coverage/lcov-report/src/MergadoApplication.ts.html +370 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/test/dataProvider.ts.html +265 -0
- package/coverage/lcov-report/test/index.html +116 -0
- package/coverage/lcov.info +211 -0
- package/dist/Batch/MergadoListAppsBatch.d.ts +15 -0
- package/dist/Batch/MergadoListAppsBatch.js +29 -0
- package/dist/Connector/MergadoCreateElementConnector.d.ts +19 -0
- package/dist/Connector/MergadoCreateElementConnector.js +23 -0
- package/dist/Connector/MergadoGetProjectConnector.d.ts +47 -0
- package/dist/Connector/MergadoGetProjectConnector.js +23 -0
- package/dist/Connector/MergadoGetUserConnector.d.ts +31 -0
- package/dist/Connector/MergadoGetUserConnector.js +23 -0
- package/dist/MergadoApplication.d.ts +20 -0
- package/dist/MergadoApplication.js +108 -0
- package/dist/package.json +22 -0
- package/jest.config.js +13 -0
- package/package.json +22 -0
- package/src/Batch/MergadoListAppsBatch.ts +55 -0
- package/src/Batch/__tests__/Data/MergadoListAppsBatch/input.json +6 -0
- package/src/Batch/__tests__/Data/MergadoListAppsBatch/mock.json +19 -0
- package/src/Batch/__tests__/Data/MergadoListAppsBatch/output.json +11 -0
- package/src/Batch/__tests__/MergadoListAppsBatch.ts +17 -0
- package/src/Connector/MergadoCreateElementConnector.ts +38 -0
- package/src/Connector/MergadoGetProjectConnector.ts +70 -0
- package/src/Connector/MergadoGetUserConnector.ts +54 -0
- package/src/Connector/__tests__/Data/MergadoCreateElementConnector/input.json +10 -0
- package/src/Connector/__tests__/Data/MergadoCreateElementConnector/mock.json +11 -0
- package/src/Connector/__tests__/Data/MergadoCreateElementConnector/output.json +12 -0
- package/src/Connector/__tests__/Data/MergadoGetProjectConnector/input.json +8 -0
- package/src/Connector/__tests__/Data/MergadoGetProjectConnector/mock.json +41 -0
- package/src/Connector/__tests__/Data/MergadoGetProjectConnector/output.json +42 -0
- package/src/Connector/__tests__/Data/MergadoGetUserConnector/input.json +8 -0
- package/src/Connector/__tests__/Data/MergadoGetUserConnector/mock.json +27 -0
- package/src/Connector/__tests__/Data/MergadoGetUserConnector/output.json +28 -0
- package/src/Connector/__tests__/MergadoCreateElementConnector.ts +17 -0
- package/src/Connector/__tests__/MergadoGetProjectConnector.ts +17 -0
- package/src/Connector/__tests__/MergadoGetUserConnector.ts +17 -0
- package/src/MergadoApplication.ts +95 -0
- package/test/dataProvider.ts +60 -0
- package/tsconfig.json +8 -0
- package/tsconfig.prod.json +13 -0
- package/tsconfig.prod.tsbuildinfo +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
3
|
+
export declare const NAME = "mergado-get-project-connector";
|
|
4
|
+
export default class MergadoGetProjectConnector extends AConnector {
|
|
5
|
+
getName(): string;
|
|
6
|
+
processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>>;
|
|
7
|
+
}
|
|
8
|
+
export interface IInput {
|
|
9
|
+
id: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IOutput {
|
|
12
|
+
id: string;
|
|
13
|
+
shop_id: string;
|
|
14
|
+
creator_id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
url: string;
|
|
17
|
+
activated: boolean;
|
|
18
|
+
created: Date;
|
|
19
|
+
exported_items: number;
|
|
20
|
+
input_format: string;
|
|
21
|
+
output_format: string;
|
|
22
|
+
pairing_elements: string;
|
|
23
|
+
readonly: boolean;
|
|
24
|
+
is_paused: boolean;
|
|
25
|
+
rules_changed_at: Date;
|
|
26
|
+
slug: string;
|
|
27
|
+
turned_off: boolean;
|
|
28
|
+
update_period: number;
|
|
29
|
+
last_access: Date;
|
|
30
|
+
xml_synced_at: Date;
|
|
31
|
+
xml_updated_at: Date;
|
|
32
|
+
is_dirty: boolean;
|
|
33
|
+
metadata: {
|
|
34
|
+
stats_ga_medium: string;
|
|
35
|
+
stats_ga_source: string;
|
|
36
|
+
generator: string;
|
|
37
|
+
};
|
|
38
|
+
number_of_elements: number;
|
|
39
|
+
all_products_query_id: string;
|
|
40
|
+
sync_schedule: {
|
|
41
|
+
minute: string;
|
|
42
|
+
hour: string;
|
|
43
|
+
day_of_week: string;
|
|
44
|
+
day_of_month: string;
|
|
45
|
+
month_of_year: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NAME = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
exports.NAME = 'mergado-get-project-connector';
|
|
10
|
+
class MergadoGetProjectConnector extends AConnector_1.default {
|
|
11
|
+
getName() {
|
|
12
|
+
return exports.NAME;
|
|
13
|
+
}
|
|
14
|
+
async processAction(dto) {
|
|
15
|
+
const { id } = dto.getJsonData();
|
|
16
|
+
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
17
|
+
const url = `projects/${id}/`;
|
|
18
|
+
const req = await this.getApplication().getRequestDto(dto, appInstall, HttpMethods_1.HttpMethods.GET, url);
|
|
19
|
+
const resp = await this.getSender().send(req, [200]);
|
|
20
|
+
return dto.setNewJsonData(resp.getJsonBody());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = MergadoGetProjectConnector;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import AConnector from '@orchesty/nodejs-sdk/dist/lib/Connector/AConnector';
|
|
2
|
+
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
|
|
3
|
+
export declare const NAME = "mergado-get-user-connector";
|
|
4
|
+
export default class MergadoGetUserConnector extends AConnector {
|
|
5
|
+
getName(): string;
|
|
6
|
+
processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>>;
|
|
7
|
+
}
|
|
8
|
+
export interface IInput {
|
|
9
|
+
id: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IOutput {
|
|
12
|
+
id: string;
|
|
13
|
+
first_name: string;
|
|
14
|
+
last_name: string;
|
|
15
|
+
name: string;
|
|
16
|
+
username: string;
|
|
17
|
+
email: string;
|
|
18
|
+
city: string;
|
|
19
|
+
company: string;
|
|
20
|
+
country: string;
|
|
21
|
+
dic: string;
|
|
22
|
+
ico: string;
|
|
23
|
+
invoice_months: number;
|
|
24
|
+
last_access: Date;
|
|
25
|
+
locale: string;
|
|
26
|
+
postcode: string;
|
|
27
|
+
registered_at: Date;
|
|
28
|
+
street: string;
|
|
29
|
+
timezone: string;
|
|
30
|
+
send_summary: boolean;
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NAME = void 0;
|
|
7
|
+
const AConnector_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Connector/AConnector"));
|
|
8
|
+
const HttpMethods_1 = require("@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods");
|
|
9
|
+
exports.NAME = 'mergado-get-user-connector';
|
|
10
|
+
class MergadoGetUserConnector extends AConnector_1.default {
|
|
11
|
+
getName() {
|
|
12
|
+
return exports.NAME;
|
|
13
|
+
}
|
|
14
|
+
async processAction(dto) {
|
|
15
|
+
const { id } = dto.getJsonData();
|
|
16
|
+
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
17
|
+
const url = `users/${id}/`;
|
|
18
|
+
const req = await this.getApplication().getRequestDto(dto, appInstall, HttpMethods_1.HttpMethods.GET, url);
|
|
19
|
+
const resp = await this.getSender().send(req, [200]);
|
|
20
|
+
return dto.setNewJsonData(resp.getJsonBody());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = MergadoGetUserConnector;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
|
|
2
|
+
import FormStack from '@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack';
|
|
3
|
+
import AOAuth2Application from '@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/AOAuth2Application';
|
|
4
|
+
import RequestDto from '@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto';
|
|
5
|
+
import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
|
|
6
|
+
import AProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/AProcessDto';
|
|
7
|
+
export declare const NAME = "mergado";
|
|
8
|
+
export default class MergadoApplication extends AOAuth2Application {
|
|
9
|
+
getName(): string;
|
|
10
|
+
getPublicName(): string;
|
|
11
|
+
getDescription(): string;
|
|
12
|
+
getAuthUrl(): string;
|
|
13
|
+
getTokenUrl(): string;
|
|
14
|
+
getLogo(): string;
|
|
15
|
+
getRequestDto(dto: AProcessDto, applicationInstall: ApplicationInstall, method: HttpMethods, _url?: string, data?: unknown): RequestDto;
|
|
16
|
+
getFormStack(): FormStack;
|
|
17
|
+
isAuthorized(applicationInstall: ApplicationInstall): boolean;
|
|
18
|
+
getScopes(applicationInstall: ApplicationInstall): string[];
|
|
19
|
+
protected _getScopesSeparator(): string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.NAME = void 0;
|
|
40
|
+
const CoreFormsEnum_1 = __importStar(require("@orchesty/nodejs-sdk/dist/lib/Application/Base/CoreFormsEnum"));
|
|
41
|
+
const Field_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Field"));
|
|
42
|
+
const FieldType_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FieldType"));
|
|
43
|
+
const Form_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/Form"));
|
|
44
|
+
const FormStack_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Application/Model/Form/FormStack"));
|
|
45
|
+
const ScopeSeparatorEnum_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Authorization/ScopeSeparatorEnum"));
|
|
46
|
+
const AOAuth2Application_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/AOAuth2Application"));
|
|
47
|
+
const IOAuth2Application_1 = require("@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application");
|
|
48
|
+
const RequestDto_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto"));
|
|
49
|
+
const Headers_1 = require("@orchesty/nodejs-sdk/dist/lib/Utils/Headers");
|
|
50
|
+
exports.NAME = 'mergado';
|
|
51
|
+
class MergadoApplication extends AOAuth2Application_1.default {
|
|
52
|
+
getName() {
|
|
53
|
+
return exports.NAME;
|
|
54
|
+
}
|
|
55
|
+
getPublicName() {
|
|
56
|
+
return 'Mergado';
|
|
57
|
+
}
|
|
58
|
+
getDescription() {
|
|
59
|
+
return 'Software with which you can automate the data flowing from your e-shop to search engines and other advertising systems';
|
|
60
|
+
}
|
|
61
|
+
getAuthUrl() {
|
|
62
|
+
return 'https://app.mergado.com/oauth2/authorize/';
|
|
63
|
+
}
|
|
64
|
+
getTokenUrl() {
|
|
65
|
+
return 'https://app.mergado.com/oauth2/token/';
|
|
66
|
+
}
|
|
67
|
+
getLogo() {
|
|
68
|
+
return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI1LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IlZyc3R2YV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTAwIDEwMDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiM3RkI5MkY7fQoJLnN0MXtmaWxsOiM0MjdCMjc7fQoJLnN0MntmaWxsOiM0NEE4Qjc7fQo8L3N0eWxlPgo8Zz4KCTxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik0wLDBsNTAsNTBMMCwxMDBWMHoiLz4KCTxwYXRoIGNsYXNzPSJzdDEiIGQ9Ik01MCw1MGw1MCw1MEgwTDUwLDUweiIvPgoJPHBhdGggY2xhc3M9InN0MiIgZD0iTTUwLDUwbDUwLTUwdjEwMEw1MCw1MHoiLz4KPC9nPgo8L3N2Zz4K';
|
|
69
|
+
}
|
|
70
|
+
getRequestDto(dto, applicationInstall, method, _url, data) {
|
|
71
|
+
const url = `https://api.mergado.com/${_url}`;
|
|
72
|
+
const request = new RequestDto_1.default(url ?? '', method, dto);
|
|
73
|
+
request.setHeaders({
|
|
74
|
+
[Headers_1.CommonHeaders.CONTENT_TYPE]: Headers_1.JSON_TYPE,
|
|
75
|
+
[Headers_1.CommonHeaders.ACCEPT]: Headers_1.JSON_TYPE,
|
|
76
|
+
[Headers_1.CommonHeaders.AUTHORIZATION]: `Bearer ${this.getAccessToken(applicationInstall)}`,
|
|
77
|
+
});
|
|
78
|
+
if (data) {
|
|
79
|
+
request.setJsonBody(data);
|
|
80
|
+
}
|
|
81
|
+
return request;
|
|
82
|
+
}
|
|
83
|
+
getFormStack() {
|
|
84
|
+
const form = new Form_1.default(CoreFormsEnum_1.default.AUTHORIZATION_FORM, (0, CoreFormsEnum_1.getFormName)(CoreFormsEnum_1.default.AUTHORIZATION_FORM))
|
|
85
|
+
.addField(new Field_1.default(FieldType_1.default.TEXT, IOAuth2Application_1.CLIENT_ID, 'Client Id', null, true))
|
|
86
|
+
.addField(new Field_1.default(FieldType_1.default.TEXT, IOAuth2Application_1.CLIENT_SECRET, 'Client Secret', null, true));
|
|
87
|
+
return new FormStack_1.default()
|
|
88
|
+
.addForm(form);
|
|
89
|
+
}
|
|
90
|
+
isAuthorized(applicationInstall) {
|
|
91
|
+
const authorizationForm = applicationInstall.getSettings()[CoreFormsEnum_1.default.AUTHORIZATION_FORM];
|
|
92
|
+
return super.isAuthorized(applicationInstall)
|
|
93
|
+
&& authorizationForm?.[IOAuth2Application_1.CLIENT_ID]
|
|
94
|
+
&& authorizationForm?.[IOAuth2Application_1.CLIENT_SECRET];
|
|
95
|
+
}
|
|
96
|
+
getScopes(applicationInstall) {
|
|
97
|
+
return [
|
|
98
|
+
'shop.read',
|
|
99
|
+
'user.read',
|
|
100
|
+
'project.read',
|
|
101
|
+
'project.elements.write',
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
_getScopesSeparator() {
|
|
105
|
+
return ScopeSeparatorEnum_1.default.SPACE;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.default = MergadoApplication;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orchesty/connector-mergado",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"url": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
7
|
+
"repository": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rm -rf dist && rm -rf tsconfig.prod.tsbuildinfo && tsc -d -p tsconfig.prod.json && cp package.json ./dist/package.json",
|
|
10
|
+
"test": "jest --coverage --forceExit --passWithNoTests",
|
|
11
|
+
"lint": "eslint src test --fix",
|
|
12
|
+
"lint-ci": "eslint src test"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "info@hanaboso.com",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@orchesty/nodejs-sdk": "^4.3.6"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=24"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const baseConfig = require('../../jest.config.js');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
...baseConfig,
|
|
5
|
+
roots: ["<rootDir>/src"],
|
|
6
|
+
setupFiles: ["<rootDir>/../../.jest/testEnvs.ts"],
|
|
7
|
+
setupFilesAfterEnv: ["<rootDir>/../../.jest/testLifecycle.ts"],
|
|
8
|
+
globalSetup: "<rootDir>/../../.jest/globalSetup.ts",
|
|
9
|
+
moduleNameMapper: {
|
|
10
|
+
"^@orchesty/nodejs-connectors/test/(.*)$": "<rootDir>/../../test/$1",
|
|
11
|
+
"^@orchesty/nodejs-connectors/lib/(.*)$": "<rootDir>/../../lib/$1",
|
|
12
|
+
},
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orchesty/connector-mergado",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"url": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
7
|
+
"repository": "https://github.com/Orchesty/orchesty-nodejs-connectors",
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "info@hanaboso.com",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@orchesty/nodejs-sdk": "^4.3.6"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=24"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rm -rf dist && rm -rf tsconfig.prod.tsbuildinfo && tsc -d -p tsconfig.prod.json && cp package.json ./dist/package.json",
|
|
18
|
+
"test": "jest --coverage --forceExit --passWithNoTests",
|
|
19
|
+
"lint": "eslint src test --fix",
|
|
20
|
+
"lint-ci": "eslint src test"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
|
|
5
|
+
export const NAME = 'mergado-list-apps-batch';
|
|
6
|
+
const LIMIT = 99;
|
|
7
|
+
|
|
8
|
+
export default class MergadoListAppsBatch extends ABatchNode {
|
|
9
|
+
|
|
10
|
+
public getName(): string {
|
|
11
|
+
return NAME;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
|
|
15
|
+
const offset = Number(dto.getBatchCursor('0'));
|
|
16
|
+
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
17
|
+
const url = `apps/?limit=${LIMIT}&offset=${offset}`;
|
|
18
|
+
const req = await this.getApplication().getRequestDto(
|
|
19
|
+
dto,
|
|
20
|
+
appInstall,
|
|
21
|
+
HttpMethods.GET,
|
|
22
|
+
url,
|
|
23
|
+
);
|
|
24
|
+
const resp = await this.getSender().send<IResponse>(req, [200]);
|
|
25
|
+
const response = resp.getJsonBody();
|
|
26
|
+
|
|
27
|
+
dto.setItemList(response.data ?? []);
|
|
28
|
+
if (response.total_results === LIMIT + 1) {
|
|
29
|
+
dto.setBatchCursor((offset + LIMIT).toString());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return dto;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
38
|
+
|
|
39
|
+
interface IResponse {
|
|
40
|
+
data: IOutput[];
|
|
41
|
+
limit: number;
|
|
42
|
+
total_results: number;
|
|
43
|
+
offset: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface IOutput {
|
|
47
|
+
creation_date: Date;
|
|
48
|
+
forum_url: string;
|
|
49
|
+
latest_release_date: Date;
|
|
50
|
+
title: string;
|
|
51
|
+
trial_period: number;
|
|
52
|
+
type: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -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 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
|
+
});
|
|
@@ -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 = '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
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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 */
|
|
@@ -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
|
+
|
|
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 */
|