Skip to content

Instantly share code, notes, and snippets.

@dafabulousteach
Created May 15, 2019 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dafabulousteach/126b8e18deb999d624d8dc0f2cf8b1f6 to your computer and use it in GitHub Desktop.
Save dafabulousteach/126b8e18deb999d624d8dc0f2cf8b1f6 to your computer and use it in GitHub Desktop.
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