amadeus4dev / amadeus-node

Node library for the Amadeus Self-Service travel APIs
https://developers.amadeus.com
MIT License
191 stars 66 forks source link

support json.stringify so that user doesn't need to convert to string maually for all POST method #202

Closed minjikarin closed 4 weeks ago

minjikarin commented 11 months ago

currently, users need to manually convert the body to string with JSON.stringify when they call POST method. for example:

amadeus.shopping.flightOffersSearch.get({
    originLocationCode: 'SYD',
    destinationLocationCode: 'BKK',
    departureDate: '2022-11-01',
    adults: '1'
}).then(function(response){
    return amadeus.shopping.flightOffers.pricing.post(
      JSON.stringify({
        'data': {
          'type': 'flight-offers-pricing',
          'flightOffers': [response.data[0]]
        }
      })
    )
}).then(function(response){
    console.log(response.data);
}).catch(function(responseError){
    console.log(responseError);
});

it would be great if SDK support automatically. so that user can use as this:

amadeus.shopping.flightOffersSearch.get({
    originLocationCode: 'SYD',
    destinationLocationCode: 'BKK',
    departureDate: '2022-11-01',
    adults: '1'
}).then(function(response){
    return amadeus.shopping.flightOffers.pricing.post(
      {
        'data': {
          'type': 'flight-offers-pricing',
          'flightOffers': [response.data[0]]
        }
      }
    )
}).then(function(response){
    console.log(response.data);
}).catch(function(responseError){
    console.log(responseError);
});