const request = require('request');

const options = {
  method: 'POST',
  url: 'https://api.betterez.com/sales/order',
  headers: {
    authorization: 'Bearer {{jwtToken}}',
    'Content-Type': 'application/json;charset=UTF-8',
    Accept: 'application/json, text/plain, */*',
    'x-api-key': '{{x-api-key}}'
  },
  body: {
    cartId: '{{cartId}}',
    payments: [],
    customerInfo: {
      acceptToc: true,
      firstName: '{{first-name}}',
      lastName: '{{last-name}}',
      email: '{{email}}',
      city: '{{city}}',
      country: '{{country}}',
      phone: '{{phone}}',
      phoneType: '{{phone-type}}',
      province: '{{province-code}}',
      street: '{{street}}',
      zip: '{{zip-post-code}}',
      enrolledInLoyaltyProgram: false
    },
    customFields: [],
    providerId: '{{providerId}}',
    channel: '{{a-proper-channel}}'
  },
  json: true
};

request(options, function (error, response, body) {
	if (error) throw new Error(error);

	console.log(body);
});