@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.
Files changed (60) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +190 -0
  3. package/coverage/clover.xml +125 -0
  4. package/coverage/coverage-final.json +7 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +146 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +210 -0
  13. package/coverage/lcov-report/src/Connector/WixCreateOrderConnector.ts.html +679 -0
  14. package/coverage/lcov-report/src/Connector/WixCreateProductConnector.ts.html +781 -0
  15. package/coverage/lcov-report/src/Connector/WixGetOrderConnector.ts.html +493 -0
  16. package/coverage/lcov-report/src/Connector/WixUpdateProductConnector.ts.html +574 -0
  17. package/coverage/lcov-report/src/Connector/index.html +161 -0
  18. package/coverage/lcov-report/src/WixApplication.ts.html +334 -0
  19. package/coverage/lcov-report/src/index.html +116 -0
  20. package/coverage/lcov-report/test/dataProvider.ts.html +268 -0
  21. package/coverage/lcov-report/test/index.html +116 -0
  22. package/coverage/lcov.info +189 -0
  23. package/dist/Connector/WixCreateOrderConnector.d.ts +181 -0
  24. package/dist/Connector/WixCreateOrderConnector.js +21 -0
  25. package/dist/Connector/WixCreateProductConnector.d.ts +217 -0
  26. package/dist/Connector/WixCreateProductConnector.js +21 -0
  27. package/dist/Connector/WixGetOrderConnector.d.ts +119 -0
  28. package/dist/Connector/WixGetOrderConnector.js +22 -0
  29. package/dist/Connector/WixUpdateProductConnector.d.ts +147 -0
  30. package/dist/Connector/WixUpdateProductConnector.js +22 -0
  31. package/dist/WixApplication.d.ts +19 -0
  32. package/dist/WixApplication.js +97 -0
  33. package/dist/package.json +22 -0
  34. package/jest.config.js +13 -0
  35. package/package.json +22 -0
  36. package/src/Connector/WixCreateOrderConnector.ts +198 -0
  37. package/src/Connector/WixCreateProductConnector.ts +232 -0
  38. package/src/Connector/WixGetOrderConnector.ts +136 -0
  39. package/src/Connector/WixUpdateProductConnector.ts +163 -0
  40. package/src/Connector/__tests__/Data/WixCreateOrderConnector/input.json +74 -0
  41. package/src/Connector/__tests__/Data/WixCreateOrderConnector/mock.json +109 -0
  42. package/src/Connector/__tests__/Data/WixCreateOrderConnector/output.json +110 -0
  43. package/src/Connector/__tests__/Data/WixCreateProductConnector/input.json +43 -0
  44. package/src/Connector/__tests__/Data/WixCreateProductConnector/mock.json +180 -0
  45. package/src/Connector/__tests__/Data/WixCreateProductConnector/output.json +181 -0
  46. package/src/Connector/__tests__/Data/WixGetOrderConnector/input.json +8 -0
  47. package/src/Connector/__tests__/Data/WixGetOrderConnector/mock.json +113 -0
  48. package/src/Connector/__tests__/Data/WixGetOrderConnector/output.json +114 -0
  49. package/src/Connector/__tests__/Data/WixUpdateProductConnector/input.json +36 -0
  50. package/src/Connector/__tests__/Data/WixUpdateProductConnector/mock.json +115 -0
  51. package/src/Connector/__tests__/Data/WixUpdateProductConnector/output.json +117 -0
  52. package/src/Connector/__tests__/WixCreateOrderConnector.ts +17 -0
  53. package/src/Connector/__tests__/WixCreateProductConnector.ts +17 -0
  54. package/src/Connector/__tests__/WixGetOrderConnector.ts +17 -0
  55. package/src/Connector/__tests__/WixUpdateProductConnector.ts +17 -0
  56. package/src/WixApplication.ts +83 -0
  57. package/test/dataProvider.ts +61 -0
  58. package/tsconfig.json +8 -0
  59. package/tsconfig.prod.json +13 -0
  60. package/tsconfig.prod.tsbuildinfo +1 -0
