Created
May 15, 2019 02:33
-
-
Save dafabulousteach/126b8e18deb999d624d8dc0f2cf8b1f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.post('/reship', async (req: Request, res: Response) => { | |
const order_line_items = req.body; | |
let model; | |
let arr = []; | |
arr.push(order_line_items); | |
arr.map((item:any) => { | |
model = new Order( | |
item.billing_address, | |
item.buyer_accepts_marketing, | |
item.currency, | |
item.customer, | |
item.email, | |
item.fulfillments, | |
item.fulfillment_status, | |
item.line_items, | |
item.note, | |
item.order_id, | |
item.original_order_number, | |
item.payment_gateway_name, | |
item.phone, | |
item.presentment_currency, | |
item.processing_method, | |
item.refunds, | |
item.reship, | |
item.shipping_address, | |
item.shipping_lines, | |
item.subtotal_price, | |
item.subtotal_price_set, | |
item.taxes_included, | |
item.total_line_items_price, | |
item.total_line_items_price_set, | |
item.total_price, | |
item.total_price_set, | |
item.total_shipping_price_set, | |
item.total_weight, | |
) | |
}); | |
let reship_object = { | |
'order': model | |
} | |
axios({ | |
url: `https://${username}:${password}@${domain}/admin/api/2019-04/orders.json`, | |
method: 'post', | |
data: reship_object | |
}).then((data: any) => { | |
return axios({ | |
url: 'http://localhost:3000/add-note/' + data.data.order.id, | |
method: 'put', | |
data: data.data.order.note | |
}).then((data: any) => { | |
console.log('successfully added note to order: ', data.data); | |
return res.send({ | |
msg: data.data | |
}); | |
}) | |
.catch((err: any) => { | |
console.error('error in adding note to reshipment: ', err); | |
res.send(err); | |
}) | |
}).catch((err:any) => { | |
console.error('error in creating reshipment: ', err); | |
res.send(err); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment