@23blocks/block-sales 5.2.0 → 5.2.2
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/index.esm.js +749 -543
- package/dist/src/lib/mappers/customer-subscription.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/customer.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/entity-subscription.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/entity.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/mercadopago.mapper.d.ts +2 -2
- package/dist/src/lib/mappers/mercadopago.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/order-detail-vendor.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/order-detail.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/order-tax.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/order.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/payment.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/subscription-model.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/subscription.mapper.d.ts +2 -1
- package/dist/src/lib/mappers/subscription.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/user.mapper.d.ts.map +1 -1
- package/dist/src/lib/mappers/vendor-payment.mapper.d.ts.map +1 -1
- package/dist/src/lib/services/customers.service.d.ts +0 -20
- package/dist/src/lib/services/customers.service.d.ts.map +1 -1
- package/dist/src/lib/services/entities.service.d.ts +0 -24
- package/dist/src/lib/services/entities.service.d.ts.map +1 -1
- package/dist/src/lib/services/mercadopago.service.d.ts +3 -15
- package/dist/src/lib/services/mercadopago.service.d.ts.map +1 -1
- package/dist/src/lib/services/order-details.service.d.ts +5 -18
- package/dist/src/lib/services/order-details.service.d.ts.map +1 -1
- package/dist/src/lib/services/order-taxes.service.d.ts +0 -19
- package/dist/src/lib/services/order-taxes.service.d.ts.map +1 -1
- package/dist/src/lib/services/orders.service.d.ts +5 -44
- package/dist/src/lib/services/orders.service.d.ts.map +1 -1
- package/dist/src/lib/services/payments.service.d.ts +3 -24
- package/dist/src/lib/services/payments.service.d.ts.map +1 -1
- package/dist/src/lib/services/stripe.service.d.ts +0 -43
- package/dist/src/lib/services/stripe.service.d.ts.map +1 -1
- package/dist/src/lib/services/subscription-models.service.d.ts +0 -16
- package/dist/src/lib/services/subscription-models.service.d.ts.map +1 -1
- package/dist/src/lib/services/subscriptions.service.d.ts +2 -38
- package/dist/src/lib/services/subscriptions.service.d.ts.map +1 -1
- package/dist/src/lib/services/users.service.d.ts +0 -51
- package/dist/src/lib/services/users.service.d.ts.map +1 -1
- package/dist/src/lib/services/vendor-payments.service.d.ts +2 -50
- package/dist/src/lib/services/vendor-payments.service.d.ts.map +1 -1
- package/dist/src/lib/types/customer.d.ts +37 -18
- package/dist/src/lib/types/customer.d.ts.map +1 -1
- package/dist/src/lib/types/entity.d.ts +25 -26
- package/dist/src/lib/types/entity.d.ts.map +1 -1
- package/dist/src/lib/types/mercadopago.d.ts +11 -51
- package/dist/src/lib/types/mercadopago.d.ts.map +1 -1
- package/dist/src/lib/types/order-detail.d.ts +83 -13
- package/dist/src/lib/types/order-detail.d.ts.map +1 -1
- package/dist/src/lib/types/order-tax.d.ts +17 -16
- package/dist/src/lib/types/order-tax.d.ts.map +1 -1
- package/dist/src/lib/types/order.d.ts +73 -56
- package/dist/src/lib/types/order.d.ts.map +1 -1
- package/dist/src/lib/types/payment.d.ts +76 -18
- package/dist/src/lib/types/payment.d.ts.map +1 -1
- package/dist/src/lib/types/stripe.d.ts +22 -107
- package/dist/src/lib/types/stripe.d.ts.map +1 -1
- package/dist/src/lib/types/subscription-model.d.ts +40 -37
- package/dist/src/lib/types/subscription-model.d.ts.map +1 -1
- package/dist/src/lib/types/subscription.d.ts +55 -38
- package/dist/src/lib/types/subscription.d.ts.map +1 -1
- package/dist/src/lib/types/user.d.ts +33 -46
- package/dist/src/lib/types/user.d.ts.map +1 -1
- package/dist/src/lib/types/vendor-payment.d.ts +81 -41
- package/dist/src/lib/types/vendor-payment.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -117,38 +117,80 @@ const orderMapper = {
|
|
|
117
117
|
uniqueId: parseString(resource.attributes['unique_id']) || '',
|
|
118
118
|
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
119
119
|
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
code: parseString(resource.attributes['code']),
|
|
121
|
+
displayUniqueId: parseString(resource.attributes['display_unique_id']),
|
|
122
|
+
parentUniqueId: parseString(resource.attributes['parent_unique_id']),
|
|
122
123
|
customerUniqueId: parseString(resource.attributes['customer_unique_id']),
|
|
124
|
+
customerName: parseString(resource.attributes['customer_name']),
|
|
125
|
+
customerEmail: parseString(resource.attributes['customer_email']),
|
|
126
|
+
customerPhone: parseString(resource.attributes['customer_phone']),
|
|
127
|
+
customerNotes: parseString(resource.attributes['customer_notes']),
|
|
123
128
|
status: parseOrderStatus(resource.attributes['status']),
|
|
129
|
+
logisticsStatus: parseString(resource.attributes['logistics_status']),
|
|
124
130
|
subtotal: parseNumber(resource.attributes['subtotal']),
|
|
125
|
-
tax: parseNumber(resource.attributes['tax']),
|
|
126
|
-
shipping: parseNumber(resource.attributes['shipping']),
|
|
127
131
|
discount: parseNumber(resource.attributes['discount']),
|
|
132
|
+
discountValue: parseNumber(resource.attributes['discount_value']) || undefined,
|
|
133
|
+
delivery: parseNumber(resource.attributes['delivery']) || undefined,
|
|
134
|
+
tax: parseNumber(resource.attributes['tax']),
|
|
135
|
+
taxValue: parseNumber(resource.attributes['tax_value']) || undefined,
|
|
136
|
+
fees: parseNumber(resource.attributes['fees']) || undefined,
|
|
137
|
+
feesValue: parseNumber(resource.attributes['fees_value']) || undefined,
|
|
138
|
+
vendorDiscount: parseNumber(resource.attributes['vendor_discount']) || undefined,
|
|
139
|
+
vendorDiscountValue: parseNumber(resource.attributes['vendor_discount_value']) || undefined,
|
|
140
|
+
vendorPrice: parseNumber(resource.attributes['vendor_price']) || undefined,
|
|
141
|
+
openPrice: parseNumber(resource.attributes['open_price']) || undefined,
|
|
142
|
+
openStock: parseNumber(resource.attributes['open_stock']) || undefined,
|
|
128
143
|
total: parseNumber(resource.attributes['total']),
|
|
144
|
+
balance: parseNumber(resource.attributes['balance']) || undefined,
|
|
129
145
|
source: parseString(resource.attributes['source']),
|
|
130
146
|
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
131
147
|
sourceId: parseString(resource.attributes['source_id']),
|
|
132
148
|
sourceType: parseString(resource.attributes['source_type']),
|
|
133
|
-
code: parseString(resource.attributes['code']),
|
|
134
|
-
discountValue: parseNumber(resource.attributes['discount_value']) || undefined,
|
|
135
|
-
taxValue: parseNumber(resource.attributes['tax_value']) || undefined,
|
|
136
|
-
fees: parseNumber(resource.attributes['fees']) || undefined,
|
|
137
|
-
feesValue: parseNumber(resource.attributes['fees_value']) || undefined,
|
|
138
|
-
promoCode: parseString(resource.attributes['promo_code']),
|
|
139
149
|
internalNotes: parseString(resource.attributes['internal_notes']),
|
|
140
150
|
cartUniqueId: parseString(resource.attributes['cart_unique_id']),
|
|
141
151
|
referredBy: parseString(resource.attributes['referred_by']),
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
promoCode: parseString(resource.attributes['promo_code']),
|
|
153
|
+
tips: parseNumber(resource.attributes['tips']) || undefined,
|
|
154
|
+
tipsValue: parseNumber(resource.attributes['tips_value']) || undefined,
|
|
145
155
|
paidAt: parseDate(resource.attributes['paid_at']),
|
|
146
156
|
shippedAt: parseDate(resource.attributes['shipped_at']),
|
|
147
|
-
deliveredAt: parseDate(resource.attributes['delivered_at'])
|
|
148
|
-
payload: resource.attributes['payload']
|
|
157
|
+
deliveredAt: parseDate(resource.attributes['delivered_at'])
|
|
149
158
|
})
|
|
150
159
|
};
|
|
151
160
|
|
|
161
|
+
function buildOrderBody(data) {
|
|
162
|
+
const order = {};
|
|
163
|
+
if (data.code) order['code'] = data.code;
|
|
164
|
+
if (data.displayUniqueId) order['display_unique_id'] = data.displayUniqueId;
|
|
165
|
+
if (data.parentUniqueId) order['parent_unique_id'] = data.parentUniqueId;
|
|
166
|
+
if (data.customerUniqueId) order['customer_unique_id'] = data.customerUniqueId;
|
|
167
|
+
if (data.customerName) order['customer_name'] = data.customerName;
|
|
168
|
+
if (data.customerEmail) order['customer_email'] = data.customerEmail;
|
|
169
|
+
if (data.customerPhone) order['customer_phone'] = data.customerPhone;
|
|
170
|
+
if (data.customerNotes) order['customer_notes'] = data.customerNotes;
|
|
171
|
+
if (data.subtotal !== undefined) order['subtotal'] = data.subtotal;
|
|
172
|
+
if (data.discount !== undefined) order['discount'] = data.discount;
|
|
173
|
+
if (data.discountValue !== undefined) order['discount_value'] = data.discountValue;
|
|
174
|
+
if (data.delivery !== undefined) order['delivery'] = data.delivery;
|
|
175
|
+
if (data.tax !== undefined) order['tax'] = data.tax;
|
|
176
|
+
if (data.taxValue !== undefined) order['tax_value'] = data.taxValue;
|
|
177
|
+
if (data.fees !== undefined) order['fees'] = data.fees;
|
|
178
|
+
if (data.feesValue !== undefined) order['fees_value'] = data.feesValue;
|
|
179
|
+
if (data.vendorDiscount !== undefined) order['vendor_discount'] = data.vendorDiscount;
|
|
180
|
+
if (data.vendorDiscountValue !== undefined) order['vendor_discount_value'] = data.vendorDiscountValue;
|
|
181
|
+
if (data.vendorPrice !== undefined) order['vendor_price'] = data.vendorPrice;
|
|
182
|
+
if (data.openPrice !== undefined) order['open_price'] = data.openPrice;
|
|
183
|
+
if (data.openStock !== undefined) order['open_stock'] = data.openStock;
|
|
184
|
+
if (data.source) order['source'] = data.source;
|
|
185
|
+
if (data.sourceAlias) order['source_alias'] = data.sourceAlias;
|
|
186
|
+
if (data.sourceId) order['source_id'] = data.sourceId;
|
|
187
|
+
if (data.sourceType) order['source_type'] = data.sourceType;
|
|
188
|
+
if (data.internalNotes) order['internal_notes'] = data.internalNotes;
|
|
189
|
+
if (data.cartUniqueId) order['cart_unique_id'] = data.cartUniqueId;
|
|
190
|
+
if (data.referredBy) order['referred_by'] = data.referredBy;
|
|
191
|
+
if (data.promoCode) order['promo_code'] = data.promoCode;
|
|
192
|
+
return order;
|
|
193
|
+
}
|
|
152
194
|
function createOrdersService(transport, _config) {
|
|
153
195
|
return {
|
|
154
196
|
async list (params) {
|
|
@@ -156,7 +198,11 @@ function createOrdersService(transport, _config) {
|
|
|
156
198
|
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
157
199
|
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
158
200
|
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
159
|
-
if (params == null ? void 0 : params.
|
|
201
|
+
if (params == null ? void 0 : params.customerUniqueId) queryParams['customer_unique_id'] = params.customerUniqueId;
|
|
202
|
+
if (params == null ? void 0 : params.parentUniqueId) queryParams['parent_unique_id'] = params.parentUniqueId;
|
|
203
|
+
if (params == null ? void 0 : params.source) queryParams['source'] = params.source;
|
|
204
|
+
if (params == null ? void 0 : params.referredBy) queryParams['referred_by'] = params.referredBy;
|
|
205
|
+
if (params == null ? void 0 : params.promoCode) queryParams['promo_code'] = params.promoCode;
|
|
160
206
|
if (params == null ? void 0 : params.startDate) queryParams['start_date'] = params.startDate.toISOString();
|
|
161
207
|
if (params == null ? void 0 : params.endDate) queryParams['end_date'] = params.endDate.toISOString();
|
|
162
208
|
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
@@ -170,82 +216,67 @@ function createOrdersService(transport, _config) {
|
|
|
170
216
|
return decodeOne(response, orderMapper);
|
|
171
217
|
},
|
|
172
218
|
async create (data) {
|
|
173
|
-
const order = {};
|
|
174
|
-
if (data.customerUniqueId) order['customer_unique_id'] = data.customerUniqueId;
|
|
175
|
-
if (data.userUniqueId) order['user_unique_id'] = data.userUniqueId;
|
|
176
|
-
if (data.subtotal !== undefined) order['subtotal'] = data.subtotal;
|
|
177
|
-
if (data.source) order['source'] = data.source;
|
|
178
|
-
if (data.sourceAlias) order['source_alias'] = data.sourceAlias;
|
|
179
|
-
if (data.sourceId) order['source_id'] = data.sourceId;
|
|
180
|
-
if (data.sourceType) order['source_type'] = data.sourceType;
|
|
181
|
-
if (data.code) order['code'] = data.code;
|
|
182
|
-
if (data.discount !== undefined) order['discount'] = data.discount;
|
|
183
|
-
if (data.discountValue !== undefined) order['discount_value'] = data.discountValue;
|
|
184
|
-
if (data.tax !== undefined) order['tax'] = data.tax;
|
|
185
|
-
if (data.taxValue !== undefined) order['tax_value'] = data.taxValue;
|
|
186
|
-
if (data.fees !== undefined) order['fees'] = data.fees;
|
|
187
|
-
if (data.feesValue !== undefined) order['fees_value'] = data.feesValue;
|
|
188
|
-
if (data.promoCode) order['promo_code'] = data.promoCode;
|
|
189
|
-
if (data.internalNotes) order['internal_notes'] = data.internalNotes;
|
|
190
|
-
if (data.cartUniqueId) order['cart_unique_id'] = data.cartUniqueId;
|
|
191
|
-
if (data.referredBy) order['referred_by'] = data.referredBy;
|
|
192
|
-
if (data.items) {
|
|
193
|
-
order['items'] = data.items.map((item)=>({
|
|
194
|
-
product_unique_id: item.productUniqueId,
|
|
195
|
-
product_variation_unique_id: item.productVariationUniqueId,
|
|
196
|
-
quantity: item.quantity,
|
|
197
|
-
unit_price: item.unitPrice
|
|
198
|
-
}));
|
|
199
|
-
}
|
|
200
|
-
if (data.shippingAddressUniqueId) order['shipping_address_unique_id'] = data.shippingAddressUniqueId;
|
|
201
|
-
if (data.billingAddressUniqueId) order['billing_address_unique_id'] = data.billingAddressUniqueId;
|
|
202
|
-
if (data.notes) order['notes'] = data.notes;
|
|
203
|
-
if (data.payload) order['payload'] = data.payload;
|
|
204
219
|
const response = await transport.post('/orders', {
|
|
205
|
-
order
|
|
220
|
+
order: buildOrderBody(data)
|
|
206
221
|
});
|
|
207
222
|
return decodeOne(response, orderMapper);
|
|
208
223
|
},
|
|
209
224
|
async update (uniqueId, data) {
|
|
210
225
|
const response = await transport.put(`/orders/${uniqueId}`, {
|
|
211
|
-
order:
|
|
212
|
-
shipping_address_unique_id: data.shippingAddressUniqueId,
|
|
213
|
-
billing_address_unique_id: data.billingAddressUniqueId,
|
|
214
|
-
notes: data.notes,
|
|
215
|
-
payload: data.payload
|
|
216
|
-
}
|
|
226
|
+
order: buildOrderBody(data)
|
|
217
227
|
});
|
|
218
228
|
return decodeOne(response, orderMapper);
|
|
219
229
|
},
|
|
220
|
-
async
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
230
|
+
async updateStatus (uniqueId, data) {
|
|
231
|
+
const body = {
|
|
232
|
+
status: data.status
|
|
233
|
+
};
|
|
234
|
+
if (data.source) body['source'] = data.source;
|
|
235
|
+
if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
|
|
236
|
+
if (data.sourceId) body['source_id'] = data.sourceId;
|
|
237
|
+
if (data.sourceType) body['source_type'] = data.sourceType;
|
|
238
|
+
const response = await transport.put(`/orders/${uniqueId}/status`, {
|
|
239
|
+
order: body
|
|
240
|
+
});
|
|
226
241
|
return decodeOne(response, orderMapper);
|
|
227
242
|
},
|
|
228
|
-
async
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
243
|
+
async updateLogistics (uniqueId, data) {
|
|
244
|
+
const body = {
|
|
245
|
+
logistics_status: data.logisticsStatus
|
|
246
|
+
};
|
|
247
|
+
if (data.source) body['source'] = data.source;
|
|
248
|
+
if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
|
|
249
|
+
if (data.sourceId) body['source_id'] = data.sourceId;
|
|
250
|
+
if (data.sourceType) body['source_type'] = data.sourceType;
|
|
251
|
+
const response = await transport.put(`/orders/${uniqueId}/logistics`, {
|
|
252
|
+
order: body
|
|
233
253
|
});
|
|
234
254
|
return decodeOne(response, orderMapper);
|
|
235
255
|
},
|
|
236
|
-
async
|
|
237
|
-
const
|
|
256
|
+
async addTips (uniqueId, data) {
|
|
257
|
+
const body = {};
|
|
258
|
+
if (data.tips !== undefined) body['tips'] = data.tips;
|
|
259
|
+
if (data.tipsValue !== undefined) body['tips_value'] = data.tipsValue;
|
|
260
|
+
if (data.source) body['source'] = data.source;
|
|
261
|
+
if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
|
|
262
|
+
if (data.sourceId) body['source_id'] = data.sourceId;
|
|
263
|
+
if (data.sourceType) body['source_type'] = data.sourceType;
|
|
264
|
+
const response = await transport.post(`/orders/${uniqueId}/tips/add`, {
|
|
265
|
+
order: body
|
|
266
|
+
});
|
|
238
267
|
return decodeOne(response, orderMapper);
|
|
239
268
|
},
|
|
240
|
-
async
|
|
241
|
-
const queryParams = {
|
|
269
|
+
async listByCustomer (customerUniqueId, params) {
|
|
270
|
+
const queryParams = {
|
|
271
|
+
customer_unique_id: customerUniqueId
|
|
272
|
+
};
|
|
242
273
|
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
243
274
|
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
244
275
|
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
245
276
|
if (params == null ? void 0 : params.startDate) queryParams['start_date'] = params.startDate.toISOString();
|
|
246
277
|
if (params == null ? void 0 : params.endDate) queryParams['end_date'] = params.endDate.toISOString();
|
|
247
278
|
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
248
|
-
const response = await transport.get(
|
|
279
|
+
const response = await transport.get('/orders', {
|
|
249
280
|
params: queryParams
|
|
250
281
|
});
|
|
251
282
|
return decodePageResult(response, orderMapper);
|
|
@@ -257,25 +288,85 @@ const orderDetailMapper = {
|
|
|
257
288
|
type: 'OrderDetail',
|
|
258
289
|
map: (resource)=>({
|
|
259
290
|
id: resource.id,
|
|
260
|
-
uniqueId: parseString(resource.attributes['unique_id']),
|
|
291
|
+
uniqueId: parseString(resource.attributes['unique_id']) || '',
|
|
261
292
|
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
262
293
|
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
263
294
|
orderUniqueId: parseString(resource.attributes['order_unique_id']) || '',
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
295
|
+
source: parseString(resource.attributes['source']),
|
|
296
|
+
sourceAlias: parseString(resource.attributes['source_alias']),
|
|
297
|
+
sourceId: parseString(resource.attributes['source_id']),
|
|
298
|
+
sourceType: parseString(resource.attributes['source_type']),
|
|
299
|
+
productSku: parseString(resource.attributes['product_sku']),
|
|
300
|
+
productUniqueId: parseString(resource.attributes['product_unique_id']),
|
|
301
|
+
productName: parseString(resource.attributes['product_name']),
|
|
302
|
+
productDescription: parseString(resource.attributes['product_description']),
|
|
303
|
+
categoryName: parseString(resource.attributes['category_name']),
|
|
304
|
+
isVariation: resource.attributes['is_variation'] === true || resource.attributes['is_variation'] === 'true' || undefined,
|
|
305
|
+
variationSku: parseString(resource.attributes['variation_sku']),
|
|
306
|
+
productSize: parseString(resource.attributes['product_size']),
|
|
307
|
+
color: parseString(resource.attributes['color']),
|
|
308
|
+
extraVariation: parseString(resource.attributes['extra_variation']),
|
|
268
309
|
quantity: parseNumber(resource.attributes['quantity']),
|
|
269
|
-
|
|
310
|
+
notes: parseString(resource.attributes['notes']),
|
|
311
|
+
subtotal: parseNumber(resource.attributes['subtotal']),
|
|
270
312
|
discount: parseNumber(resource.attributes['discount']),
|
|
313
|
+
discountValue: parseNumber(resource.attributes['discount_value']) || undefined,
|
|
271
314
|
tax: parseNumber(resource.attributes['tax']),
|
|
315
|
+
taxValue: parseNumber(resource.attributes['tax_value']) || undefined,
|
|
316
|
+
fees: parseNumber(resource.attributes['fees']) || undefined,
|
|
317
|
+
feesValue: parseNumber(resource.attributes['fees_value']) || undefined,
|
|
318
|
+
tips: parseNumber(resource.attributes['tips']) || undefined,
|
|
319
|
+
tipsValue: parseNumber(resource.attributes['tips_value']) || undefined,
|
|
320
|
+
vendorDiscount: parseNumber(resource.attributes['vendor_discount']) || undefined,
|
|
321
|
+
vendorDiscountValue: parseNumber(resource.attributes['vendor_discount_value']) || undefined,
|
|
322
|
+
vendorPrice: parseNumber(resource.attributes['vendor_price']) || undefined,
|
|
272
323
|
total: parseNumber(resource.attributes['total']),
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
324
|
+
cartDetailUniqueId: parseString(resource.attributes['cart_detail_unique_id']),
|
|
325
|
+
referredBy: parseString(resource.attributes['referred_by']),
|
|
326
|
+
promoCode: parseString(resource.attributes['promo_code']),
|
|
327
|
+
orderCode: parseString(resource.attributes['order_code']),
|
|
328
|
+
status: parseString(resource.attributes['status']),
|
|
329
|
+
logisticsStatus: parseString(resource.attributes['logistics_status'])
|
|
276
330
|
})
|
|
277
331
|
};
|
|
278
332
|
|
|
333
|
+
function buildDetailBody(data) {
|
|
334
|
+
const detail = {};
|
|
335
|
+
if (data.source) detail['source'] = data.source;
|
|
336
|
+
if (data.sourceAlias) detail['source_alias'] = data.sourceAlias;
|
|
337
|
+
if (data.sourceId) detail['source_id'] = data.sourceId;
|
|
338
|
+
if (data.sourceType) detail['source_type'] = data.sourceType;
|
|
339
|
+
if (data.productSku) detail['product_sku'] = data.productSku;
|
|
340
|
+
if (data.productUniqueId) detail['product_unique_id'] = data.productUniqueId;
|
|
341
|
+
if (data.productName) detail['product_name'] = data.productName;
|
|
342
|
+
if (data.productDescription) detail['product_description'] = data.productDescription;
|
|
343
|
+
if (data.categoryName) detail['category_name'] = data.categoryName;
|
|
344
|
+
if (data.isVariation !== undefined) detail['is_variation'] = data.isVariation;
|
|
345
|
+
if (data.variationSku) detail['variation_sku'] = data.variationSku;
|
|
346
|
+
if (data.productSize) detail['product_size'] = data.productSize;
|
|
347
|
+
if (data.color) detail['color'] = data.color;
|
|
348
|
+
if (data.extraVariation) detail['extra_variation'] = data.extraVariation;
|
|
349
|
+
detail['quantity'] = data.quantity;
|
|
350
|
+
if (data.notes) detail['notes'] = data.notes;
|
|
351
|
+
if (data.subtotal !== undefined) detail['subtotal'] = data.subtotal;
|
|
352
|
+
if (data.discount !== undefined) detail['discount'] = data.discount;
|
|
353
|
+
if (data.discountValue !== undefined) detail['discount_value'] = data.discountValue;
|
|
354
|
+
if (data.tax !== undefined) detail['tax'] = data.tax;
|
|
355
|
+
if (data.taxValue !== undefined) detail['tax_value'] = data.taxValue;
|
|
356
|
+
if (data.fees !== undefined) detail['fees'] = data.fees;
|
|
357
|
+
if (data.feesValue !== undefined) detail['fees_value'] = data.feesValue;
|
|
358
|
+
if (data.tips !== undefined) detail['tips'] = data.tips;
|
|
359
|
+
if (data.tipsValue !== undefined) detail['tips_value'] = data.tipsValue;
|
|
360
|
+
if (data.vendorDiscount !== undefined) detail['vendor_discount'] = data.vendorDiscount;
|
|
361
|
+
if (data.vendorDiscountValue !== undefined) detail['vendor_discount_value'] = data.vendorDiscountValue;
|
|
362
|
+
if (data.vendorPrice !== undefined) detail['vendor_price'] = data.vendorPrice;
|
|
363
|
+
if (data.total !== undefined) detail['total'] = data.total;
|
|
364
|
+
if (data.cartDetailUniqueId) detail['cart_detail_unique_id'] = data.cartDetailUniqueId;
|
|
365
|
+
if (data.referredBy) detail['referred_by'] = data.referredBy;
|
|
366
|
+
if (data.promoCode) detail['promo_code'] = data.promoCode;
|
|
367
|
+
if (data.orderCode) detail['order_code'] = data.orderCode;
|
|
368
|
+
return detail;
|
|
369
|
+
}
|
|
279
370
|
function createOrderDetailsService(transport, _config) {
|
|
280
371
|
return {
|
|
281
372
|
async list () {
|
|
@@ -286,15 +377,41 @@ function createOrderDetailsService(transport, _config) {
|
|
|
286
377
|
const response = await transport.get(`/order_details/${uniqueId}`);
|
|
287
378
|
return decodeOne(response, orderDetailMapper);
|
|
288
379
|
},
|
|
289
|
-
async
|
|
290
|
-
const response = await transport.
|
|
291
|
-
details:
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
380
|
+
async create (orderUniqueId, data) {
|
|
381
|
+
const response = await transport.post(`/orders/${orderUniqueId}/details`, {
|
|
382
|
+
details: buildDetailBody(data)
|
|
383
|
+
});
|
|
384
|
+
return decodeOne(response, orderDetailMapper);
|
|
385
|
+
},
|
|
386
|
+
async update (orderUniqueId, detailUniqueId, data) {
|
|
387
|
+
const response = await transport.put(`/orders/${orderUniqueId}/details/${detailUniqueId}`, {
|
|
388
|
+
details: buildDetailBody(data)
|
|
389
|
+
});
|
|
390
|
+
return decodeOne(response, orderDetailMapper);
|
|
391
|
+
},
|
|
392
|
+
async updateStatus (orderUniqueId, detailUniqueId, data) {
|
|
393
|
+
const body = {
|
|
394
|
+
status: data.status
|
|
395
|
+
};
|
|
396
|
+
if (data.source) body['source'] = data.source;
|
|
397
|
+
if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
|
|
398
|
+
if (data.sourceId) body['source_id'] = data.sourceId;
|
|
399
|
+
if (data.sourceType) body['source_type'] = data.sourceType;
|
|
400
|
+
const response = await transport.put(`/orders/${orderUniqueId}/details/${detailUniqueId}/status`, {
|
|
401
|
+
details: body
|
|
402
|
+
});
|
|
403
|
+
return decodeOne(response, orderDetailMapper);
|
|
404
|
+
},
|
|
405
|
+
async updateLogistics (orderUniqueId, detailUniqueId, data) {
|
|
406
|
+
const body = {
|
|
407
|
+
logistics_status: data.logisticsStatus
|
|
408
|
+
};
|
|
409
|
+
if (data.source) body['source'] = data.source;
|
|
410
|
+
if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
|
|
411
|
+
if (data.sourceId) body['source_id'] = data.sourceId;
|
|
412
|
+
if (data.sourceType) body['source_type'] = data.sourceType;
|
|
413
|
+
const response = await transport.put(`/orders/${orderUniqueId}/details/${detailUniqueId}/logistics`, {
|
|
414
|
+
details: body
|
|
298
415
|
});
|
|
299
416
|
return decodeOne(response, orderDetailMapper);
|
|
300
417
|
},
|
|
@@ -309,18 +426,33 @@ const orderTaxMapper = {
|
|
|
309
426
|
type: 'OrderTax',
|
|
310
427
|
map: (resource)=>({
|
|
311
428
|
id: resource.id,
|
|
312
|
-
uniqueId: parseString(resource.attributes['unique_id']),
|
|
313
|
-
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
314
|
-
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
429
|
+
uniqueId: parseString(resource.attributes['unique_id']) || '',
|
|
315
430
|
orderUniqueId: parseString(resource.attributes['order_unique_id']) || '',
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
431
|
+
taxUniqueId: parseString(resource.attributes['tax_unique_id']),
|
|
432
|
+
name: parseString(resource.attributes['name']),
|
|
433
|
+
description: parseString(resource.attributes['description']),
|
|
434
|
+
level: parseString(resource.attributes['level']),
|
|
435
|
+
taxValue: parseNumber(resource.attributes['tax_value']) || undefined,
|
|
436
|
+
tax: parseNumber(resource.attributes['tax']) || undefined,
|
|
437
|
+
displayOrder: parseNumber(resource.attributes['display_order']) || undefined,
|
|
438
|
+
status: parseString(resource.attributes['status']),
|
|
439
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
440
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
|
|
321
441
|
})
|
|
322
442
|
};
|
|
323
443
|
|
|
444
|
+
function buildTaxBody(data) {
|
|
445
|
+
const body = {};
|
|
446
|
+
if (data.taxUniqueId) body['tax_unique_id'] = data.taxUniqueId;
|
|
447
|
+
if (data.name) body['name'] = data.name;
|
|
448
|
+
if (data.description) body['description'] = data.description;
|
|
449
|
+
if (data.level) body['level'] = data.level;
|
|
450
|
+
if (data.taxValue !== undefined) body['tax_value'] = data.taxValue;
|
|
451
|
+
if (data.tax !== undefined) body['tax'] = data.tax;
|
|
452
|
+
if (data.displayOrder !== undefined) body['display_order'] = data.displayOrder;
|
|
453
|
+
if (data.status) body['status'] = data.status;
|
|
454
|
+
return body;
|
|
455
|
+
}
|
|
324
456
|
function createOrderTaxesService(transport, _config) {
|
|
325
457
|
return {
|
|
326
458
|
async list (orderUniqueId) {
|
|
@@ -333,25 +465,13 @@ function createOrderTaxesService(transport, _config) {
|
|
|
333
465
|
},
|
|
334
466
|
async create (orderUniqueId, data) {
|
|
335
467
|
const response = await transport.post(`/orders/${orderUniqueId}/taxes`, {
|
|
336
|
-
order_tax:
|
|
337
|
-
name: data.name,
|
|
338
|
-
rate: data.rate,
|
|
339
|
-
amount: data.amount,
|
|
340
|
-
type: data.type,
|
|
341
|
-
payload: data.payload
|
|
342
|
-
}
|
|
468
|
+
order_tax: buildTaxBody(data)
|
|
343
469
|
});
|
|
344
470
|
return decodeOne(response, orderTaxMapper);
|
|
345
471
|
},
|
|
346
472
|
async update (orderUniqueId, uniqueId, data) {
|
|
347
473
|
const response = await transport.put(`/orders/${orderUniqueId}/taxes/${uniqueId}`, {
|
|
348
|
-
order_tax:
|
|
349
|
-
name: data.name,
|
|
350
|
-
rate: data.rate,
|
|
351
|
-
amount: data.amount,
|
|
352
|
-
type: data.type,
|
|
353
|
-
payload: data.payload
|
|
354
|
-
}
|
|
474
|
+
order_tax: buildTaxBody(data)
|
|
355
475
|
});
|
|
356
476
|
return decodeOne(response, orderTaxMapper);
|
|
357
477
|
},
|
|
@@ -365,21 +485,67 @@ const paymentMapper = {
|
|
|
365
485
|
type: 'Payment',
|
|
366
486
|
map: (resource)=>({
|
|
367
487
|
id: resource.id,
|
|
368
|
-
uniqueId: parseString(resource.attributes['unique_id']),
|
|
488
|
+
uniqueId: parseString(resource.attributes['unique_id']) || '',
|
|
369
489
|
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
370
490
|
updatedAt: parseDate(resource.attributes['updated_at']) || new Date(),
|
|
371
|
-
orderUniqueId: parseString(resource.attributes['order_unique_id'])
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
491
|
+
orderUniqueId: parseString(resource.attributes['order_unique_id']),
|
|
492
|
+
paymentType: parseString(resource.attributes['payment_type']),
|
|
493
|
+
gatewayUniqueId: parseString(resource.attributes['gateway_unique_id']),
|
|
494
|
+
gatewayName: parseString(resource.attributes['gateway_name']),
|
|
495
|
+
gatewayReference: parseString(resource.attributes['gateway_reference']),
|
|
496
|
+
gatewayOrderId: parseString(resource.attributes['gateway_order_id']),
|
|
497
|
+
gatewayFranchise: parseString(resource.attributes['gateway_franchise']),
|
|
498
|
+
gatewayPaymentType: parseString(resource.attributes['gateway_payment_type']),
|
|
499
|
+
gatewayTransactionId: parseString(resource.attributes['gateway_transaction_id']),
|
|
500
|
+
gatewayDescription: parseString(resource.attributes['gateway_description']),
|
|
501
|
+
gatewaySubtotal: parseNumber(resource.attributes['gateway_subtotal']) || undefined,
|
|
502
|
+
gatewayDiscount: parseNumber(resource.attributes['gateway_discount']) || undefined,
|
|
503
|
+
gatewayDiscountValue: parseNumber(resource.attributes['gateway_discount_value']) || undefined,
|
|
504
|
+
gatewayDelivery: parseNumber(resource.attributes['gateway_delivery']) || undefined,
|
|
505
|
+
gatewayTax: parseNumber(resource.attributes['gateway_tax']) || undefined,
|
|
506
|
+
gatewayTaxValue: parseNumber(resource.attributes['gateway_tax_value']) || undefined,
|
|
507
|
+
gatewayFees: parseNumber(resource.attributes['gateway_fees']) || undefined,
|
|
508
|
+
gatewayFeesValue: parseNumber(resource.attributes['gateway_fees_value']) || undefined,
|
|
509
|
+
gatewayTips: parseNumber(resource.attributes['gateway_tips']) || undefined,
|
|
510
|
+
gatewayTipsValue: parseNumber(resource.attributes['gateway_tips_value']) || undefined,
|
|
511
|
+
gatewayTotal: parseNumber(resource.attributes['gateway_total']) || undefined,
|
|
512
|
+
gatewayBalance: parseNumber(resource.attributes['gateway_balance']) || undefined,
|
|
513
|
+
gatewayPaidAt: parseDate(resource.attributes['gateway_paid_at']),
|
|
514
|
+
gatewayStatus: parseString(resource.attributes['gateway_status']),
|
|
515
|
+
gatewayResponse: parseString(resource.attributes['gateway_response']),
|
|
516
|
+
status: parseString(resource.attributes['status']),
|
|
517
|
+
paidAt: parseDate(resource.attributes['paid_at'])
|
|
380
518
|
})
|
|
381
519
|
};
|
|
382
520
|
|
|
521
|
+
function buildPaymentBody(data) {
|
|
522
|
+
const payment = {};
|
|
523
|
+
if (data.gatewayUniqueId) payment['gateway_unique_id'] = data.gatewayUniqueId;
|
|
524
|
+
if (data.gatewayName) payment['gateway_name'] = data.gatewayName;
|
|
525
|
+
if (data.gatewayReference) payment['gateway_reference'] = data.gatewayReference;
|
|
526
|
+
if (data.gatewayOrderId) payment['gateway_order_id'] = data.gatewayOrderId;
|
|
527
|
+
if (data.gatewayFranchise) payment['gateway_franchise'] = data.gatewayFranchise;
|
|
528
|
+
if (data.gatewayPaymentType) payment['gateway_payment_type'] = data.gatewayPaymentType;
|
|
529
|
+
if (data.gatewayTransactionId) payment['gateway_transaction_id'] = data.gatewayTransactionId;
|
|
530
|
+
if (data.gatewayDescription) payment['gateway_description'] = data.gatewayDescription;
|
|
531
|
+
if (data.gatewaySubtotal !== undefined) payment['gateway_subtotal'] = data.gatewaySubtotal;
|
|
532
|
+
if (data.gatewayDiscount !== undefined) payment['gateway_discount'] = data.gatewayDiscount;
|
|
533
|
+
if (data.gatewayDiscountValue !== undefined) payment['gateway_discount_value'] = data.gatewayDiscountValue;
|
|
534
|
+
if (data.gatewayDelivery !== undefined) payment['gateway_delivery'] = data.gatewayDelivery;
|
|
535
|
+
if (data.gatewayTax !== undefined) payment['gateway_tax'] = data.gatewayTax;
|
|
536
|
+
if (data.gatewayTaxValue !== undefined) payment['gateway_tax_value'] = data.gatewayTaxValue;
|
|
537
|
+
if (data.gatewayFees !== undefined) payment['gateway_fees'] = data.gatewayFees;
|
|
538
|
+
if (data.gatewayFeesValue !== undefined) payment['gateway_fees_value'] = data.gatewayFeesValue;
|
|
539
|
+
if (data.gatewayTips !== undefined) payment['gateway_tips'] = data.gatewayTips;
|
|
540
|
+
if (data.gatewayTipsValue !== undefined) payment['gateway_tips_value'] = data.gatewayTipsValue;
|
|
541
|
+
if (data.gatewayTotal !== undefined) payment['gateway_total'] = data.gatewayTotal;
|
|
542
|
+
if (data.gatewayBalance !== undefined) payment['gateway_balance'] = data.gatewayBalance;
|
|
543
|
+
if (data.gatewayPaidAt) payment['gateway_paid_at'] = data.gatewayPaidAt;
|
|
544
|
+
if (data.gatewayStatus) payment['gateway_status'] = data.gatewayStatus;
|
|
545
|
+
if (data.gatewayResponse) payment['gateway_response'] = data.gatewayResponse;
|
|
546
|
+
if (data.paymentType) payment['payment_type'] = data.paymentType;
|
|
547
|
+
return payment;
|
|
548
|
+
}
|
|
383
549
|
function createPaymentsService(transport, _config) {
|
|
384
550
|
return {
|
|
385
551
|
async list (params) {
|
|
@@ -388,7 +554,7 @@ function createPaymentsService(transport, _config) {
|
|
|
388
554
|
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
389
555
|
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
390
556
|
if (params == null ? void 0 : params.orderUniqueId) queryParams['order_unique_id'] = params.orderUniqueId;
|
|
391
|
-
if (params == null ? void 0 : params.
|
|
557
|
+
if (params == null ? void 0 : params.paymentType) queryParams['payment_type'] = params.paymentType;
|
|
392
558
|
if (params == null ? void 0 : params.startDate) queryParams['start_date'] = params.startDate.toISOString();
|
|
393
559
|
if (params == null ? void 0 : params.endDate) queryParams['end_date'] = params.endDate.toISOString();
|
|
394
560
|
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
@@ -401,25 +567,36 @@ function createPaymentsService(transport, _config) {
|
|
|
401
567
|
const response = await transport.get(`/payments/${uniqueId}`);
|
|
402
568
|
return decodeOne(response, paymentMapper);
|
|
403
569
|
},
|
|
404
|
-
async create (data) {
|
|
405
|
-
const response = await transport.post(
|
|
406
|
-
payment:
|
|
407
|
-
order_unique_id: data.orderUniqueId,
|
|
408
|
-
payment_method: data.paymentMethod,
|
|
409
|
-
payment_provider: data.paymentProvider,
|
|
410
|
-
amount: data.amount,
|
|
411
|
-
currency: data.currency,
|
|
412
|
-
transaction_id: data.transactionId,
|
|
413
|
-
payload: data.payload
|
|
414
|
-
}
|
|
570
|
+
async create (orderUniqueId, data) {
|
|
571
|
+
const response = await transport.post(`/orders/${orderUniqueId}/payments`, {
|
|
572
|
+
payment: buildPaymentBody(data)
|
|
415
573
|
});
|
|
416
574
|
return decodeOne(response, paymentMapper);
|
|
417
575
|
},
|
|
418
|
-
async
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
576
|
+
async createPaymentMethod (orderUniqueId, data) {
|
|
577
|
+
const body = {};
|
|
578
|
+
if (data.paymentType) body['payment_type'] = data.paymentType;
|
|
579
|
+
if (data.city) body['city'] = data.city;
|
|
580
|
+
if (data.country) body['country'] = data.country;
|
|
581
|
+
if (data.line1) body['line1'] = data.line1;
|
|
582
|
+
if (data.line2) body['line2'] = data.line2;
|
|
583
|
+
if (data.postalCode) body['postal_code'] = data.postalCode;
|
|
584
|
+
if (data.state) body['state'] = data.state;
|
|
585
|
+
if (data.brand) body['brand'] = data.brand;
|
|
586
|
+
if (data.cardCountry) body['card_country'] = data.cardCountry;
|
|
587
|
+
if (data.expMonth) body['exp_month'] = data.expMonth;
|
|
588
|
+
if (data.expYear) body['exp_year'] = data.expYear;
|
|
589
|
+
if (data.fingerprint) body['fingerprint'] = data.fingerprint;
|
|
590
|
+
if (data.last4) body['last4'] = data.last4;
|
|
591
|
+
if (data.paymentProcessorName) body['payment_processor_name'] = data.paymentProcessorName;
|
|
592
|
+
if (data.paymentProcessorId) body['payment_processor_id'] = data.paymentProcessorId;
|
|
593
|
+
if (data.customerUniqueId) body['customer_unique_id'] = data.customerUniqueId;
|
|
594
|
+
if (data.customerName) body['customer_name'] = data.customerName;
|
|
595
|
+
if (data.customerEmail) body['customer_email'] = data.customerEmail;
|
|
596
|
+
if (data.bankName) body['bank_name'] = data.bankName;
|
|
597
|
+
if (data.accountNumber) body['account_number'] = data.accountNumber;
|
|
598
|
+
const response = await transport.post(`/orders/${orderUniqueId}/payments/method`, {
|
|
599
|
+
payment: body
|
|
423
600
|
});
|
|
424
601
|
return decodeOne(response, paymentMapper);
|
|
425
602
|
},
|
|
@@ -431,27 +608,80 @@ function createPaymentsService(transport, _config) {
|
|
|
431
608
|
}
|
|
432
609
|
|
|
433
610
|
const subscriptionMapper = {
|
|
434
|
-
type: '
|
|
435
|
-
map: (resource)=>
|
|
611
|
+
type: 'subscription',
|
|
612
|
+
map: (resource)=>{
|
|
613
|
+
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11;
|
|
614
|
+
return {
|
|
436
615
|
id: resource.id,
|
|
437
|
-
uniqueId: parseString(resource.attributes['unique_id']),
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
616
|
+
uniqueId: parseString((_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id']) || '',
|
|
617
|
+
stripeCustomerId: parseString((_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['stripe_customer_id']),
|
|
618
|
+
accountUniqueId: parseString((_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['account_unique_id']),
|
|
619
|
+
accountCode: parseString((_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['account_code']),
|
|
620
|
+
accountName: parseString((_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['account_name']),
|
|
621
|
+
currency: parseString((_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['currency']),
|
|
622
|
+
billingInterval: parseString((_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['billing_interval']),
|
|
623
|
+
trialPeriodDays: parseNumber((_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['trial_period_days']) || undefined,
|
|
624
|
+
status: parseString((_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['status']),
|
|
625
|
+
metadata: (_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['metadata'],
|
|
626
|
+
createdAt: parseDate((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['created_at']) || new Date(),
|
|
627
|
+
updatedAt: parseDate((_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['updated_at']) || new Date()
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
const subscriptionItemMapper = {
|
|
632
|
+
type: 'subscription_item',
|
|
633
|
+
map: (resource)=>{
|
|
634
|
+
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13, _resource_attributes14;
|
|
635
|
+
return {
|
|
636
|
+
id: resource.id,
|
|
637
|
+
uniqueId: parseString((_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id']) || '',
|
|
638
|
+
subscriptionUniqueId: parseString((_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['subscription_unique_id']),
|
|
639
|
+
stripePriceId: parseString((_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['stripe_price_id']),
|
|
640
|
+
stripeProductId: parseString((_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['stripe_product_id']),
|
|
641
|
+
blockCode: parseString((_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['block_code']),
|
|
642
|
+
blockName: parseString((_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['block_name']),
|
|
643
|
+
appUniqueId: parseString((_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['app_unique_id']),
|
|
644
|
+
appName: parseString((_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['app_name']),
|
|
645
|
+
appBlockUniqueId: parseString((_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['app_block_unique_id']),
|
|
646
|
+
amountCents: parseNumber((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['amount_cents']) || undefined,
|
|
647
|
+
quantity: parseNumber((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['quantity']) || undefined,
|
|
648
|
+
status: parseString((_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['status']),
|
|
649
|
+
metadata: (_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['metadata'],
|
|
650
|
+
createdAt: parseDate((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['created_at']) || new Date(),
|
|
651
|
+
updatedAt: parseDate((_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['updated_at']) || new Date()
|
|
652
|
+
};
|
|
653
|
+
}
|
|
453
654
|
};
|
|
454
655
|
|
|
656
|
+
function buildItemBody(data) {
|
|
657
|
+
const body = {};
|
|
658
|
+
if (data.stripePriceId) body['stripe_price_id'] = data.stripePriceId;
|
|
659
|
+
if (data.stripeProductId) body['stripe_product_id'] = data.stripeProductId;
|
|
660
|
+
if (data.blockCode) body['block_code'] = data.blockCode;
|
|
661
|
+
if (data.blockName) body['block_name'] = data.blockName;
|
|
662
|
+
if (data.appUniqueId) body['app_unique_id'] = data.appUniqueId;
|
|
663
|
+
if (data.appName) body['app_name'] = data.appName;
|
|
664
|
+
if (data.appBlockUniqueId) body['app_block_unique_id'] = data.appBlockUniqueId;
|
|
665
|
+
if (data.amountCents !== undefined) body['amount_cents'] = data.amountCents;
|
|
666
|
+
if (data.quantity !== undefined) body['quantity'] = data.quantity;
|
|
667
|
+
if (data.metadata) body['metadata'] = data.metadata;
|
|
668
|
+
return body;
|
|
669
|
+
}
|
|
670
|
+
function buildSubscriptionBody$1(data) {
|
|
671
|
+
const body = {};
|
|
672
|
+
if (data.stripeCustomerId) body['stripe_customer_id'] = data.stripeCustomerId;
|
|
673
|
+
if (data.accountUniqueId) body['account_unique_id'] = data.accountUniqueId;
|
|
674
|
+
if (data.accountCode) body['account_code'] = data.accountCode;
|
|
675
|
+
if (data.accountName) body['account_name'] = data.accountName;
|
|
676
|
+
if (data.currency) body['currency'] = data.currency;
|
|
677
|
+
if (data.billingInterval) body['billing_interval'] = data.billingInterval;
|
|
678
|
+
if (data.trialPeriodDays !== undefined) body['trial_period_days'] = data.trialPeriodDays;
|
|
679
|
+
if (data.metadata) body['metadata'] = data.metadata;
|
|
680
|
+
if (data.items) {
|
|
681
|
+
body['items'] = data.items.map((item)=>buildItemBody(item));
|
|
682
|
+
}
|
|
683
|
+
return body;
|
|
684
|
+
}
|
|
455
685
|
function createSubscriptionsService(transport, _config) {
|
|
456
686
|
return {
|
|
457
687
|
async list (params) {
|
|
@@ -459,9 +689,6 @@ function createSubscriptionsService(transport, _config) {
|
|
|
459
689
|
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
460
690
|
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
461
691
|
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
462
|
-
if (params == null ? void 0 : params.userUniqueId) queryParams['user_unique_id'] = params.userUniqueId;
|
|
463
|
-
if (params == null ? void 0 : params.planUniqueId) queryParams['plan_unique_id'] = params.planUniqueId;
|
|
464
|
-
if (params == null ? void 0 : params.interval) queryParams['interval'] = params.interval;
|
|
465
692
|
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
466
693
|
const response = await transport.get('/subscriptions', {
|
|
467
694
|
params: queryParams
|
|
@@ -473,62 +700,16 @@ function createSubscriptionsService(transport, _config) {
|
|
|
473
700
|
return decodeOne(response, subscriptionMapper);
|
|
474
701
|
},
|
|
475
702
|
async create (data) {
|
|
476
|
-
var _data_startDate;
|
|
477
703
|
const response = await transport.post('/subscriptions', {
|
|
478
|
-
subscription:
|
|
479
|
-
user_unique_id: data.userUniqueId,
|
|
480
|
-
plan_unique_id: data.planUniqueId,
|
|
481
|
-
plan_name: data.planName,
|
|
482
|
-
price: data.price,
|
|
483
|
-
currency: data.currency,
|
|
484
|
-
interval: data.interval,
|
|
485
|
-
start_date: (_data_startDate = data.startDate) == null ? void 0 : _data_startDate.toISOString(),
|
|
486
|
-
payload: data.payload
|
|
487
|
-
}
|
|
704
|
+
subscription: buildSubscriptionBody$1(data)
|
|
488
705
|
});
|
|
489
706
|
return decodeOne(response, subscriptionMapper);
|
|
490
707
|
},
|
|
491
|
-
async
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
subscription: {
|
|
495
|
-
plan_unique_id: data.planUniqueId,
|
|
496
|
-
plan_name: data.planName,
|
|
497
|
-
price: data.price,
|
|
498
|
-
currency: data.currency,
|
|
499
|
-
interval: data.interval,
|
|
500
|
-
status: data.status,
|
|
501
|
-
end_date: (_data_endDate = data.endDate) == null ? void 0 : _data_endDate.toISOString(),
|
|
502
|
-
next_billing_date: (_data_nextBillingDate = data.nextBillingDate) == null ? void 0 : _data_nextBillingDate.toISOString(),
|
|
503
|
-
payload: data.payload
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
return decodeOne(response, subscriptionMapper);
|
|
507
|
-
},
|
|
508
|
-
async cancel (uniqueId) {
|
|
509
|
-
const response = await transport.put(`/subscriptions/${uniqueId}/cancel`, {});
|
|
510
|
-
return decodeOne(response, subscriptionMapper);
|
|
511
|
-
},
|
|
512
|
-
async pause (uniqueId) {
|
|
513
|
-
const response = await transport.put(`/subscriptions/${uniqueId}/pause`, {});
|
|
514
|
-
return decodeOne(response, subscriptionMapper);
|
|
515
|
-
},
|
|
516
|
-
async resume (uniqueId) {
|
|
517
|
-
const response = await transport.put(`/subscriptions/${uniqueId}/resume`, {});
|
|
518
|
-
return decodeOne(response, subscriptionMapper);
|
|
519
|
-
},
|
|
520
|
-
async listByUser (userUniqueId, params) {
|
|
521
|
-
const queryParams = {};
|
|
522
|
-
if (params == null ? void 0 : params.page) queryParams['page'] = String(params.page);
|
|
523
|
-
if (params == null ? void 0 : params.perPage) queryParams['records'] = String(params.perPage);
|
|
524
|
-
if (params == null ? void 0 : params.status) queryParams['status'] = params.status;
|
|
525
|
-
if (params == null ? void 0 : params.planUniqueId) queryParams['plan_unique_id'] = params.planUniqueId;
|
|
526
|
-
if (params == null ? void 0 : params.interval) queryParams['interval'] = params.interval;
|
|
527
|
-
if (params == null ? void 0 : params.sortBy) queryParams['sort'] = params.sortOrder === 'desc' ? `-${params.sortBy}` : params.sortBy;
|
|
528
|
-
const response = await transport.get(`/users/${userUniqueId}/subscriptions`, {
|
|
529
|
-
params: queryParams
|
|
708
|
+
async addItem (subscriptionUniqueId, data) {
|
|
709
|
+
const response = await transport.post(`/subscriptions/${subscriptionUniqueId}/items`, {
|
|
710
|
+
item: buildItemBody(data)
|
|
530
711
|
});
|
|
531
|
-
return
|
|
712
|
+
return decodeOne(response, subscriptionItemMapper);
|
|
532
713
|
}
|
|
533
714
|
};
|
|
534
715
|
}
|
|
@@ -536,31 +717,62 @@ function createSubscriptionsService(transport, _config) {
|
|
|
536
717
|
const subscriptionModelMapper = {
|
|
537
718
|
type: 'subscription_model',
|
|
538
719
|
map: (resource)=>{
|
|
539
|
-
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13, _resource_attributes14, _resource_attributes15, _resource_attributes16;
|
|
540
|
-
var _resource_attributes_allow_promotion_codes;
|
|
720
|
+
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13, _resource_attributes14, _resource_attributes15, _resource_attributes16, _resource_attributes17, _resource_attributes18, _resource_attributes19, _resource_attributes20, _resource_attributes21, _resource_attributes22, _resource_attributes23;
|
|
541
721
|
return {
|
|
542
722
|
id: resource.id,
|
|
543
|
-
uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
|
|
544
|
-
code: (_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['code'],
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
723
|
+
uniqueId: parseString((_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id']) || '',
|
|
724
|
+
code: parseString((_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['code']),
|
|
725
|
+
description: parseString((_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['description']),
|
|
726
|
+
promotional: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['promotional'],
|
|
727
|
+
programCode: parseString((_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['program_code']),
|
|
728
|
+
duration: parseNumber((_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['duration']) || undefined,
|
|
729
|
+
durationUnit: parseString((_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['duration_unit']),
|
|
730
|
+
durationDescription: parseString((_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['duration_description']),
|
|
731
|
+
recurringPaymentFees: parseNumber((_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['recurring_payment_fees']) || undefined,
|
|
732
|
+
recurringPaymentAmount: parseNumber((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['recurring_payment_amount']) || undefined,
|
|
733
|
+
contentUrl: parseString((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['content_url']),
|
|
734
|
+
startAt: parseDate((_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['start_at']),
|
|
735
|
+
endAt: parseDate((_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['end_at']),
|
|
736
|
+
initialPayment: parseNumber((_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['initial_payment']) || undefined,
|
|
737
|
+
subscriptionType: parseString((_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['subscription_type']),
|
|
738
|
+
maxItems: parseNumber((_resource_attributes15 = resource.attributes) == null ? void 0 : _resource_attributes15['max_items']) || undefined,
|
|
739
|
+
stripeProductId: parseString((_resource_attributes16 = resource.attributes) == null ? void 0 : _resource_attributes16['stripe_product_id']),
|
|
740
|
+
productType: parseString((_resource_attributes17 = resource.attributes) == null ? void 0 : _resource_attributes17['product_type']),
|
|
741
|
+
trialPeriodDays: parseNumber((_resource_attributes18 = resource.attributes) == null ? void 0 : _resource_attributes18['trial_period_days']) || undefined,
|
|
742
|
+
allowPromotionCodes: (_resource_attributes19 = resource.attributes) == null ? void 0 : _resource_attributes19['allow_promotion_codes'],
|
|
743
|
+
features: (_resource_attributes20 = resource.attributes) == null ? void 0 : _resource_attributes20['features'],
|
|
744
|
+
status: parseString((_resource_attributes21 = resource.attributes) == null ? void 0 : _resource_attributes21['status']),
|
|
745
|
+
createdAt: parseDate((_resource_attributes22 = resource.attributes) == null ? void 0 : _resource_attributes22['created_at']) || new Date(),
|
|
746
|
+
updatedAt: parseDate((_resource_attributes23 = resource.attributes) == null ? void 0 : _resource_attributes23['updated_at']) || new Date()
|
|
560
747
|
};
|
|
561
748
|
}
|
|
562
749
|
};
|
|
563
750
|
|
|
751
|
+
function buildSubModelBody(data) {
|
|
752
|
+
const body = {};
|
|
753
|
+
if (data.uniqueId) body['unique_id'] = data.uniqueId;
|
|
754
|
+
if (data.code) body['code'] = data.code;
|
|
755
|
+
if (data.description) body['description'] = data.description;
|
|
756
|
+
if (data.promotional !== undefined) body['promotional'] = data.promotional;
|
|
757
|
+
if (data.programCode) body['program_code'] = data.programCode;
|
|
758
|
+
if (data.duration !== undefined) body['duration'] = data.duration;
|
|
759
|
+
if (data.durationUnit) body['duration_unit'] = data.durationUnit;
|
|
760
|
+
if (data.durationDescription) body['duration_description'] = data.durationDescription;
|
|
761
|
+
if (data.recurringPaymentFees !== undefined) body['recurring_payment_fees'] = data.recurringPaymentFees;
|
|
762
|
+
if (data.recurringPaymentAmount !== undefined) body['recurring_payment_amount'] = data.recurringPaymentAmount;
|
|
763
|
+
if (data.contentUrl) body['content_url'] = data.contentUrl;
|
|
764
|
+
if (data.startAt) body['start_at'] = data.startAt;
|
|
765
|
+
if (data.endAt) body['end_at'] = data.endAt;
|
|
766
|
+
if (data.initialPayment !== undefined) body['initial_payment'] = data.initialPayment;
|
|
767
|
+
if (data.subscriptionType) body['subscription_type'] = data.subscriptionType;
|
|
768
|
+
if (data.maxItems !== undefined) body['max_items'] = data.maxItems;
|
|
769
|
+
if (data.stripeProductId) body['stripe_product_id'] = data.stripeProductId;
|
|
770
|
+
if (data.productType) body['product_type'] = data.productType;
|
|
771
|
+
if (data.trialPeriodDays !== undefined) body['trial_period_days'] = data.trialPeriodDays;
|
|
772
|
+
if (data.allowPromotionCodes !== undefined) body['allow_promotion_codes'] = data.allowPromotionCodes;
|
|
773
|
+
if (data.features) body['features'] = data.features;
|
|
774
|
+
return body;
|
|
775
|
+
}
|
|
564
776
|
function createSubscriptionModelsService(transport, _config) {
|
|
565
777
|
return {
|
|
566
778
|
async list (params) {
|
|
@@ -581,40 +793,13 @@ function createSubscriptionModelsService(transport, _config) {
|
|
|
581
793
|
},
|
|
582
794
|
async create (data) {
|
|
583
795
|
const response = await transport.post('/subscription_models', {
|
|
584
|
-
subscription_model:
|
|
585
|
-
code: data.code,
|
|
586
|
-
name: data.name,
|
|
587
|
-
description: data.description,
|
|
588
|
-
price: data.price,
|
|
589
|
-
currency: data.currency,
|
|
590
|
-
interval: data.interval,
|
|
591
|
-
interval_count: data.intervalCount,
|
|
592
|
-
trial_days: data.trialDays,
|
|
593
|
-
features: data.features,
|
|
594
|
-
limits: data.limits,
|
|
595
|
-
payload: data.payload,
|
|
596
|
-
allow_promotion_codes: data.allowPromotionCodes
|
|
597
|
-
}
|
|
796
|
+
subscription_model: buildSubModelBody(data)
|
|
598
797
|
});
|
|
599
798
|
return decodeOne(response, subscriptionModelMapper);
|
|
600
799
|
},
|
|
601
800
|
async update (uniqueId, data) {
|
|
602
801
|
const response = await transport.put(`/subscription_models/${uniqueId}`, {
|
|
603
|
-
subscription_model:
|
|
604
|
-
name: data.name,
|
|
605
|
-
description: data.description,
|
|
606
|
-
price: data.price,
|
|
607
|
-
currency: data.currency,
|
|
608
|
-
interval: data.interval,
|
|
609
|
-
interval_count: data.intervalCount,
|
|
610
|
-
trial_days: data.trialDays,
|
|
611
|
-
features: data.features,
|
|
612
|
-
limits: data.limits,
|
|
613
|
-
enabled: data.enabled,
|
|
614
|
-
status: data.status,
|
|
615
|
-
payload: data.payload,
|
|
616
|
-
allow_promotion_codes: data.allowPromotionCodes
|
|
617
|
-
}
|
|
802
|
+
subscription_model: buildSubModelBody(data)
|
|
618
803
|
});
|
|
619
804
|
return decodeOne(response, subscriptionModelMapper);
|
|
620
805
|
}
|
|
@@ -624,18 +809,21 @@ function createSubscriptionModelsService(transport, _config) {
|
|
|
624
809
|
const salesEntityMapper = {
|
|
625
810
|
type: 'entity',
|
|
626
811
|
map: (resource)=>{
|
|
627
|
-
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8;
|
|
812
|
+
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11;
|
|
628
813
|
return {
|
|
629
814
|
id: resource.id,
|
|
630
|
-
uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
815
|
+
uniqueId: parseString((_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id']) || '',
|
|
816
|
+
entityType: parseString((_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['entity_type']),
|
|
817
|
+
entityAlias: parseString((_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['entity_alias']),
|
|
818
|
+
entitySource: parseString((_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['entity_source']),
|
|
819
|
+
entityUrl: parseString((_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['entity_url']),
|
|
820
|
+
stripeId: parseString((_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['stripe_id']),
|
|
821
|
+
status: parseString((_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['status']),
|
|
822
|
+
timeZone: parseString((_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['time_zone']),
|
|
823
|
+
preferredLanguage: parseString((_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['preferred_language']),
|
|
824
|
+
avatarUrl: parseString((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['avatar_url']),
|
|
825
|
+
createdAt: parseDate((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['created_at']) || new Date(),
|
|
826
|
+
updatedAt: parseDate((_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['updated_at']) || new Date()
|
|
639
827
|
};
|
|
640
828
|
}
|
|
641
829
|
};
|
|
@@ -643,24 +831,38 @@ const salesEntityMapper = {
|
|
|
643
831
|
const entitySubscriptionMapper = {
|
|
644
832
|
type: 'EntitySubscription',
|
|
645
833
|
map: (resource)=>{
|
|
646
|
-
var _resource_attributes_subscription_unique_id, _resource_attributes_subscription_model_unique_id, _resource_attributes_start_at, _resource_attributes_end_at, _resource_attributes_closed_at, _resource_attributes_created_at,
|
|
834
|
+
var _resource_attributes_subscription_unique_id, _resource_attributes_subscription_model_unique_id, _resource_attributes_start_at, _resource_attributes_end_at, _resource_attributes_closed_at, _resource_attributes_created_at, _resource_attributes_updated_at;
|
|
647
835
|
return {
|
|
648
836
|
id: resource.id,
|
|
649
|
-
uniqueId: (_resource_attributes_subscription_unique_id = resource.attributes['subscription_unique_id']) != null ? _resource_attributes_subscription_unique_id : resource.attributes['unique_id'],
|
|
650
|
-
entityUniqueId: resource.attributes['entity_unique_id'],
|
|
651
|
-
subscriptionModelUniqueId: (_resource_attributes_subscription_model_unique_id = resource.attributes['subscription_model_unique_id']) != null ? _resource_attributes_subscription_model_unique_id : resource.attributes['code'],
|
|
652
|
-
|
|
837
|
+
uniqueId: parseString((_resource_attributes_subscription_unique_id = resource.attributes['subscription_unique_id']) != null ? _resource_attributes_subscription_unique_id : resource.attributes['unique_id']) || '',
|
|
838
|
+
entityUniqueId: resource.attributes['entity_unique_id'] || '',
|
|
839
|
+
subscriptionModelUniqueId: parseString((_resource_attributes_subscription_model_unique_id = resource.attributes['subscription_model_unique_id']) != null ? _resource_attributes_subscription_model_unique_id : resource.attributes['code']) || '',
|
|
840
|
+
ownerUniqueId: parseString(resource.attributes['owner_unique_id']),
|
|
841
|
+
ownerType: parseString(resource.attributes['owner_type']),
|
|
842
|
+
status: resource.attributes['status'] || '',
|
|
653
843
|
startDate: parseDate((_resource_attributes_start_at = resource.attributes['start_at']) != null ? _resource_attributes_start_at : resource.attributes['start_date']),
|
|
654
844
|
endDate: parseDate((_resource_attributes_end_at = resource.attributes['end_at']) != null ? _resource_attributes_end_at : resource.attributes['end_date']),
|
|
655
845
|
trialEndDate: parseDate(resource.attributes['trial_end_date']),
|
|
656
846
|
cancelledAt: parseDate((_resource_attributes_closed_at = resource.attributes['closed_at']) != null ? _resource_attributes_closed_at : resource.attributes['cancelled_at']),
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
updatedAt: (_parseDate1 = parseDate((_resource_attributes_updated_at = resource.attributes['updated_at']) != null ? _resource_attributes_updated_at : resource.attributes['subscribed_at'])) != null ? _parseDate1 : new Date()
|
|
847
|
+
createdAt: parseDate((_resource_attributes_created_at = resource.attributes['created_at']) != null ? _resource_attributes_created_at : resource.attributes['subscribed_at']) || new Date(),
|
|
848
|
+
updatedAt: parseDate((_resource_attributes_updated_at = resource.attributes['updated_at']) != null ? _resource_attributes_updated_at : resource.attributes['subscribed_at']) || new Date()
|
|
660
849
|
};
|
|
661
850
|
}
|
|
662
851
|
};
|
|
663
852
|
|
|
853
|
+
function buildEntityBody(data) {
|
|
854
|
+
const body = {};
|
|
855
|
+
if (data.entityType) body['entity_type'] = data.entityType;
|
|
856
|
+
if (data.entityAlias) body['entity_alias'] = data.entityAlias;
|
|
857
|
+
if (data.entitySource) body['entity_source'] = data.entitySource;
|
|
858
|
+
if (data.entityUrl) body['entity_url'] = data.entityUrl;
|
|
859
|
+
if (data.stripeId) body['stripe_id'] = data.stripeId;
|
|
860
|
+
if (data.status) body['status'] = data.status;
|
|
861
|
+
if (data.timeZone) body['time_zone'] = data.timeZone;
|
|
862
|
+
if (data.preferredLanguage) body['preferred_language'] = data.preferredLanguage;
|
|
863
|
+
if (data.avatarUrl) body['avatar_url'] = data.avatarUrl;
|
|
864
|
+
return body;
|
|
865
|
+
}
|
|
664
866
|
function createSalesEntitiesService(transport, _config) {
|
|
665
867
|
return {
|
|
666
868
|
async list (params) {
|
|
@@ -681,25 +883,13 @@ function createSalesEntitiesService(transport, _config) {
|
|
|
681
883
|
},
|
|
682
884
|
async register (uniqueId, data) {
|
|
683
885
|
const response = await transport.post(`/entities/${uniqueId}/register`, {
|
|
684
|
-
entity: {
|
|
685
|
-
code: data == null ? void 0 : data.code,
|
|
686
|
-
name: data == null ? void 0 : data.name,
|
|
687
|
-
email: data == null ? void 0 : data.email,
|
|
688
|
-
phone: data == null ? void 0 : data.phone,
|
|
689
|
-
payload: data == null ? void 0 : data.payload
|
|
690
|
-
}
|
|
886
|
+
entity: data ? buildEntityBody(data) : {}
|
|
691
887
|
});
|
|
692
888
|
return decodeOne(response, salesEntityMapper);
|
|
693
889
|
},
|
|
694
890
|
async update (uniqueId, data) {
|
|
695
891
|
const response = await transport.put(`/entities/${uniqueId}`, {
|
|
696
|
-
entity:
|
|
697
|
-
name: data.name,
|
|
698
|
-
email: data.email,
|
|
699
|
-
phone: data.phone,
|
|
700
|
-
status: data.status,
|
|
701
|
-
payload: data.payload
|
|
702
|
-
}
|
|
892
|
+
entity: buildEntityBody(data)
|
|
703
893
|
});
|
|
704
894
|
return decodeOne(response, salesEntityMapper);
|
|
705
895
|
},
|
|
@@ -707,9 +897,8 @@ function createSalesEntitiesService(transport, _config) {
|
|
|
707
897
|
const response = await transport.post(`/entities/${uniqueId}/subscriptions`, {
|
|
708
898
|
subscription: {
|
|
709
899
|
subscription_model_unique_id: data.subscriptionModelUniqueId,
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
payload: data.payload
|
|
900
|
+
owner_unique_id: data.ownerUniqueId,
|
|
901
|
+
owner_type: data.ownerType
|
|
713
902
|
}
|
|
714
903
|
});
|
|
715
904
|
return decodeOne(response, entitySubscriptionMapper);
|
|
@@ -717,9 +906,9 @@ function createSalesEntitiesService(transport, _config) {
|
|
|
717
906
|
async updateSubscription (uniqueId, subscriptionUniqueId, data) {
|
|
718
907
|
const response = await transport.put(`/entities/${uniqueId}/subscriptions/${subscriptionUniqueId}`, {
|
|
719
908
|
subscription: {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
909
|
+
subscription_model_unique_id: data.subscriptionModelUniqueId,
|
|
910
|
+
owner_unique_id: data.ownerUniqueId,
|
|
911
|
+
owner_type: data.ownerType
|
|
723
912
|
}
|
|
724
913
|
});
|
|
725
914
|
return decodeOne(response, entitySubscriptionMapper);
|
|
@@ -730,17 +919,28 @@ function createSalesEntitiesService(transport, _config) {
|
|
|
730
919
|
const salesUserMapper = {
|
|
731
920
|
type: 'user',
|
|
732
921
|
map: (resource)=>{
|
|
733
|
-
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7;
|
|
922
|
+
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13, _resource_attributes14, _resource_attributes15, _resource_attributes16, _resource_attributes17, _resource_attributes18;
|
|
734
923
|
return {
|
|
735
924
|
id: resource.id,
|
|
736
|
-
uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
925
|
+
uniqueId: parseString((_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id']) || '',
|
|
926
|
+
name: parseString((_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['name']),
|
|
927
|
+
firstName: parseString((_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['first_name']),
|
|
928
|
+
lastName: parseString((_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['last_name']),
|
|
929
|
+
email: parseString((_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['email']),
|
|
930
|
+
phone: parseString((_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['phone']),
|
|
931
|
+
avatarUrl: parseString((_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['avatar_url']),
|
|
932
|
+
roleName: parseString((_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['role_name']),
|
|
933
|
+
roleUniqueId: parseString((_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['role_unique_id']),
|
|
934
|
+
stripeId: parseString((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['stripe_id']),
|
|
935
|
+
timeZone: parseString((_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['time_zone']),
|
|
936
|
+
preferredLanguage: parseString((_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['preferred_language']),
|
|
937
|
+
emailNotifications: (_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['email_notifications'],
|
|
938
|
+
smsNotifications: (_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['sms_notifications'],
|
|
939
|
+
whatsappNotifications: (_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['whatsapp_notifications'],
|
|
940
|
+
otherNotifications: (_resource_attributes15 = resource.attributes) == null ? void 0 : _resource_attributes15['other_notifications'],
|
|
941
|
+
status: parseString((_resource_attributes16 = resource.attributes) == null ? void 0 : _resource_attributes16['status']),
|
|
942
|
+
createdAt: parseDate((_resource_attributes17 = resource.attributes) == null ? void 0 : _resource_attributes17['created_at']) || new Date(),
|
|
943
|
+
updatedAt: parseDate((_resource_attributes18 = resource.attributes) == null ? void 0 : _resource_attributes18['updated_at']) || new Date()
|
|
744
944
|
};
|
|
745
945
|
}
|
|
746
946
|
};
|
|
@@ -781,6 +981,25 @@ const userSubscriptionMapper = {
|
|
|
781
981
|
}
|
|
782
982
|
};
|
|
783
983
|
|
|
984
|
+
function buildUserBody(data) {
|
|
985
|
+
const body = {};
|
|
986
|
+
if (data.name) body['name'] = data.name;
|
|
987
|
+
if (data.firstName) body['first_name'] = data.firstName;
|
|
988
|
+
if (data.lastName) body['last_name'] = data.lastName;
|
|
989
|
+
if (data.email) body['email'] = data.email;
|
|
990
|
+
if (data.phone) body['phone'] = data.phone;
|
|
991
|
+
if (data.avatarUrl) body['avatar_url'] = data.avatarUrl;
|
|
992
|
+
if (data.roleName) body['role_name'] = data.roleName;
|
|
993
|
+
if (data.roleUniqueId) body['role_unique_id'] = data.roleUniqueId;
|
|
994
|
+
if (data.stripeId) body['stripe_id'] = data.stripeId;
|
|
995
|
+
if (data.timeZone) body['time_zone'] = data.timeZone;
|
|
996
|
+
if (data.preferredLanguage) body['preferred_language'] = data.preferredLanguage;
|
|
997
|
+
if (data.emailNotifications !== undefined) body['email_notifications'] = data.emailNotifications;
|
|
998
|
+
if (data.smsNotifications !== undefined) body['sms_notifications'] = data.smsNotifications;
|
|
999
|
+
if (data.whatsappNotifications !== undefined) body['whatsapp_notifications'] = data.whatsappNotifications;
|
|
1000
|
+
if (data.otherNotifications !== undefined) body['other_notifications'] = data.otherNotifications;
|
|
1001
|
+
return body;
|
|
1002
|
+
}
|
|
784
1003
|
function createSalesUsersService(transport, _config) {
|
|
785
1004
|
return {
|
|
786
1005
|
async list (params) {
|
|
@@ -801,23 +1020,13 @@ function createSalesUsersService(transport, _config) {
|
|
|
801
1020
|
},
|
|
802
1021
|
async register (uniqueId, data) {
|
|
803
1022
|
const response = await transport.post(`/users/${uniqueId}/register`, {
|
|
804
|
-
user: {
|
|
805
|
-
email: data == null ? void 0 : data.email,
|
|
806
|
-
name: data == null ? void 0 : data.name,
|
|
807
|
-
phone: data == null ? void 0 : data.phone,
|
|
808
|
-
payload: data == null ? void 0 : data.payload
|
|
809
|
-
}
|
|
1023
|
+
user: data ? buildUserBody(data) : {}
|
|
810
1024
|
});
|
|
811
1025
|
return decodeOne(response, salesUserMapper);
|
|
812
1026
|
},
|
|
813
1027
|
async update (uniqueId, data) {
|
|
814
1028
|
const response = await transport.put(`/users/${uniqueId}`, {
|
|
815
|
-
user:
|
|
816
|
-
name: data.name,
|
|
817
|
-
phone: data.phone,
|
|
818
|
-
status: data.status,
|
|
819
|
-
payload: data.payload
|
|
820
|
-
}
|
|
1029
|
+
user: buildUserBody(data)
|
|
821
1030
|
});
|
|
822
1031
|
return decodeOne(response, salesUserMapper);
|
|
823
1032
|
},
|
|
@@ -854,8 +1063,7 @@ function createSalesUsersService(transport, _config) {
|
|
|
854
1063
|
subscription: {
|
|
855
1064
|
subscription_model_unique_id: data.subscriptionModelUniqueId,
|
|
856
1065
|
subscription_number: data.subscriptionNumber,
|
|
857
|
-
notes: data.notes
|
|
858
|
-
payload: data.payload
|
|
1066
|
+
notes: data.notes
|
|
859
1067
|
}
|
|
860
1068
|
});
|
|
861
1069
|
return decodeOne(response, userSubscriptionMapper);
|
|
@@ -865,19 +1073,14 @@ function createSalesUsersService(transport, _config) {
|
|
|
865
1073
|
subscription: {
|
|
866
1074
|
subscription_model_unique_id: data.subscriptionModelUniqueId,
|
|
867
1075
|
subscription_number: data.subscriptionNumber,
|
|
868
|
-
notes: data.notes
|
|
869
|
-
payload: data.payload
|
|
1076
|
+
notes: data.notes
|
|
870
1077
|
}
|
|
871
1078
|
});
|
|
872
1079
|
return decodeOne(response, userSubscriptionMapper);
|
|
873
1080
|
},
|
|
874
1081
|
async addConsumption (uniqueId, subscriptionUniqueId, data) {
|
|
875
1082
|
const response = await transport.post(`/users/${uniqueId}/subscriptions/${subscriptionUniqueId}/consumption`, {
|
|
876
|
-
consumption:
|
|
877
|
-
quantity: data.quantity,
|
|
878
|
-
description: data.description,
|
|
879
|
-
payload: data.payload
|
|
880
|
-
}
|
|
1083
|
+
consumption: data.consumption
|
|
881
1084
|
});
|
|
882
1085
|
return decodeOne(response, userSubscriptionMapper);
|
|
883
1086
|
},
|
|
@@ -894,19 +1097,29 @@ function createSalesUsersService(transport, _config) {
|
|
|
894
1097
|
const salesCustomerMapper = {
|
|
895
1098
|
type: 'customer',
|
|
896
1099
|
map: (resource)=>{
|
|
897
|
-
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9;
|
|
1100
|
+
var _resource_attributes, _resource_attributes1, _resource_attributes2, _resource_attributes3, _resource_attributes4, _resource_attributes5, _resource_attributes6, _resource_attributes7, _resource_attributes8, _resource_attributes9, _resource_attributes10, _resource_attributes11, _resource_attributes12, _resource_attributes13, _resource_attributes14, _resource_attributes15, _resource_attributes16, _resource_attributes17, _resource_attributes18, _resource_attributes19;
|
|
898
1101
|
return {
|
|
899
1102
|
id: resource.id,
|
|
900
|
-
uniqueId: (_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id'],
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
phone: (_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['phone'],
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
status: (_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['status'],
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
1103
|
+
uniqueId: parseString((_resource_attributes = resource.attributes) == null ? void 0 : _resource_attributes['unique_id']) || '',
|
|
1104
|
+
name: parseString((_resource_attributes1 = resource.attributes) == null ? void 0 : _resource_attributes1['name']),
|
|
1105
|
+
email: parseString((_resource_attributes2 = resource.attributes) == null ? void 0 : _resource_attributes2['email']),
|
|
1106
|
+
phone: parseString((_resource_attributes3 = resource.attributes) == null ? void 0 : _resource_attributes3['phone']),
|
|
1107
|
+
companyUniqueId: parseString((_resource_attributes4 = resource.attributes) == null ? void 0 : _resource_attributes4['company_unique_id']),
|
|
1108
|
+
stripeId: parseString((_resource_attributes5 = resource.attributes) == null ? void 0 : _resource_attributes5['stripe_id']),
|
|
1109
|
+
status: parseString((_resource_attributes6 = resource.attributes) == null ? void 0 : _resource_attributes6['status']),
|
|
1110
|
+
timeZone: parseString((_resource_attributes7 = resource.attributes) == null ? void 0 : _resource_attributes7['time_zone']),
|
|
1111
|
+
preferredLanguage: parseString((_resource_attributes8 = resource.attributes) == null ? void 0 : _resource_attributes8['preferred_language']),
|
|
1112
|
+
avatarUrl: parseString((_resource_attributes9 = resource.attributes) == null ? void 0 : _resource_attributes9['avatar_url']),
|
|
1113
|
+
emailNotifications: (_resource_attributes10 = resource.attributes) == null ? void 0 : _resource_attributes10['email_notifications'],
|
|
1114
|
+
smsNotifications: (_resource_attributes11 = resource.attributes) == null ? void 0 : _resource_attributes11['sms_notifications'],
|
|
1115
|
+
whatsappNotifications: (_resource_attributes12 = resource.attributes) == null ? void 0 : _resource_attributes12['whatsapp_notifications'],
|
|
1116
|
+
otherNotifications: (_resource_attributes13 = resource.attributes) == null ? void 0 : _resource_attributes13['other_notifications'],
|
|
1117
|
+
source: parseString((_resource_attributes14 = resource.attributes) == null ? void 0 : _resource_attributes14['source']),
|
|
1118
|
+
sourceAlias: parseString((_resource_attributes15 = resource.attributes) == null ? void 0 : _resource_attributes15['source_alias']),
|
|
1119
|
+
sourceId: parseString((_resource_attributes16 = resource.attributes) == null ? void 0 : _resource_attributes16['source_id']),
|
|
1120
|
+
sourceType: parseString((_resource_attributes17 = resource.attributes) == null ? void 0 : _resource_attributes17['source_type']),
|
|
1121
|
+
createdAt: parseDate((_resource_attributes18 = resource.attributes) == null ? void 0 : _resource_attributes18['created_at']) || new Date(),
|
|
1122
|
+
updatedAt: parseDate((_resource_attributes19 = resource.attributes) == null ? void 0 : _resource_attributes19['updated_at']) || new Date()
|
|
910
1123
|
};
|
|
911
1124
|
}
|
|
912
1125
|
};
|
|
@@ -914,24 +1127,46 @@ const salesCustomerMapper = {
|
|
|
914
1127
|
const customerSubscriptionMapper = {
|
|
915
1128
|
type: 'CustomerSubscription',
|
|
916
1129
|
map: (resource)=>{
|
|
917
|
-
var _resource_attributes_subscription_unique_id, _resource_attributes_subscription_model_unique_id, _resource_attributes_start_at, _resource_attributes_end_at, _resource_attributes_closed_at, _resource_attributes_created_at,
|
|
1130
|
+
var _resource_attributes_subscription_unique_id, _resource_attributes_subscription_model_unique_id, _resource_attributes_start_at, _resource_attributes_end_at, _resource_attributes_closed_at, _resource_attributes_created_at, _resource_attributes_updated_at;
|
|
918
1131
|
return {
|
|
919
1132
|
id: resource.id,
|
|
920
|
-
uniqueId: (_resource_attributes_subscription_unique_id = resource.attributes['subscription_unique_id']) != null ? _resource_attributes_subscription_unique_id : resource.attributes['unique_id'],
|
|
921
|
-
customerUniqueId: resource.attributes['customer_unique_id'],
|
|
922
|
-
subscriptionModelUniqueId: (_resource_attributes_subscription_model_unique_id = resource.attributes['subscription_model_unique_id']) != null ? _resource_attributes_subscription_model_unique_id : resource.attributes['code'],
|
|
923
|
-
|
|
1133
|
+
uniqueId: parseString((_resource_attributes_subscription_unique_id = resource.attributes['subscription_unique_id']) != null ? _resource_attributes_subscription_unique_id : resource.attributes['unique_id']) || '',
|
|
1134
|
+
customerUniqueId: resource.attributes['customer_unique_id'] || '',
|
|
1135
|
+
subscriptionModelUniqueId: parseString((_resource_attributes_subscription_model_unique_id = resource.attributes['subscription_model_unique_id']) != null ? _resource_attributes_subscription_model_unique_id : resource.attributes['code']) || '',
|
|
1136
|
+
subscriptionNumber: parseString(resource.attributes['subscription_number']),
|
|
1137
|
+
notes: parseString(resource.attributes['notes']),
|
|
1138
|
+
status: resource.attributes['status'] || '',
|
|
924
1139
|
startDate: parseDate((_resource_attributes_start_at = resource.attributes['start_at']) != null ? _resource_attributes_start_at : resource.attributes['start_date']),
|
|
925
1140
|
endDate: parseDate((_resource_attributes_end_at = resource.attributes['end_at']) != null ? _resource_attributes_end_at : resource.attributes['end_date']),
|
|
926
1141
|
trialEndDate: parseDate(resource.attributes['trial_end_date']),
|
|
927
1142
|
cancelledAt: parseDate((_resource_attributes_closed_at = resource.attributes['closed_at']) != null ? _resource_attributes_closed_at : resource.attributes['cancelled_at']),
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
updatedAt: (_parseDate1 = parseDate((_resource_attributes_updated_at = resource.attributes['updated_at']) != null ? _resource_attributes_updated_at : resource.attributes['subscribed_at'])) != null ? _parseDate1 : new Date()
|
|
1143
|
+
createdAt: parseDate((_resource_attributes_created_at = resource.attributes['created_at']) != null ? _resource_attributes_created_at : resource.attributes['subscribed_at']) || new Date(),
|
|
1144
|
+
updatedAt: parseDate((_resource_attributes_updated_at = resource.attributes['updated_at']) != null ? _resource_attributes_updated_at : resource.attributes['subscribed_at']) || new Date()
|
|
931
1145
|
};
|
|
932
1146
|
}
|
|
933
1147
|
};
|
|
934
1148
|
|
|
1149
|
+
function buildCustomerBody(data) {
|
|
1150
|
+
const body = {};
|
|
1151
|
+
if (data.name) body['name'] = data.name;
|
|
1152
|
+
if (data.email) body['email'] = data.email;
|
|
1153
|
+
if (data.phone) body['phone'] = data.phone;
|
|
1154
|
+
if (data.companyUniqueId) body['company_unique_id'] = data.companyUniqueId;
|
|
1155
|
+
if (data.stripeId) body['stripe_id'] = data.stripeId;
|
|
1156
|
+
if (data.status) body['status'] = data.status;
|
|
1157
|
+
if (data.timeZone) body['time_zone'] = data.timeZone;
|
|
1158
|
+
if (data.preferredLanguage) body['preferred_language'] = data.preferredLanguage;
|
|
1159
|
+
if (data.avatarUrl) body['avatar_url'] = data.avatarUrl;
|
|
1160
|
+
if (data.emailNotifications !== undefined) body['email_notifications'] = data.emailNotifications;
|
|
1161
|
+
if (data.smsNotifications !== undefined) body['sms_notifications'] = data.smsNotifications;
|
|
1162
|
+
if (data.whatsappNotifications !== undefined) body['whatsapp_notifications'] = data.whatsappNotifications;
|
|
1163
|
+
if (data.otherNotifications !== undefined) body['other_notifications'] = data.otherNotifications;
|
|
1164
|
+
if (data.source) body['source'] = data.source;
|
|
1165
|
+
if (data.sourceAlias) body['source_alias'] = data.sourceAlias;
|
|
1166
|
+
if (data.sourceId) body['source_id'] = data.sourceId;
|
|
1167
|
+
if (data.sourceType) body['source_type'] = data.sourceType;
|
|
1168
|
+
return body;
|
|
1169
|
+
}
|
|
935
1170
|
function createSalesCustomersService(transport, _config) {
|
|
936
1171
|
return {
|
|
937
1172
|
async get (uniqueId) {
|
|
@@ -940,14 +1175,7 @@ function createSalesCustomersService(transport, _config) {
|
|
|
940
1175
|
},
|
|
941
1176
|
async register (uniqueId, data) {
|
|
942
1177
|
const response = await transport.post(`/customers/${uniqueId}/register`, {
|
|
943
|
-
customer: {
|
|
944
|
-
email: data == null ? void 0 : data.email,
|
|
945
|
-
name: data == null ? void 0 : data.name,
|
|
946
|
-
phone: data == null ? void 0 : data.phone,
|
|
947
|
-
stripe_customer_id: data == null ? void 0 : data.stripeCustomerId,
|
|
948
|
-
mercadopago_customer_id: data == null ? void 0 : data.mercadopagoCustomerId,
|
|
949
|
-
payload: data == null ? void 0 : data.payload
|
|
950
|
-
}
|
|
1178
|
+
customer: data ? buildCustomerBody(data) : {}
|
|
951
1179
|
});
|
|
952
1180
|
return decodeOne(response, salesCustomerMapper);
|
|
953
1181
|
},
|
|
@@ -959,9 +1187,8 @@ function createSalesCustomersService(transport, _config) {
|
|
|
959
1187
|
const response = await transport.post(`/customers/${uniqueId}/subscriptions`, {
|
|
960
1188
|
subscription: {
|
|
961
1189
|
subscription_model_unique_id: data.subscriptionModelUniqueId,
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
payload: data.payload
|
|
1190
|
+
subscription_number: data.subscriptionNumber,
|
|
1191
|
+
notes: data.notes
|
|
965
1192
|
}
|
|
966
1193
|
});
|
|
967
1194
|
return decodeOne(response, customerSubscriptionMapper);
|
|
@@ -969,9 +1196,9 @@ function createSalesCustomersService(transport, _config) {
|
|
|
969
1196
|
async updateSubscription (uniqueId, subscriptionUniqueId, data) {
|
|
970
1197
|
const response = await transport.put(`/customers/${uniqueId}/subscriptions/${subscriptionUniqueId}`, {
|
|
971
1198
|
subscription: {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1199
|
+
subscription_model_unique_id: data.subscriptionModelUniqueId,
|
|
1200
|
+
subscription_number: data.subscriptionNumber,
|
|
1201
|
+
notes: data.notes
|
|
975
1202
|
}
|
|
976
1203
|
});
|
|
977
1204
|
return decodeOne(response, customerSubscriptionMapper);
|
|
@@ -1259,58 +1486,58 @@ const stripeWebhookMapper = {
|
|
|
1259
1486
|
}
|
|
1260
1487
|
};
|
|
1261
1488
|
|
|
1489
|
+
function buildSubscriptionBody(data) {
|
|
1490
|
+
const body = {};
|
|
1491
|
+
if (data.customerId) body['customer_id'] = data.customerId;
|
|
1492
|
+
if (data.setupPriceId) body['setup_price_id'] = data.setupPriceId;
|
|
1493
|
+
if (data.subscriptionPriceId) body['subscription_price_id'] = data.subscriptionPriceId;
|
|
1494
|
+
if (data.priceUniqueId) body['price_unique_id'] = data.priceUniqueId;
|
|
1495
|
+
if (data.localPriceId) body['local_price_id'] = data.localPriceId;
|
|
1496
|
+
if (data.cardToken) body['card_token'] = data.cardToken;
|
|
1497
|
+
if (data.trialPeriodDays !== undefined) body['trial_period_days'] = data.trialPeriodDays;
|
|
1498
|
+
if (data.multipleSubscriptions !== undefined) body['multiple_subscriptions'] = data.multipleSubscriptions;
|
|
1499
|
+
if (data.appName) body['app_name'] = data.appName;
|
|
1500
|
+
if (data.parentName) body['parent_name'] = data.parentName;
|
|
1501
|
+
if (data.description) body['description'] = data.description;
|
|
1502
|
+
if (data.subscriptionType) body['subscription_type'] = data.subscriptionType;
|
|
1503
|
+
if (data.entityType) body['entity_type'] = data.entityType;
|
|
1504
|
+
if (data.entityId) body['entity_id'] = data.entityId;
|
|
1505
|
+
if (data.customerCompanyId) body['customer_company_id'] = data.customerCompanyId;
|
|
1506
|
+
return body;
|
|
1507
|
+
}
|
|
1262
1508
|
function createStripeService(transport, _config) {
|
|
1263
1509
|
return {
|
|
1264
1510
|
async createCustomer (data) {
|
|
1265
1511
|
const response = await transport.post('/stripe/customers', {
|
|
1266
1512
|
customer: {
|
|
1267
|
-
email: data.email,
|
|
1268
1513
|
name: data.name,
|
|
1269
1514
|
phone: data.phone,
|
|
1515
|
+
email: data.email,
|
|
1270
1516
|
token: data.token,
|
|
1271
1517
|
user_unique_id: data.userUniqueId,
|
|
1272
1518
|
identity_type: data.identityType,
|
|
1273
1519
|
company_unique_id: data.companyUniqueId,
|
|
1274
1520
|
entity_unique_id: data.entityUniqueId,
|
|
1275
|
-
entity_type: data.entityType
|
|
1276
|
-
metadata: data.metadata
|
|
1521
|
+
entity_type: data.entityType
|
|
1277
1522
|
}
|
|
1278
1523
|
});
|
|
1279
1524
|
return decodeOne(response, stripeCustomerResponseMapper);
|
|
1280
1525
|
},
|
|
1281
1526
|
async createCheckoutSession (data) {
|
|
1282
|
-
var _data_lineItems;
|
|
1283
1527
|
const response = await transport.post('/stripe/sessions', {
|
|
1284
1528
|
session: {
|
|
1285
|
-
|
|
1286
|
-
stripe_customer_id: data.stripeCustomerId,
|
|
1529
|
+
price: data.price,
|
|
1287
1530
|
success_url: data.successUrl,
|
|
1288
1531
|
cancel_url: data.cancelUrl,
|
|
1289
1532
|
mode: data.mode,
|
|
1290
|
-
line_items: (_data_lineItems = data.lineItems) == null ? void 0 : _data_lineItems.map((item)=>({
|
|
1291
|
-
price_id: item.priceId,
|
|
1292
|
-
quantity: item.quantity,
|
|
1293
|
-
price_data: item.priceData ? {
|
|
1294
|
-
currency: item.priceData.currency,
|
|
1295
|
-
unit_amount: item.priceData.unitAmount,
|
|
1296
|
-
product_data: item.priceData.productData,
|
|
1297
|
-
recurring: item.priceData.recurring
|
|
1298
|
-
} : undefined
|
|
1299
|
-
})),
|
|
1300
|
-
subscription_data: data.subscriptionData ? {
|
|
1301
|
-
trial_period_days: data.subscriptionData.trialPeriodDays,
|
|
1302
|
-
metadata: data.subscriptionData.metadata
|
|
1303
|
-
} : undefined,
|
|
1304
|
-
metadata: data.metadata,
|
|
1305
|
-
subscription_model_code: data.subscriptionModelCode,
|
|
1306
|
-
price_unique_id: data.priceUniqueId,
|
|
1307
|
-
price: data.price,
|
|
1308
1533
|
customer: data.customer,
|
|
1309
1534
|
quantity: data.quantity,
|
|
1310
1535
|
trial_period_days: data.trialPeriodDays,
|
|
1311
1536
|
subscription_type: data.subscriptionType,
|
|
1537
|
+
price_unique_id: data.priceUniqueId,
|
|
1312
1538
|
identity_type: data.identityType,
|
|
1313
1539
|
description: data.description,
|
|
1540
|
+
subscription_model_code: data.subscriptionModelCode,
|
|
1314
1541
|
allow_promotion_codes: data.allowPromotionCodes,
|
|
1315
1542
|
coupon_id: data.couponId
|
|
1316
1543
|
}
|
|
@@ -1324,12 +1551,11 @@ function createStripeService(transport, _config) {
|
|
|
1324
1551
|
async createPaymentIntent (data) {
|
|
1325
1552
|
const response = await transport.post('/stripe/payments', {
|
|
1326
1553
|
payment: {
|
|
1554
|
+
customer_id: data.customerId,
|
|
1327
1555
|
currency: data.currency,
|
|
1328
1556
|
order_unique_id: data.orderUniqueId,
|
|
1329
|
-
order_id: data.orderId,
|
|
1330
1557
|
identity_type: data.identityType,
|
|
1331
1558
|
entity_type: data.entityType,
|
|
1332
|
-
customer_id: data.customerId,
|
|
1333
1559
|
entity_id: data.entityId
|
|
1334
1560
|
}
|
|
1335
1561
|
});
|
|
@@ -1338,8 +1564,8 @@ function createStripeService(transport, _config) {
|
|
|
1338
1564
|
async createCustomerPortal (uniqueId, data) {
|
|
1339
1565
|
const response = await transport.post(`/stripe/customers/${uniqueId}/portal`, {
|
|
1340
1566
|
portal: {
|
|
1341
|
-
|
|
1342
|
-
|
|
1567
|
+
customer_id: data.customerId,
|
|
1568
|
+
return_url: data.returnUrl
|
|
1343
1569
|
}
|
|
1344
1570
|
});
|
|
1345
1571
|
return decodeOne(response, stripeCustomerPortalMapper);
|
|
@@ -1357,35 +1583,13 @@ function createStripeService(transport, _config) {
|
|
|
1357
1583
|
},
|
|
1358
1584
|
async createSubscription (data) {
|
|
1359
1585
|
const response = await transport.post('/stripe/subscriptions', {
|
|
1360
|
-
subscription:
|
|
1361
|
-
customer_unique_id: data.customerUniqueId,
|
|
1362
|
-
stripe_customer_id: data.stripeCustomerId,
|
|
1363
|
-
price_id: data.priceId,
|
|
1364
|
-
price_unique_id: data.priceUniqueId,
|
|
1365
|
-
quantity: data.quantity,
|
|
1366
|
-
trial_period_days: data.trialPeriodDays,
|
|
1367
|
-
customer_id: data.customerId,
|
|
1368
|
-
setup_price_id: data.setupPriceId,
|
|
1369
|
-
subscription_price_id: data.subscriptionPriceId,
|
|
1370
|
-
card_token: data.cardToken,
|
|
1371
|
-
subscription_type: data.subscriptionType,
|
|
1372
|
-
identity_type: data.identityType,
|
|
1373
|
-
company_unique_id: data.companyUniqueId,
|
|
1374
|
-
entity_unique_id: data.entityUniqueId,
|
|
1375
|
-
entity_type: data.entityType,
|
|
1376
|
-
metadata: data.metadata
|
|
1377
|
-
}
|
|
1586
|
+
subscription: buildSubscriptionBody(data)
|
|
1378
1587
|
});
|
|
1379
1588
|
return decodeOne(response, stripeSubscriptionMapper);
|
|
1380
1589
|
},
|
|
1381
1590
|
async updateSubscription (stripeSubscriptionId, data) {
|
|
1382
1591
|
const response = await transport.put(`/stripe/subscriptions/${stripeSubscriptionId}`, {
|
|
1383
|
-
subscription:
|
|
1384
|
-
price_id: data.priceId,
|
|
1385
|
-
quantity: data.quantity,
|
|
1386
|
-
cancel_at_period_end: data.cancelAtPeriodEnd,
|
|
1387
|
-
metadata: data.metadata
|
|
1388
|
-
}
|
|
1592
|
+
subscription: buildSubscriptionBody(data)
|
|
1389
1593
|
});
|
|
1390
1594
|
return decodeOne(response, stripeSubscriptionMapper);
|
|
1391
1595
|
},
|
|
@@ -1425,7 +1629,7 @@ const mercadoPagoPaymentMethodMapper = {
|
|
|
1425
1629
|
processingModes: parseStringArray(resource.attributes['processing_modes'])
|
|
1426
1630
|
})
|
|
1427
1631
|
};
|
|
1428
|
-
const
|
|
1632
|
+
const mercadoPagoPaymentMapper = {
|
|
1429
1633
|
type: 'MercadoPagoPaymentIntent',
|
|
1430
1634
|
map: (resource)=>{
|
|
1431
1635
|
var _parseDate;
|
|
@@ -1448,121 +1652,156 @@ const mercadoPagoPaymentIntentMapper = {
|
|
|
1448
1652
|
}
|
|
1449
1653
|
};
|
|
1450
1654
|
|
|
1655
|
+
function buildMercadoPagoBody(data) {
|
|
1656
|
+
const body = {};
|
|
1657
|
+
if (data.amount !== undefined) body['amount'] = data.amount;
|
|
1658
|
+
if (data.cardToken) body['card_token'] = data.cardToken;
|
|
1659
|
+
if (data.description) body['description'] = data.description;
|
|
1660
|
+
if (data.installments !== undefined) body['installments'] = data.installments;
|
|
1661
|
+
if (data.paymentMethodId) body['paymentMethodId'] = data.paymentMethodId;
|
|
1662
|
+
if (data.email) body['email'] = data.email;
|
|
1663
|
+
if (data.documentType) body['document_type'] = data.documentType;
|
|
1664
|
+
if (data.documentNumber) body['document_number'] = data.documentNumber;
|
|
1665
|
+
if (data.orderUniqueId) body['order_unique_id'] = data.orderUniqueId;
|
|
1666
|
+
if (data.displayUniqueId) body['display_unique_id'] = data.displayUniqueId;
|
|
1667
|
+
if (data.financialInstitution) body['financial_institution'] = data.financialInstitution;
|
|
1668
|
+
if (data.callbackUrl) body['callback_url'] = data.callbackUrl;
|
|
1669
|
+
return body;
|
|
1670
|
+
}
|
|
1451
1671
|
function createMercadoPagoService(transport, _config) {
|
|
1452
1672
|
return {
|
|
1453
1673
|
async listPaymentMethods () {
|
|
1454
1674
|
const response = await transport.get('/mercadopago');
|
|
1455
1675
|
return decodeMany(response, mercadoPagoPaymentMethodMapper);
|
|
1456
1676
|
},
|
|
1457
|
-
async
|
|
1458
|
-
var _data_additionalInfo_items;
|
|
1677
|
+
async createPayment (data) {
|
|
1459
1678
|
const response = await transport.post('/mercadopago/payments', {
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
},
|
|
1466
|
-
installments: data.installments,
|
|
1467
|
-
token: data.token,
|
|
1468
|
-
issuer_id: data.issuerId,
|
|
1469
|
-
external_reference: data.externalReference,
|
|
1470
|
-
statement_descriptor: data.statementDescriptor,
|
|
1471
|
-
notification_url: data.notificationUrl,
|
|
1472
|
-
additional_info: data.additionalInfo ? {
|
|
1473
|
-
items: (_data_additionalInfo_items = data.additionalInfo.items) == null ? void 0 : _data_additionalInfo_items.map((item)=>({
|
|
1474
|
-
id: item.id,
|
|
1475
|
-
title: item.title,
|
|
1476
|
-
description: item.description,
|
|
1477
|
-
picture_url: item.pictureUrl,
|
|
1478
|
-
category_id: item.categoryId,
|
|
1479
|
-
quantity: item.quantity,
|
|
1480
|
-
unit_price: item.unitPrice
|
|
1481
|
-
})),
|
|
1482
|
-
payer: data.additionalInfo.payer ? {
|
|
1483
|
-
first_name: data.additionalInfo.payer.firstName,
|
|
1484
|
-
last_name: data.additionalInfo.payer.lastName,
|
|
1485
|
-
email: data.additionalInfo.payer.email,
|
|
1486
|
-
phone: data.additionalInfo.payer.phone,
|
|
1487
|
-
identification: data.additionalInfo.payer.identification,
|
|
1488
|
-
address: data.additionalInfo.payer.address ? {
|
|
1489
|
-
zip_code: data.additionalInfo.payer.address.zipCode,
|
|
1490
|
-
street_name: data.additionalInfo.payer.address.streetName,
|
|
1491
|
-
street_number: data.additionalInfo.payer.address.streetNumber
|
|
1492
|
-
} : undefined
|
|
1493
|
-
} : undefined
|
|
1494
|
-
} : undefined,
|
|
1495
|
-
metadata: data.metadata
|
|
1496
|
-
});
|
|
1497
|
-
return decodeOne(response, mercadoPagoPaymentIntentMapper);
|
|
1498
|
-
},
|
|
1499
|
-
async createPSEIntent (data) {
|
|
1679
|
+
payment: buildMercadoPagoBody(data)
|
|
1680
|
+
});
|
|
1681
|
+
return decodeOne(response, mercadoPagoPaymentMapper);
|
|
1682
|
+
},
|
|
1683
|
+
async createPSEPayment (data) {
|
|
1500
1684
|
const response = await transport.post('/mercadopago/payments/pse', {
|
|
1501
|
-
|
|
1502
|
-
description: data.description,
|
|
1503
|
-
payer: {
|
|
1504
|
-
email: data.payerEmail,
|
|
1505
|
-
identification: {
|
|
1506
|
-
type: data.payerDocumentType,
|
|
1507
|
-
number: data.payerDocumentNumber
|
|
1508
|
-
}
|
|
1509
|
-
},
|
|
1510
|
-
transaction_details: {
|
|
1511
|
-
financial_institution: data.financialInstitution
|
|
1512
|
-
},
|
|
1513
|
-
callback_url: data.callbackUrl,
|
|
1514
|
-
external_reference: data.externalReference,
|
|
1515
|
-
metadata: data.metadata
|
|
1685
|
+
payment: buildMercadoPagoBody(data)
|
|
1516
1686
|
});
|
|
1517
|
-
return decodeOne(response,
|
|
1687
|
+
return decodeOne(response, mercadoPagoPaymentMapper);
|
|
1518
1688
|
}
|
|
1519
1689
|
};
|
|
1520
1690
|
}
|
|
1521
1691
|
|
|
1522
1692
|
const vendorPaymentMapper = {
|
|
1523
1693
|
type: 'VendorPayment',
|
|
1524
|
-
map: (resource)=>{
|
|
1525
|
-
var _parseDate, _parseDate1;
|
|
1526
|
-
return {
|
|
1694
|
+
map: (resource)=>({
|
|
1527
1695
|
id: resource.id,
|
|
1528
|
-
uniqueId: resource.attributes['unique_id'],
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1696
|
+
uniqueId: parseString(resource.attributes['unique_id']) || '',
|
|
1697
|
+
vendorUniqueId: parseString(resource.attributes['vendor_unique_id']),
|
|
1698
|
+
vendorName: parseString(resource.attributes['vendor_name']),
|
|
1699
|
+
vendorEmail: parseString(resource.attributes['vendor_email']),
|
|
1700
|
+
vendorPhone: parseString(resource.attributes['vendor_phone']),
|
|
1701
|
+
vendorContact: parseString(resource.attributes['vendor_contact']),
|
|
1702
|
+
paymentType: parseString(resource.attributes['payment_type']),
|
|
1703
|
+
price: parseNumber(resource.attributes['price']) || undefined,
|
|
1704
|
+
discount: parseNumber(resource.attributes['discount']) || undefined,
|
|
1705
|
+
discountValue: parseNumber(resource.attributes['discount_value']) || undefined,
|
|
1706
|
+
fees: parseNumber(resource.attributes['fees']) || undefined,
|
|
1707
|
+
feesValue: parseNumber(resource.attributes['fees_value']) || undefined,
|
|
1708
|
+
tips: parseNumber(resource.attributes['tips']) || undefined,
|
|
1709
|
+
tipsValue: parseNumber(resource.attributes['tips_value']) || undefined,
|
|
1710
|
+
subtotal: parseNumber(resource.attributes['subtotal']) || undefined,
|
|
1711
|
+
delivery: parseNumber(resource.attributes['delivery']) || undefined,
|
|
1712
|
+
tax: parseNumber(resource.attributes['tax']) || undefined,
|
|
1713
|
+
taxValue: parseNumber(resource.attributes['tax_value']) || undefined,
|
|
1714
|
+
status: parseString(resource.attributes['status']),
|
|
1535
1715
|
paidAt: parseDate(resource.attributes['paid_at']),
|
|
1536
|
-
reference: resource.attributes['reference'],
|
|
1537
|
-
notes: resource.attributes['notes'],
|
|
1538
1716
|
payload: resource.attributes['payload'],
|
|
1539
|
-
createdAt:
|
|
1540
|
-
updatedAt:
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1717
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
1718
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
|
|
1719
|
+
})
|
|
1543
1720
|
};
|
|
1544
1721
|
|
|
1545
1722
|
const orderDetailVendorMapper = {
|
|
1546
1723
|
type: 'OrderDetailVendor',
|
|
1547
|
-
map: (resource)=>{
|
|
1548
|
-
var _parseDate, _parseDate1;
|
|
1549
|
-
return {
|
|
1724
|
+
map: (resource)=>({
|
|
1550
1725
|
id: resource.id,
|
|
1551
|
-
uniqueId: resource.attributes['unique_id'],
|
|
1552
|
-
orderDetailUniqueId: resource.attributes['order_detail_unique_id'],
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
status: resource.attributes['status'],
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1726
|
+
uniqueId: parseString(resource.attributes['unique_id']) || '',
|
|
1727
|
+
orderDetailUniqueId: parseString(resource.attributes['order_detail_unique_id']),
|
|
1728
|
+
vendorUniqueId: parseString(resource.attributes['vendor_unique_id']),
|
|
1729
|
+
vendorName: parseString(resource.attributes['vendor_name']),
|
|
1730
|
+
vendorEmail: parseString(resource.attributes['vendor_email']),
|
|
1731
|
+
vendorPhone: parseString(resource.attributes['vendor_phone']),
|
|
1732
|
+
vendorContact: parseString(resource.attributes['vendor_contact']),
|
|
1733
|
+
status: parseString(resource.attributes['status']),
|
|
1734
|
+
referredBy: parseString(resource.attributes['referred_by']),
|
|
1735
|
+
promoCode: parseString(resource.attributes['promo_code']),
|
|
1736
|
+
createdAt: parseDate(resource.attributes['created_at']) || new Date(),
|
|
1737
|
+
updatedAt: parseDate(resource.attributes['updated_at']) || new Date()
|
|
1738
|
+
})
|
|
1564
1739
|
};
|
|
1565
1740
|
|
|
1741
|
+
function buildVendorPaymentBody(data) {
|
|
1742
|
+
const body = {};
|
|
1743
|
+
if (data.vendorUniqueId) body['vendor_unique_id'] = data.vendorUniqueId;
|
|
1744
|
+
if (data.vendorName) body['vendor_name'] = data.vendorName;
|
|
1745
|
+
if (data.vendorEmail) body['vendor_email'] = data.vendorEmail;
|
|
1746
|
+
if (data.vendorPhone) body['vendor_phone'] = data.vendorPhone;
|
|
1747
|
+
if (data.vendorContact) body['vendor_contact'] = data.vendorContact;
|
|
1748
|
+
if (data.paymentType) body['payment_type'] = data.paymentType;
|
|
1749
|
+
if (data.price !== undefined) body['price'] = data.price;
|
|
1750
|
+
if (data.discount !== undefined) body['discount'] = data.discount;
|
|
1751
|
+
if (data.discountValue !== undefined) body['discount_value'] = data.discountValue;
|
|
1752
|
+
if (data.fees !== undefined) body['fees'] = data.fees;
|
|
1753
|
+
if (data.feesValue !== undefined) body['fees_value'] = data.feesValue;
|
|
1754
|
+
if (data.tips !== undefined) body['tips'] = data.tips;
|
|
1755
|
+
if (data.tipsValue !== undefined) body['tips_value'] = data.tipsValue;
|
|
1756
|
+
if (data.subtotal !== undefined) body['subtotal'] = data.subtotal;
|
|
1757
|
+
if (data.delivery !== undefined) body['delivery'] = data.delivery;
|
|
1758
|
+
if (data.tax !== undefined) body['tax'] = data.tax;
|
|
1759
|
+
if (data.taxValue !== undefined) body['tax_value'] = data.taxValue;
|
|
1760
|
+
if (data.payload) body['payload'] = data.payload;
|
|
1761
|
+
return body;
|
|
1762
|
+
}
|
|
1763
|
+
function buildPayBody(data) {
|
|
1764
|
+
const body = {};
|
|
1765
|
+
if (data.paymentType) body['payment_type'] = data.paymentType;
|
|
1766
|
+
if (data.gatewayUniqueId) body['gateway_unique_id'] = data.gatewayUniqueId;
|
|
1767
|
+
if (data.gatewayName) body['gateway_name'] = data.gatewayName;
|
|
1768
|
+
if (data.gatewayReference) body['gateway_reference'] = data.gatewayReference;
|
|
1769
|
+
if (data.gatewayOrderId) body['gateway_order_id'] = data.gatewayOrderId;
|
|
1770
|
+
if (data.gatewayFranchise) body['gateway_franchise'] = data.gatewayFranchise;
|
|
1771
|
+
if (data.gatewayPaymentType) body['gateway_payment_type'] = data.gatewayPaymentType;
|
|
1772
|
+
if (data.gatewayTransactionId) body['gateway_transaction_id'] = data.gatewayTransactionId;
|
|
1773
|
+
if (data.gatewayDescription) body['gateway_description'] = data.gatewayDescription;
|
|
1774
|
+
if (data.gatewayFees !== undefined) body['gateway_fees'] = data.gatewayFees;
|
|
1775
|
+
if (data.gatewayFeesValue !== undefined) body['gateway_fees_value'] = data.gatewayFeesValue;
|
|
1776
|
+
if (data.gatewayTips !== undefined) body['gateway_tips'] = data.gatewayTips;
|
|
1777
|
+
if (data.gatewayTipsValue !== undefined) body['gateway_tips_value'] = data.gatewayTipsValue;
|
|
1778
|
+
if (data.gatewaySubtotal !== undefined) body['gateway_subtotal'] = data.gatewaySubtotal;
|
|
1779
|
+
if (data.gatewayDiscount !== undefined) body['gateway_discount'] = data.gatewayDiscount;
|
|
1780
|
+
if (data.gatewayDiscountValue !== undefined) body['gateway_discount_value'] = data.gatewayDiscountValue;
|
|
1781
|
+
if (data.gatewayDelivery !== undefined) body['gateway_delivery'] = data.gatewayDelivery;
|
|
1782
|
+
if (data.gatewayTax !== undefined) body['gateway_tax'] = data.gatewayTax;
|
|
1783
|
+
if (data.gatewayTaxValue !== undefined) body['gateway_tax_value'] = data.gatewayTaxValue;
|
|
1784
|
+
if (data.gatewayTotal !== undefined) body['gateway_total'] = data.gatewayTotal;
|
|
1785
|
+
if (data.gatewayBalance !== undefined) body['gateway_balance'] = data.gatewayBalance;
|
|
1786
|
+
if (data.gatewayPaidAt) body['gateway_paid_at'] = data.gatewayPaidAt;
|
|
1787
|
+
if (data.gatewayStatus) body['gateway_status'] = data.gatewayStatus;
|
|
1788
|
+
if (data.gatewayResponse) body['gateway_response'] = data.gatewayResponse;
|
|
1789
|
+
if (data.gatewayPayload) body['gateway_payload'] = data.gatewayPayload;
|
|
1790
|
+
if (data.paidAt) body['paid_at'] = data.paidAt;
|
|
1791
|
+
return body;
|
|
1792
|
+
}
|
|
1793
|
+
function buildProviderBody(data) {
|
|
1794
|
+
const body = {};
|
|
1795
|
+
if (data.vendorUniqueId) body['vendor_unique_id'] = data.vendorUniqueId;
|
|
1796
|
+
if (data.vendorName) body['vendor_name'] = data.vendorName;
|
|
1797
|
+
if (data.vendorEmail) body['vendor_email'] = data.vendorEmail;
|
|
1798
|
+
if (data.vendorPhone) body['vendor_phone'] = data.vendorPhone;
|
|
1799
|
+
if (data.vendorContact) body['vendor_contact'] = data.vendorContact;
|
|
1800
|
+
if (data.status) body['status'] = data.status;
|
|
1801
|
+
if (data.referredBy) body['referred_by'] = data.referredBy;
|
|
1802
|
+
if (data.promoCode) body['promo_code'] = data.promoCode;
|
|
1803
|
+
return body;
|
|
1804
|
+
}
|
|
1566
1805
|
function createVendorPaymentsService(transport, _config) {
|
|
1567
1806
|
return {
|
|
1568
1807
|
async get (paymentUniqueId) {
|
|
@@ -1571,30 +1810,20 @@ function createVendorPaymentsService(transport, _config) {
|
|
|
1571
1810
|
},
|
|
1572
1811
|
async create (orderUniqueId, detailUniqueId, vendorUniqueId, data) {
|
|
1573
1812
|
const response = await transport.post(`/orders/${orderUniqueId}/details/${detailUniqueId}/vendors/${vendorUniqueId}/payments`, {
|
|
1574
|
-
payment:
|
|
1575
|
-
amount: data.amount,
|
|
1576
|
-
currency: data.currency,
|
|
1577
|
-
reference: data.reference,
|
|
1578
|
-
notes: data.notes,
|
|
1579
|
-
payload: data.payload
|
|
1580
|
-
}
|
|
1813
|
+
payment: buildVendorPaymentBody(data)
|
|
1581
1814
|
});
|
|
1582
1815
|
return decodeOne(response, vendorPaymentMapper);
|
|
1583
1816
|
},
|
|
1584
1817
|
async update (orderUniqueId, detailUniqueId, vendorUniqueId, paymentUniqueId, data) {
|
|
1585
1818
|
const response = await transport.put(`/orders/${orderUniqueId}/details/${detailUniqueId}/vendors/${vendorUniqueId}/payments/${paymentUniqueId}`, {
|
|
1586
|
-
payment:
|
|
1587
|
-
amount: data.amount,
|
|
1588
|
-
reference: data.reference,
|
|
1589
|
-
notes: data.notes,
|
|
1590
|
-
status: data.status,
|
|
1591
|
-
payload: data.payload
|
|
1592
|
-
}
|
|
1819
|
+
payment: buildVendorPaymentBody(data)
|
|
1593
1820
|
});
|
|
1594
1821
|
return decodeOne(response, vendorPaymentMapper);
|
|
1595
1822
|
},
|
|
1596
|
-
async pay (orderUniqueId, detailUniqueId, vendorUniqueId, paymentUniqueId) {
|
|
1597
|
-
const response = await transport.put(`/orders/${orderUniqueId}/details/${detailUniqueId}/vendors/${vendorUniqueId}/payments/${paymentUniqueId}/pay`, {
|
|
1823
|
+
async pay (orderUniqueId, detailUniqueId, vendorUniqueId, paymentUniqueId, data) {
|
|
1824
|
+
const response = await transport.put(`/orders/${orderUniqueId}/details/${detailUniqueId}/vendors/${vendorUniqueId}/payments/${paymentUniqueId}/pay`, {
|
|
1825
|
+
payment: data ? buildPayBody(data) : {}
|
|
1826
|
+
});
|
|
1598
1827
|
return decodeOne(response, vendorPaymentMapper);
|
|
1599
1828
|
},
|
|
1600
1829
|
async delete (orderUniqueId, detailUniqueId, vendorUniqueId, paymentUniqueId) {
|
|
@@ -1602,36 +1831,13 @@ function createVendorPaymentsService(transport, _config) {
|
|
|
1602
1831
|
},
|
|
1603
1832
|
async createProvider (orderUniqueId, orderDetailUniqueId, data) {
|
|
1604
1833
|
const response = await transport.post(`/orders/${orderUniqueId}/details/${orderDetailUniqueId}/providers`, {
|
|
1605
|
-
provider:
|
|
1606
|
-
vendor_unique_id: data.vendorUniqueId,
|
|
1607
|
-
amount: data.amount,
|
|
1608
|
-
commission: data.commission,
|
|
1609
|
-
payload: data.payload
|
|
1610
|
-
}
|
|
1611
|
-
});
|
|
1612
|
-
return decodeOne(response, orderDetailVendorMapper);
|
|
1613
|
-
},
|
|
1614
|
-
async createProviderBySource (sourceId, data) {
|
|
1615
|
-
const response = await transport.post(`/sources/${sourceId}/providers`, {
|
|
1616
|
-
provider: {
|
|
1617
|
-
vendor_unique_id: data.vendorUniqueId,
|
|
1618
|
-
order_unique_id: data.orderUniqueId,
|
|
1619
|
-
order_detail_unique_id: data.orderDetailUniqueId,
|
|
1620
|
-
amount: data.amount,
|
|
1621
|
-
commission: data.commission,
|
|
1622
|
-
payload: data.payload
|
|
1623
|
-
}
|
|
1834
|
+
provider: buildProviderBody(data)
|
|
1624
1835
|
});
|
|
1625
1836
|
return decodeOne(response, orderDetailVendorMapper);
|
|
1626
1837
|
},
|
|
1627
1838
|
async updateProvider (orderUniqueId, orderDetailUniqueId, providerUniqueId, data) {
|
|
1628
1839
|
const response = await transport.put(`/orders/${orderUniqueId}/details/${orderDetailUniqueId}/providers/${providerUniqueId}`, {
|
|
1629
|
-
provider:
|
|
1630
|
-
amount: data.amount,
|
|
1631
|
-
commission: data.commission,
|
|
1632
|
-
status: data.status,
|
|
1633
|
-
payload: data.payload
|
|
1634
|
-
}
|
|
1840
|
+
provider: buildProviderBody(data)
|
|
1635
1841
|
});
|
|
1636
1842
|
return decodeOne(response, orderDetailVendorMapper);
|
|
1637
1843
|
},
|
|
@@ -1828,4 +2034,4 @@ const salesBlockMetadata = {
|
|
|
1828
2034
|
]
|
|
1829
2035
|
};
|
|
1830
2036
|
|
|
1831
|
-
export { createFlexibleOrdersService, createMercadoPagoService, createOrderDetailsService, createOrderTaxesService, createOrdersService, createPaymentsService, createPurchasesService, createSalesBlock, createSalesCustomersService, createSalesEntitiesService, createSalesUsersService, createStripeService, createSubscriptionModelsService, createSubscriptionsService, createVendorPaymentsService, customerSubscriptionMapper, entitySubscriptionMapper, flexibleOrderMapper,
|
|
2037
|
+
export { createFlexibleOrdersService, createMercadoPagoService, createOrderDetailsService, createOrderTaxesService, createOrdersService, createPaymentsService, createPurchasesService, createSalesBlock, createSalesCustomersService, createSalesEntitiesService, createSalesUsersService, createStripeService, createSubscriptionModelsService, createSubscriptionsService, createVendorPaymentsService, customerSubscriptionMapper, entitySubscriptionMapper, flexibleOrderMapper, mercadoPagoPaymentMapper, mercadoPagoPaymentMethodMapper, orderDetailMapper, orderDetailVendorMapper, orderMapper, orderTaxMapper, parseBoolean, parseDate, parseNumber, parseOptionalNumber, parseOrderStatus, parsePaymentStatus, parseStatus, parseString, parseStringArray, parseSubscriptionInterval, parseSubscriptionStatus, paymentMapper, purchaseMapper, salesBlockMetadata, salesCustomerMapper, salesEntityMapper, salesUserMapper, stripeCheckoutSessionMapper, stripeCustomerPortalMapper, stripeCustomerResponseMapper, stripePaymentIntentMapper, stripeSubscriptionMapper, stripeWebhookMapper, subscriptionItemMapper, subscriptionMapper, subscriptionModelMapper, userSubscriptionMapper, vendorPaymentMapper };
|