@orchesty/connector-wix 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 +125 -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 +146 -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/Connector/WixCreateOrderConnector.ts.html +679 -0
- package/coverage/lcov-report/src/Connector/WixCreateProductConnector.ts.html +781 -0
- package/coverage/lcov-report/src/Connector/WixGetOrderConnector.ts.html +493 -0
- package/coverage/lcov-report/src/Connector/WixUpdateProductConnector.ts.html +574 -0
- package/coverage/lcov-report/src/Connector/index.html +161 -0
- package/coverage/lcov-report/src/WixApplication.ts.html +334 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/test/dataProvider.ts.html +268 -0
- package/coverage/lcov-report/test/index.html +116 -0
- package/coverage/lcov.info +189 -0
- package/dist/Connector/WixCreateOrderConnector.d.ts +181 -0
- package/dist/Connector/WixCreateOrderConnector.js +21 -0
- package/dist/Connector/WixCreateProductConnector.d.ts +217 -0
- package/dist/Connector/WixCreateProductConnector.js +21 -0
- package/dist/Connector/WixGetOrderConnector.d.ts +119 -0
- package/dist/Connector/WixGetOrderConnector.js +22 -0
- package/dist/Connector/WixUpdateProductConnector.d.ts +147 -0
- package/dist/Connector/WixUpdateProductConnector.js +22 -0
- package/dist/WixApplication.d.ts +19 -0
- package/dist/WixApplication.js +97 -0
- package/dist/package.json +22 -0
- package/jest.config.js +13 -0
- package/package.json +22 -0
- package/src/Connector/WixCreateOrderConnector.ts +198 -0
- package/src/Connector/WixCreateProductConnector.ts +232 -0
- package/src/Connector/WixGetOrderConnector.ts +136 -0
- package/src/Connector/WixUpdateProductConnector.ts +163 -0
- package/src/Connector/__tests__/Data/WixCreateOrderConnector/input.json +74 -0
- package/src/Connector/__tests__/Data/WixCreateOrderConnector/mock.json +109 -0
- package/src/Connector/__tests__/Data/WixCreateOrderConnector/output.json +110 -0
- package/src/Connector/__tests__/Data/WixCreateProductConnector/input.json +43 -0
- package/src/Connector/__tests__/Data/WixCreateProductConnector/mock.json +180 -0
- package/src/Connector/__tests__/Data/WixCreateProductConnector/output.json +181 -0
- package/src/Connector/__tests__/Data/WixGetOrderConnector/input.json +8 -0
- package/src/Connector/__tests__/Data/WixGetOrderConnector/mock.json +113 -0
- package/src/Connector/__tests__/Data/WixGetOrderConnector/output.json +114 -0
- package/src/Connector/__tests__/Data/WixUpdateProductConnector/input.json +36 -0
- package/src/Connector/__tests__/Data/WixUpdateProductConnector/mock.json +115 -0
- package/src/Connector/__tests__/Data/WixUpdateProductConnector/output.json +117 -0
- package/src/Connector/__tests__/WixCreateOrderConnector.ts +17 -0
- package/src/Connector/__tests__/WixCreateProductConnector.ts +17 -0
- package/src/Connector/__tests__/WixGetOrderConnector.ts +17 -0
- package/src/Connector/__tests__/WixUpdateProductConnector.ts +17 -0
- package/src/WixApplication.ts +83 -0
- package/test/dataProvider.ts +61 -0
- package/tsconfig.json +8 -0
- package/tsconfig.prod.json +13 -0
- package/tsconfig.prod.tsbuildinfo +1 -0
|
@@ -0,0 +1,147 @@
|
|
|
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 = "wix-update-product-connector";
|
|
4
|
+
export default class WixUpdateProductConnector extends AConnector {
|
|
5
|
+
getName(): string;
|
|
6
|
+
processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>>;
|
|
7
|
+
}
|
|
8
|
+
export interface IInput {
|
|
9
|
+
productId: string;
|
|
10
|
+
product: {
|
|
11
|
+
name: string;
|
|
12
|
+
productType: string;
|
|
13
|
+
priceData: {
|
|
14
|
+
price: number;
|
|
15
|
+
};
|
|
16
|
+
description: string;
|
|
17
|
+
sku: string;
|
|
18
|
+
visible: boolean;
|
|
19
|
+
weight: number;
|
|
20
|
+
ribbon: string;
|
|
21
|
+
brand: string;
|
|
22
|
+
discount: {
|
|
23
|
+
type: string;
|
|
24
|
+
value: number;
|
|
25
|
+
};
|
|
26
|
+
productOptions: [
|
|
27
|
+
{
|
|
28
|
+
name: string;
|
|
29
|
+
choices: [
|
|
30
|
+
{
|
|
31
|
+
value: string;
|
|
32
|
+
description: string;
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface IOutput {
|
|
40
|
+
product: {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
slug: string;
|
|
44
|
+
visible: boolean;
|
|
45
|
+
productType: string;
|
|
46
|
+
description: string;
|
|
47
|
+
stock: {
|
|
48
|
+
trackInventory: boolean;
|
|
49
|
+
inStock: boolean;
|
|
50
|
+
};
|
|
51
|
+
price: {
|
|
52
|
+
currency: string;
|
|
53
|
+
price: number;
|
|
54
|
+
discountedPrice: number;
|
|
55
|
+
formatted: {
|
|
56
|
+
price: string;
|
|
57
|
+
discountedPrice: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
priceData: {
|
|
61
|
+
currency: string;
|
|
62
|
+
price: string;
|
|
63
|
+
discountedPrice: number;
|
|
64
|
+
formatted: {
|
|
65
|
+
price: string;
|
|
66
|
+
discountedPrice: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
convertedPriceData: {
|
|
70
|
+
currency: string;
|
|
71
|
+
price: number;
|
|
72
|
+
discountedPrice: number;
|
|
73
|
+
formatted: {
|
|
74
|
+
price: string;
|
|
75
|
+
discountedPrice: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
additionalInfoSections: [];
|
|
79
|
+
ribbons: {
|
|
80
|
+
text: string;
|
|
81
|
+
}[];
|
|
82
|
+
media: {
|
|
83
|
+
items: [];
|
|
84
|
+
};
|
|
85
|
+
customTextFields: [];
|
|
86
|
+
manageVariants: boolean;
|
|
87
|
+
productOptions: [
|
|
88
|
+
{
|
|
89
|
+
optionType: string;
|
|
90
|
+
name: string;
|
|
91
|
+
choices: [
|
|
92
|
+
{
|
|
93
|
+
value: string;
|
|
94
|
+
description: string;
|
|
95
|
+
inStock: boolean;
|
|
96
|
+
visible: boolean;
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
productPageUrl: {
|
|
102
|
+
base: string;
|
|
103
|
+
path: string;
|
|
104
|
+
};
|
|
105
|
+
numericId: string;
|
|
106
|
+
inventoryItemId: string;
|
|
107
|
+
discount: {
|
|
108
|
+
type: string;
|
|
109
|
+
value: number;
|
|
110
|
+
};
|
|
111
|
+
collectionIds: [];
|
|
112
|
+
variants: [
|
|
113
|
+
{
|
|
114
|
+
id: string;
|
|
115
|
+
choices: {
|
|
116
|
+
Size: string;
|
|
117
|
+
};
|
|
118
|
+
variant: {
|
|
119
|
+
priceData: {
|
|
120
|
+
currency: string;
|
|
121
|
+
price: number;
|
|
122
|
+
discountedPrice: number;
|
|
123
|
+
formatted: {
|
|
124
|
+
price: string;
|
|
125
|
+
discountedPrice: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
convertedPriceData: {
|
|
129
|
+
currency: string;
|
|
130
|
+
price: number;
|
|
131
|
+
discountedPrice: number;
|
|
132
|
+
formatted: {
|
|
133
|
+
price: string;
|
|
134
|
+
discountedPrice: string;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
weight: number;
|
|
138
|
+
sku: string;
|
|
139
|
+
visible: boolean;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
lastUpdated: string;
|
|
144
|
+
ribbon: string;
|
|
145
|
+
brand: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 = 'wix-update-product-connector';
|
|
10
|
+
class WixUpdateProductConnector extends AConnector_1.default {
|
|
11
|
+
getName() {
|
|
12
|
+
return exports.NAME;
|
|
13
|
+
}
|
|
14
|
+
async processAction(dto) {
|
|
15
|
+
const { productId, ...body } = dto.getJsonData();
|
|
16
|
+
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
17
|
+
const req = await this.getApplication().getRequestDto(dto, appInstall, HttpMethods_1.HttpMethods.PATCH, `v1/products/${productId}`, body);
|
|
18
|
+
const resp = await this.getSender().send(req, [200]);
|
|
19
|
+
return dto.setNewJsonData(resp.getJsonBody());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = WixUpdateProductConnector;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 = "wix";
|
|
8
|
+
export default class WixApplication extends AOAuth2Application {
|
|
9
|
+
getScopes(applicationInstall: ApplicationInstall): string[];
|
|
10
|
+
getName(): string;
|
|
11
|
+
getAuthUrl(): string;
|
|
12
|
+
getTokenUrl(): string;
|
|
13
|
+
getPublicName(): string;
|
|
14
|
+
getDescription(): string;
|
|
15
|
+
getLogo(): string;
|
|
16
|
+
getRequestDto(dto: AProcessDto, applicationInstall: ApplicationInstall, method: HttpMethods, _url?: string, data?: unknown): RequestDto;
|
|
17
|
+
getFormStack(): FormStack;
|
|
18
|
+
isAuthorized(applicationInstall: ApplicationInstall): boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 AOAuth2Application_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/AOAuth2Application"));
|
|
46
|
+
const IOAuth2Application_1 = require("@orchesty/nodejs-sdk/dist/lib/Authorization/Type/OAuth2/IOAuth2Application");
|
|
47
|
+
const RequestDto_1 = __importDefault(require("@orchesty/nodejs-sdk/dist/lib/Transport/Curl/RequestDto"));
|
|
48
|
+
const Headers_1 = require("@orchesty/nodejs-sdk/dist/lib/Utils/Headers");
|
|
49
|
+
exports.NAME = 'wix';
|
|
50
|
+
class WixApplication extends AOAuth2Application_1.default {
|
|
51
|
+
getScopes(applicationInstall) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
getName() {
|
|
55
|
+
return exports.NAME;
|
|
56
|
+
}
|
|
57
|
+
getAuthUrl() {
|
|
58
|
+
return 'https://www.wix.com/installer/install';
|
|
59
|
+
}
|
|
60
|
+
getTokenUrl() {
|
|
61
|
+
return 'https://www.wixapis.com/oauth/access';
|
|
62
|
+
}
|
|
63
|
+
getPublicName() {
|
|
64
|
+
return 'Wix';
|
|
65
|
+
}
|
|
66
|
+
getDescription() {
|
|
67
|
+
return 'Simple cloud-based platform for web development';
|
|
68
|
+
}
|
|
69
|
+
getLogo() {
|
|
70
|
+
return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI1LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IlZyc3R2YV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTAwIDEwMDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8cGF0aCBkPSJNNjEuNSwzMC43YzAsMiwwLjMsNS4xLTQuNSw2LjhjLTEuNSwwLjUtMi41LDEuNS0yLjUsMS41YzAtNC44LDAuNy02LjYsMi43LTcuNkM1OC43LDMwLjYsNjEuNSwzMC43LDYxLjUsMzAuN3ogTTQzLjQsMzYuMgoJbC01LjMsMjAuN0wzMy42LDQwYy0xLjItNS0zLjItNy42LTcuNS03LjZjLTQuMywwLTYuMywyLjUtNy41LDcuNmwtNC40LDE2LjlMOC43LDM2LjJjLTAuOS00LjItNC45LTYtOC42LTUuNWwxMC4yLDM4LjYKCWMwLDAsMy40LDAuMiw1LjEtMC42YzIuMi0xLjEsMy4zLTIsNC42LTcuM2MxLjItNC43LDQuNS0xOC41LDQuOS0xOS40YzAuNy0yLjMsMS43LTIuMiwyLjQsMGMwLjMsMSwzLjcsMTQuOCw0LjksMTkuNAoJYzEuMyw1LjMsMi40LDYuMSw0LjYsNy4zYzEuNywwLjksNS4xLDAuNiw1LjEsMC42TDUyLDMwLjdDNDguMiwzMC4yLDQ0LjMsMzIuMSw0My40LDM2LjJMNDMuNCwzNi4yeiBNNjEuNCwzN2MwLDAtMC42LDEtMi4xLDEuOAoJYy0wLjksMC41LTEuOCwwLjktMi44LDEuM2MtMi40LDEuMS0yLjEsMi4yLTIuMSw1LjV2MjMuN2MwLDAsMi42LDAuMyw0LjMtMC41YzIuMi0xLjEsMi43LTIuMiwyLjctN1YzOC40bDAsMEw2MS40LDM3TDYxLjQsMzd6CgkgTTg2LjksNTAuMWwxMy0xOS4zYzAsMC01LjUtMC45LTguMiwxLjVjLTIuMSwxLjktMy44LDQuNi04LjQsMTEuM2MtMC4xLDAuMS0xLDEuNi0yLDBjLTQuNi02LjYtNi40LTkuNC04LjQtMTEuMwoJYy0yLjctMi41LTguMi0xLjUtOC4yLTEuNWwxMywxOS4zTDY0LjYsNjkuNGMwLDAsNS43LDAuNyw4LjQtMS43YzEuOC0xLjYsMi43LTMuMiw4LjItMTFjMS4xLTEuNiwyLTAuMSwyLDBjNC42LDYuNiw2LjEsOSw4LjMsMTEKCWMyLjcsMi41LDguMywxLjcsOC4zLDEuN0w4Ni45LDUwLjFMODYuOSw1MC4xeiIvPgo8L3N2Zz4K';
|
|
71
|
+
}
|
|
72
|
+
getRequestDto(dto, applicationInstall, method, _url, data) {
|
|
73
|
+
const request = new RequestDto_1.default(`https://www.wixapis.com/stores/${_url}`, method, dto);
|
|
74
|
+
request.setHeaders({
|
|
75
|
+
[Headers_1.CommonHeaders.CONTENT_TYPE]: Headers_1.JSON_TYPE,
|
|
76
|
+
[Headers_1.CommonHeaders.ACCEPT]: Headers_1.JSON_TYPE,
|
|
77
|
+
[Headers_1.CommonHeaders.AUTHORIZATION]: this.getAccessToken(applicationInstall),
|
|
78
|
+
});
|
|
79
|
+
if (data) {
|
|
80
|
+
request.setJsonBody(data);
|
|
81
|
+
}
|
|
82
|
+
return request;
|
|
83
|
+
}
|
|
84
|
+
getFormStack() {
|
|
85
|
+
const form = new Form_1.default(CoreFormsEnum_1.default.AUTHORIZATION_FORM, (0, CoreFormsEnum_1.getFormName)(CoreFormsEnum_1.default.AUTHORIZATION_FORM))
|
|
86
|
+
.addField(new Field_1.default(FieldType_1.default.TEXT, IOAuth2Application_1.CLIENT_ID, 'Client Id', undefined, true))
|
|
87
|
+
.addField(new Field_1.default(FieldType_1.default.TEXT, IOAuth2Application_1.CLIENT_SECRET, 'Client Secret', undefined, true));
|
|
88
|
+
return new FormStack_1.default().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
|
+
}
|
|
97
|
+
exports.default = WixApplication;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orchesty/connector-wix",
|
|
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-wix",
|
|
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,198 @@
|
|
|
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 = 'wix-create-order-connector';
|
|
6
|
+
|
|
7
|
+
export default class WixCreateOrderConnector extends AConnector {
|
|
8
|
+
|
|
9
|
+
public getName(): string {
|
|
10
|
+
return NAME;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
|
|
14
|
+
const appInstall = await this.getApplicationInstallFromProcess(dto);
|
|
15
|
+
const req = await this.getApplication().getRequestDto(
|
|
16
|
+
dto,
|
|
17
|
+
appInstall,
|
|
18
|
+
HttpMethods.POST,
|
|
19
|
+
'v2/orders',
|
|
20
|
+
{ data: dto.getJsonData() },
|
|
21
|
+
);
|
|
22
|
+
const resp = await this.getSender().send<IOutput>(req, [200]);
|
|
23
|
+
|
|
24
|
+
return dto.setNewJsonData(resp.getJsonBody());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface IOutput {
|
|
30
|
+
order: {
|
|
31
|
+
id: string;
|
|
32
|
+
number: number;
|
|
33
|
+
dateCreated: string;
|
|
34
|
+
currency: string;
|
|
35
|
+
weightUnit: string;
|
|
36
|
+
totals: {
|
|
37
|
+
subtotal: string;
|
|
38
|
+
shipping: string;
|
|
39
|
+
tax: string;
|
|
40
|
+
discount: string;
|
|
41
|
+
total: string;
|
|
42
|
+
weight: string;
|
|
43
|
+
quantity: number;
|
|
44
|
+
};
|
|
45
|
+
billingInfo: {
|
|
46
|
+
paymentMethod: string;
|
|
47
|
+
externalTransactionId: string;
|
|
48
|
+
paymentProviderTransactionId: string;
|
|
49
|
+
address: {
|
|
50
|
+
fullName: {
|
|
51
|
+
firstName: string;
|
|
52
|
+
lastName: string;
|
|
53
|
+
};
|
|
54
|
+
country: string;
|
|
55
|
+
city: string;
|
|
56
|
+
zipCode: string;
|
|
57
|
+
phone: string;
|
|
58
|
+
email: string;
|
|
59
|
+
};
|
|
60
|
+
paidDate: string;
|
|
61
|
+
};
|
|
62
|
+
shippingInfo: {
|
|
63
|
+
deliveryOption: string;
|
|
64
|
+
estimatedDeliveryTime: string;
|
|
65
|
+
shipmentDetails: {
|
|
66
|
+
address: {
|
|
67
|
+
fullName: {
|
|
68
|
+
firstName: string;
|
|
69
|
+
lastName: string;
|
|
70
|
+
};
|
|
71
|
+
country: string;
|
|
72
|
+
city: string;
|
|
73
|
+
zipCode: string;
|
|
74
|
+
phone: string;
|
|
75
|
+
email: string;
|
|
76
|
+
};
|
|
77
|
+
discount: string;
|
|
78
|
+
tax: string;
|
|
79
|
+
priceData: {
|
|
80
|
+
taxIncludedInPrice: boolean;
|
|
81
|
+
price: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
read: boolean;
|
|
86
|
+
archived: boolean;
|
|
87
|
+
paymentStatus: string;
|
|
88
|
+
fulfillmentStatus: string;
|
|
89
|
+
lineItems: [{
|
|
90
|
+
index: number;
|
|
91
|
+
quantity: number;
|
|
92
|
+
name: string;
|
|
93
|
+
productId: string;
|
|
94
|
+
lineItemType: string;
|
|
95
|
+
options: [];
|
|
96
|
+
customTextFields: [];
|
|
97
|
+
weight: string;
|
|
98
|
+
sku: string;
|
|
99
|
+
discount: string;
|
|
100
|
+
tax: string;
|
|
101
|
+
priceData: {
|
|
102
|
+
taxIncludedInPrice: boolean;
|
|
103
|
+
price: string;
|
|
104
|
+
totalPrice: string;
|
|
105
|
+
};
|
|
106
|
+
}];
|
|
107
|
+
activities: [
|
|
108
|
+
{
|
|
109
|
+
type: string;
|
|
110
|
+
timestamp: string;
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: string;
|
|
114
|
+
timestamp: string;
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
fulfillments: [];
|
|
118
|
+
discount: { value: string };
|
|
119
|
+
buyerLanguage: string;
|
|
120
|
+
channelInfo: { type: string };
|
|
121
|
+
enteredBy: {
|
|
122
|
+
id: string;
|
|
123
|
+
identityType: string;
|
|
124
|
+
};
|
|
125
|
+
lastUpdated: string;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface IInput {
|
|
130
|
+
|
|
131
|
+
order: {
|
|
132
|
+
totals: {
|
|
133
|
+
subtotal: string;
|
|
134
|
+
shipping: string;
|
|
135
|
+
tax: string;
|
|
136
|
+
discount: string;
|
|
137
|
+
total: string;
|
|
138
|
+
};
|
|
139
|
+
billingInfo: {
|
|
140
|
+
paymentMethod: string;
|
|
141
|
+
paymentProviderTransactionId: string;
|
|
142
|
+
address: {
|
|
143
|
+
fullName: {
|
|
144
|
+
firstName: string;
|
|
145
|
+
lastName: string;
|
|
146
|
+
};
|
|
147
|
+
country: string;
|
|
148
|
+
city: string;
|
|
149
|
+
zipCode: string;
|
|
150
|
+
phone: string;
|
|
151
|
+
email: string;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
shippingInfo: {
|
|
155
|
+
deliveryOption: string;
|
|
156
|
+
estimatedDeliveryTime: string;
|
|
157
|
+
shippingRegion: string;
|
|
158
|
+
shipmentDetails: {
|
|
159
|
+
address: {
|
|
160
|
+
fullName: {
|
|
161
|
+
firstName: string;
|
|
162
|
+
lastName: string;
|
|
163
|
+
};
|
|
164
|
+
country: string;
|
|
165
|
+
city: string;
|
|
166
|
+
zipCode: string;
|
|
167
|
+
phone: string;
|
|
168
|
+
email: string;
|
|
169
|
+
};
|
|
170
|
+
tax: string;
|
|
171
|
+
priceData: {
|
|
172
|
+
taxIncludedInPrice: boolean;
|
|
173
|
+
price: string;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
paymentStatus: string;
|
|
178
|
+
lineItems: [
|
|
179
|
+
{
|
|
180
|
+
quantity: number;
|
|
181
|
+
discount: string;
|
|
182
|
+
tax: string;
|
|
183
|
+
name: string;
|
|
184
|
+
productId: string;
|
|
185
|
+
lineItemType: string;
|
|
186
|
+
weight: string;
|
|
187
|
+
sku: string;
|
|
188
|
+
priceData: {
|
|
189
|
+
taxIncludedInPrice: boolean;
|
|
190
|
+
price: string;
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
];
|
|
194
|
+
channelInfo: {
|
|
195
|
+
type: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
}
|