@@ -0,0 +1,232 @@
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-product-connector';
6
+
7
+ export default class WixCreateProductConnector 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
+ 'v1/products',
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
+ /* eslint-disable @typescript-eslint/naming-convention */
30
+ export interface IInput {
31
+ product: {
32
+ name: string;
33
+ productType: string;
34
+ priceData: {
35
+ price: number;
36
+ };
37
+ costAndProfitData: {
38
+ itemCost: number;
39
+ };
40
+ description: string;
41
+ sku: string;
42
+ visible: boolean;
43
+ ribbon: string;
44
+ brand: string;
45
+ weight: number;
46
+ discount: {
47
+ type: string;
48
+ value: number;
49
+ };
50
+ manageVariants: boolean;
51
+ productOptions: [
52
+ {
53
+ name: string;
54
+ choices: [
55
+ {
56
+ value: string;
57
+ description: string;
58
+ },
59
+ {
60
+ value: string;
61
+ description: string;
62
+ },
63
+ ];
64
+ },
65
+ ];
66
+ };
67
+ }
68
+
69
+ export interface IOutput {
70
+ product: {
71
+ id: string;
72
+ name: string;
73
+ slug: string;
74
+ visible: boolean;
75
+ productType: string;
76
+ description: string;
77
+ weightRange: {
78
+ minValue: number;
79
+ maxValue: number;
80
+ };
81
+ stock: {
82
+ trackInventory: boolean;
83
+ inStock: boolean;
84
+ inventoryStatus: string;
85
+ };
86
+ price: {
87
+ currency: string;
88
+ price: number;
89
+ discountedPrice: number;
90
+ formatted: {
91
+ price: string;
92
+ discountedPrice: string;
93
+ };
94
+ };
95
+ priceData: {
96
+ currency: string;
97
+ price: number;
98
+ discountedPrice: number;
99
+ formatted: {
100
+ price: string;
101
+ discountedPrice: string;
102
+ };
103
+ };
104
+ convertedPriceData: {
105
+ currency: string;
106
+ price: number;
107
+ discountedPrice: number;
108
+ formatted: {
109
+ price: string;
110
+ discountedPrice: string;
111
+ };
112
+ };
113
+ priceRange: {
114
+ minValue: number;
115
+ maxValue: number;
116
+ };
117
+ costRange: {
118
+ minValue: number;
119
+ maxValue: number;
120
+ };
121
+ additionalInfoSections: [];
122
+ ribbons: { text: string }[];
123
+ media: { items: [] };
124
+ customTextFields: [];
125
+ manageVariants: boolean;
126
+ productOptions: [{
127
+ optionType: string;
128
+ name: string;
129
+ choices: [
130
+ {
131
+ value: string;
132
+ description: string;
133
+ inStock: boolean;
134
+ visible: boolean;
135
+ },
136
+ {
137
+ value: string;
138
+ description: string;
139
+ inStock: boolean;
140
+ visible: boolean;
141
+ },
142
+ ];
143
+ }];
144
+ productPageUrl: {
145
+ base: string;
146
+ path: string;
147
+ };
148
+ numericId: string;
149
+ inventoryItemId: string;
150
+ discount: {
151
+ type: string;
152
+ value: number;
153
+ };
154
+ collectionIds: string[];
155
+ variants: [
156
+ {
157
+ id: string;
158
+ choices: { Size: string };
159
+ variant: {
160
+ priceData: {
161
+ currency: string;
162
+ price: number;
163
+ discountedPrice: number;
164
+ formatted: {
165
+ price: string;
166
+ discountedPrice: string;
167
+ };
168
+ };
169
+ convertedPriceData: {
170
+ currency: string;
171
+ price: number;
172
+ discountedPrice: number;
173
+ formatted: {
174
+ price: string;
175
+ discountedPrice: string;
176
+ };
177
+ };
178
+ costAndProfitData: {
179
+ itemCost: number;
180
+ formattedItemCost: string;
181
+ profit: number;
182
+ formattedProfit: string;
183
+ profitMargin: number;
184
+ };
185
+ weight: number;
186
+ sku: string;
187
+ visible: boolean;
188
+ };
189
+ },
190
+ {
191
+ id: string;
192
+ choices: { Size: string };
193
+ variant: {
194
+ priceData: {
195
+ currency: string;
196
+ price: number;
197
+ discountedPrice: number;
198
+ formatted: {
199
+ price: string;
200
+ discountedPrice: string;
201
+ };
202
+ };
203
+ convertedPriceData: {
204
+ currency: string;
205
+ price: number;
206
+ discountedPrice: number;
207
+ formatted: {
208
+ price: string;
209
+ discountedPrice: string;
210
+ };
211
+ };
212
+ costAndProfitData: {
213
+ itemCost: number;
214
+ formattedItemCost: string;
215
+ profit: number;
216
+ formattedProfit: string;
217
+ profitMargin: number;
218
+ };
219
+ weight: number;
220
+ sku: string;
221
+ visible: boolean;
222
+ };
223
+ },
224
+ ];
225
+ lastUpdated: string;
226
+ createdDate: string;
227
+ ribbon: string;
228
+ brand: string;
229
+ };
230
+ }
231
+
232
+ /* eslint-enable @typescript-eslint/naming-convention */
@@ -0,0 +1,136 @@
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-get-order-connector';
6
+
7
+ export default class WixGetOrderConnector 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 req = await this.getApplication().getRequestDto(
18
+ dto,
19
+ appInstall,
20
+ HttpMethods.GET,
21
+ `v2/orders/${id}`,
22
+ );
23
+ const resp = await this.getSender().send<IOutput>(req, [200]);
24
+
25
+ return dto.setNewJsonData(resp.getJsonBody());
26
+ }
27
+
28
+ }
29
+
30
+ export interface IInput {
31
+ id: string;
32
+ }
33
+
34
+ export interface IOutput {
35
+ order: {
36
+ id: string;
37
+ number: number;
38
+ dateCreated: string;
39
+ currency: string;
40
+ weightUnit: string;
41
+ totals: {
42
+ subtotal: string;
43
+ shipping: string;
44
+ tax: string;
45
+ discount: string;
46
+ total: string;
47
+ weight: string;
48
+ quantity: number;
49
+ };
50
+ billingInfo: {
51
+ paymentMethod: string;
52
+ externalTransactionId: string;
53
+ paymentProviderTransactionId: string;
54
+ address: {
55
+ fullName: {
56
+ firstName: string;
57
+ lastName: string;
58
+ };
59
+ country: string;
60
+ city: string;
61
+ zipCode: string;
62
+ phone: string;
63
+ email: string;
64
+ };
65
+ paidDate: string;
66
+ };
67
+ shippingInfo: {
68
+ deliveryOption: string;
69
+ shippingRegion: string;
70
+ estimatedDeliveryTime: string;
71
+ shipmentDetails: {
72
+ address: {
73
+ fullName: {
74
+ firstName: string;
75
+ lastName: string;
76
+ };
77
+ country: string;
78
+ city: string;
79
+ zipCode: string;
80
+ phone: string;
81
+ email: string;
82
+ };
83
+ discount: string;
84
+ tax: string;
85
+ priceData: {
86
+ taxIncludedInPrice: boolean;
87
+ price: string;
88
+ };
89
+ };
90
+ };
91
+ read: boolean;
92
+ archived: boolean;
93
+ paymentStatus: string;
94
+ fulfillmentStatus: string;
95
+ lineItems: [{
96
+ index: number;
97
+ quantity: number;
98
+ price: string;
99
+ name: string;
100
+ productId: string;
101
+ totalPrice: string;
102
+ lineItemType: string;
103
+ options: [];
104
+ customTextFields: [];
105
+ weight: string;
106
+ sku: string;
107
+ discount: string;
108
+ tax: string;
109
+ taxIncludedInPrice: boolean;
110
+ priceData: {
111
+ taxIncludedInPrice: boolean;
112
+ price: string;
113
+ totalPrice: string;
114
+ };
115
+ }];
116
+ activities: [
117
+ {
118
+ type: string;
119
+ timestamp: string;
120
+ },
121
+ {
122
+ type: string;
123
+ timestamp: string;
124
+ },
125
+ ];
126
+ fulfillments: [];
127
+ discount: { value: string };
128
+ buyerLanguage: string;
129
+ channelInfo: { type: string };
130
+ enteredBy: {
131
+ id: string;
132
+ identityType: string;
133
+ };
134
+ lastUpdated: string;
135
+ };
136
+ }
@@ -0,0 +1,163 @@
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-update-product-connector';
6
+
7
+ export default class WixUpdateProductConnector extends AConnector {
8
+
9
+ public getName(): string {
10
+ return NAME;
11
+ }
12
+
13
+ public async processAction(dto: ProcessDto<IInput>): Promise<ProcessDto<IOutput>> {
14
+ const { productId, ...body } = dto.getJsonData();
15
+
16
+ const appInstall = await this.getApplicationInstallFromProcess(dto);
17
+ const req = await this.getApplication().getRequestDto(
18
+ dto,
19
+ appInstall,
20
+ HttpMethods.PATCH,
21
+ `v1/products/${productId}`,
22
+ body,
23
+ );
24
+ const resp = await this.getSender().send<IOutput>(req, [200]);
25
+
26
+ return dto.setNewJsonData(resp.getJsonBody());
27
+ }
28
+
29
+ }
30
+
31
+ /* eslint-disable @typescript-eslint/naming-convention */
32
+ export interface IInput {
33
+ productId: string;
34
+ product: {
35
+ name: string;
36
+ productType: string;
37
+ priceData: {
38
+ price: number;
39
+ };
40
+ description: string;
41
+ sku: string;
42
+ visible: boolean;
43
+ weight: number;
44
+ ribbon: string;
45
+ brand: string;
46
+ discount: {
47
+ type: string;
48
+ value: number;
49
+ };
50
+ productOptions: [
51
+ {
52
+ name: string;
53
+ choices: [
54
+ {
55
+ value: string;
56
+ description: string;
57
+ },
58
+ ];
59
+ },
60
+ ];
61
+ };
62
+
63
+ }
64
+
65
+ export interface IOutput {
66
+ product: {
67
+ id: string;
68
+ name: string;
69
+ slug: string;
70
+ visible: boolean;
71
+ productType: string;
72
+ description: string;
73
+ stock: {
74
+ trackInventory: boolean;
75
+ inStock: boolean;
76
+ };
77
+ price: {
78
+ currency: string;
79
+ price: number;
80
+ discountedPrice: number;
81
+ formatted: {
82
+ price: string;
83
+ discountedPrice: string;
84
+ };
85
+ };
86
+ priceData: {
87
+ currency: string;
88
+ price: string;
89
+ discountedPrice: number;
90
+ formatted: {
91
+ price: string;
92
+ discountedPrice: string;
93
+ };
94
+ };
95
+ convertedPriceData: {
96
+ currency: string;
97
+ price: number;
98
+ discountedPrice: number;
99
+ formatted: {
100
+ price: string;
101
+ discountedPrice: string;
102
+ };
103
+ };
104
+ additionalInfoSections: [];
105
+ ribbons: { text: string }[];
106
+ media: { items: [] };
107
+ customTextFields: [];
108
+ manageVariants: boolean;
109
+ productOptions: [{
110
+ optionType: string;
111
+ name: string;
112
+ choices: [{
113
+ value: string;
114
+ description: string;
115
+ inStock: boolean;
116
+ visible: boolean;
117
+ }];
118
+ }];
119
+ productPageUrl: {
120
+ base: string;
121
+ path: string;
122
+ };
123
+ numericId: string;
124
+ inventoryItemId: string;
125
+ discount: {
126
+ type: string;
127
+ value: number;
128
+ };
129
+ collectionIds: [];
130
+ variants: [{
131
+ id: string;
132
+ choices: { Size: string };
133
+ variant: {
134
+ priceData: {
135
+ currency: string;
136
+ price: number;
137
+ discountedPrice: number;
138
+ formatted: {
139
+ price: string;
140
+ discountedPrice: string;
141
+ };
142
+ };
143
+ convertedPriceData: {
144
+ currency: string;
145
+ price: number;
146
+ discountedPrice: number;
147
+ formatted: {
148
+ price: string;
149
+ discountedPrice: string;
150
+ };
151
+ };
152
+ weight: number;
153
+ sku: string;
154
+ visible: boolean;
155
+ };
156
+ }];
157
+ lastUpdated: string;
158
+ ribbon: string;
159
+ brand: string;
160
+ };
161
+ }
162
+
163
+ /* eslint-enable @typescript-eslint/naming-convention */
@@ -0,0 +1,74 @@
1
+ {
2
+ "headers": {
3
+ "user": "TestUser"
4
+ },
5
+ "data": {
6
+ "order": {
7
+ "totals": {
8
+ "subtotal": "10",
9
+ "shipping": "3",
10
+ "tax": "3",
11
+ "discount": "1",
12
+ "total": "15"
13
+ },
14
+ "billingInfo": {
15
+ "paymentMethod": "PayPal",
16
+ "paymentProviderTransactionId": "tx_1806",
17
+ "address": {
18
+ "fullName": {
19
+ "firstName": "John",
20
+ "lastName": "Smith"
21
+ },
22
+ "country": "US",
23
+ "city": "New York",
24
+ "zipCode": "92544",
25
+ "phone": "+972 555234555",
26
+ "email": "Ivanushka@example.com"
27
+ }
28
+ },
29
+ "shippingInfo": {
30
+ "deliveryOption": "Express",
31
+ "estimatedDeliveryTime": "Today",
32
+ "shippingRegion": "Domestic",
33
+ "shipmentDetails": {
34
+ "address": {
35
+ "fullName": {
36
+ "firstName": "John",
37
+ "lastName": "Smith"
38
+ },
39
+ "country": "US",
40
+ "city": "New York",
41
+ "zipCode": "92544",
42
+ "phone": "+972 555234555",
43
+ "email": "Ivanushka@example.com"
44
+ },
45
+ "tax": "1",
46
+ "priceData": {
47
+ "taxIncludedInPrice": false,
48
+ "price": "3"
49
+ }
50
+ }
51
+ },
52
+ "paymentStatus": "PAID",
53
+ "lineItems": [
54
+ {
55
+ "quantity": 2,
56
+ "discount": "1",
57
+ "tax": "1",
58
+ "name": "my product",
59
+ "productId": "a1f9d337-f831-4529-31e6-67db8fd4e1aa",
60
+ "lineItemType": "PHYSICAL",
61
+ "weight": "15",
62
+ "sku": "12345678",
63
+ "priceData": {
64
+ "taxIncludedInPrice": false,
65
+ "price": "5"
66
+ }
67
+ }
68
+ ],
69
+ "channelInfo": {
70
+ "type": "WEB"
71
+ }
72
+ }
73
+ }
74
+ }