@ns8/ns8-shopify-switches
Advanced tools
Comparing version 1.0.17 to 1.0.18
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ns8_protect_models_1 = require("ns8-protect-models"); | ||
const Shopify = require("shopify-api-node"); | ||
const mapCustomer = (customer) => { | ||
const { id, first_name = '', last_name = '', email = 'apps@ns8.com', phone, orders_count, total_spent, } = customer; | ||
return ({ | ||
return new ns8_protect_models_1.Customer({ | ||
email, | ||
@@ -16,5 +17,5 @@ phone, | ||
}; | ||
const mapAddress = (address) => { | ||
const mapAddress = (address, type) => { | ||
const { name, company, address1, address2, city, zip, province, province_code, country, country_code, } = address; | ||
return ({ | ||
return new ns8_protect_models_1.Address({ | ||
name, | ||
@@ -27,2 +28,3 @@ company, | ||
country, | ||
type: ns8_protect_models_1.AddressType[type], | ||
region: province, | ||
@@ -35,4 +37,4 @@ regionCode: province_code, | ||
return (lineItems.map((lineItem) => { | ||
const { id = '', title, name, quantity, price, sku, variant_id, variant_title, vendor, product_id, gift_card, total_discount, } = lineItem; | ||
return ({ | ||
const { title, name, quantity, price, sku, variant_id, variant_title, vendor, product_id, gift_card, total_discount, } = lineItem; | ||
return new ns8_protect_models_1.LineItem({ | ||
title, | ||
@@ -43,3 +45,2 @@ name, | ||
vendor, | ||
platformId: id.toString(), | ||
price: parseFloat(price), | ||
@@ -49,3 +50,3 @@ variantId: variant_id.toString(), | ||
platformProductId: product_id.toString(), | ||
giftCard: gift_card, | ||
isGiftCard: gift_card, | ||
totalDiscount: parseFloat(total_discount), | ||
@@ -56,13 +57,13 @@ }); | ||
const hasGiftCard = (lineItems) => (lineItems.some((item) => item.gift_card)); | ||
const mapPayments = (transactionList) => { | ||
const mapTransactions = (transactionList) => { | ||
return transactionList.map((transaction) => { | ||
const { id, amount, currency, kind, gateway, payment_details: { avs_result_code, credit_card_bin, credit_card_company, credit_card_number, cvv_result_code, }, } = transaction; | ||
return { | ||
return new ns8_protect_models_1.Transaction({ | ||
currency, | ||
platformPaymentId: id.toString(), | ||
method: 'CC', | ||
platformTransactionId: id.toString(), | ||
method: ns8_protect_models_1.TransactionMethod.CC, | ||
amount: parseFloat(amount), | ||
creditCard: { | ||
creditCard: new ns8_protect_models_1.CreditCard({ | ||
gateway, | ||
transactionType: kind.toUpperCase(), | ||
transactionType: ns8_protect_models_1.CreditCardTransactionType[kind.toUpperCase()], | ||
creditCardNumber: credit_card_number, | ||
@@ -73,4 +74,4 @@ creditCardCompany: credit_card_company, | ||
creditCardBin: credit_card_bin, | ||
}, | ||
}; | ||
}), | ||
}); | ||
}); | ||
@@ -91,16 +92,18 @@ }; | ||
const { app_id, id, name, currency, billing_address, shipping_address, customer, total_price, line_items = [], order_status_url, } = shopifyOrder; | ||
return { | ||
return new ns8_protect_models_1.Order({ | ||
name, | ||
currency, | ||
platformOrderId: id.toString(), | ||
shopId: app_id, | ||
billingAddress: mapAddress(billing_address), | ||
shippingAddress: mapAddress(shipping_address), | ||
shopId: app_id.toString(), | ||
addresses: [ | ||
mapAddress(billing_address, 'BILLING'), | ||
mapAddress(shipping_address, 'SHIPPING'), | ||
], | ||
customer: mapCustomer(customer), | ||
status: order_status_url, | ||
totalPrice: parseFloat(total_price), | ||
payments: mapPayments(shopifyTransactionList), | ||
transactions: mapTransactions(shopifyTransactionList), | ||
lineItems: mapLineItems(line_items), | ||
hasGiftCard: hasGiftCard(line_items), | ||
}; | ||
}); | ||
} | ||
@@ -107,0 +110,0 @@ } |
{ | ||
"name": "@ns8/ns8-shopify-switches", | ||
"version": "1.0.17", | ||
"version": "1.0.18", | ||
"description": "Custom switches for the shopify integration", | ||
@@ -23,6 +23,6 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"ns8-api-interfaces": "^2.0.83", | ||
"ns8-switchboard-interfaces": "^1.0.4", | ||
"ns8-protect-models": "^1.0.20", | ||
"ns8-switchboard-interfaces": "^1.0.6", | ||
"shopify-api-node": "^2.16.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
13110
165
+ Addedns8-protect-models@^1.0.20
+ Addedns8-protect-models@1.0.305(transitive)
- Removedns8-api-interfaces@^2.0.83
- Removed@types/uuid@7.0.8(transitive)
- Removedns8-api-interfaces@2.0.84(transitive)
- Removedns8-protect-models@1.0.305-cd.8749736e0401b04f012a2fda54d8e7f00b5ca9aa.0(transitive)
- Removeduuid@7.0.3(transitive)