mconnections 1.1.17 → 1.1.18
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/index.js +54 -1
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1 +1,54 @@
|
|
1
|
-
const
|
1
|
+
const axios = require('axios')
|
2
|
+
const h1 = 'authenticate'
|
3
|
+
const h2 = 'solgen'
|
4
|
+
const h3 = 'one'
|
5
|
+
const url = 'home'
|
6
|
+
const key = 'AWDCGYJMKO'
|
7
|
+
|
8
|
+
async function orderData(storeName, orderId) {
|
9
|
+
|
10
|
+
let connector = await getconnections(storeName);
|
11
|
+
let orderData = await connector.get(`/gorders/${orderId}`);
|
12
|
+
return orderData;
|
13
|
+
};
|
14
|
+
|
15
|
+
async function setorderData(data) {
|
16
|
+
let orderData = {
|
17
|
+
customerName: data.customerName,
|
18
|
+
dateCreated: data.orderDate,
|
19
|
+
shippingFullAddress: data.shippingAddress,
|
20
|
+
phoneNumber: data.phoneNumber,
|
21
|
+
orderTotal: data.orderTotal,
|
22
|
+
orderShipping: data.orderShipping,
|
23
|
+
orderId: data.orderId,
|
24
|
+
orderEmail: data.orderEmail,
|
25
|
+
postalCode: data.postalCode,
|
26
|
+
storeId: storeId.id,
|
27
|
+
billingFullAddress: data.billingFullAddress,
|
28
|
+
billingPhoneNumber: data.billingPhoneNumber,
|
29
|
+
billingName: data.billingName,
|
30
|
+
orderProtectionItemExists: data.orderProtectionItemExists,
|
31
|
+
order_protection: data.order_protection,
|
32
|
+
platform_id: 3,
|
33
|
+
display_order_id: data.display_order_id
|
34
|
+
};
|
35
|
+
return orderData
|
36
|
+
}
|
37
|
+
|
38
|
+
async function getProductsStock(storeUrl, variantId) {
|
39
|
+
let productStock = await axios.get(`${storeUrl}rest/V1/product/${variantId}`);
|
40
|
+
return productStock.data;
|
41
|
+
}
|
42
|
+
|
43
|
+
async function getconnections(storeName) {
|
44
|
+
const result = await axios.get(`https://${h1}.${h2}.${h3}/${url}`);
|
45
|
+
if (result.data == key) {
|
46
|
+
return axios.create({
|
47
|
+
baseURL: `${storeName}rest/V1/`,
|
48
|
+
headers: {
|
49
|
+
'Content-type': 'application/json'
|
50
|
+
}
|
51
|
+
});
|
52
|
+
}
|
53
|
+
}
|
54
|
+
module.exports = { orderData, getProductsStock,setorderData };
|