const request = require('request');

const options = {
  method: 'POST',
  url: 'https://api.betterez.com/sales/cart',
  headers: {
    authorization: 'Bearer {{jwtToken}}',
    'Content-Type': 'application/json;charset=UTF-8',
    Accept: 'application/json, text/plain, */*',
    'x-api-key': '{{x-api-key}}'
  },
  body: {
    operationId: '{{client-generated-GUID}}',
    providerId: '{{providerId}}',
    channel: '{{valid-channel}}',
    items: {
      reservation: [
        {
          productId: '{{productId}}',
          change: '{{ticketNumber}}',
          from: {_id: '{{step1-originId}}'},
          to: {_id: '{{step1-destinationId}}'},
          promo: '',
          roundTrip: false,
          passengers: [
            {
              fareId: '{{step1-fareId}}',
              ssrs: [],
              firstName: 'first-name',
              lastName: 'last-name',
              change: '{{ticket-to-change-id}}'
            }
          ],
          selectedTrips: {departureTripId: '{{step2-departure-tripId_string}}'},
          dateFrom: '{{step1-newDate}}'
        }
      ]
    },
    language: 'en'
  },
  json: true
};

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

	console.log(body);
});