amadeus4dev-examples / amadeus-php

PHP library for the Amadeus Self-Service APIs
https://amadeus4dev-examples.github.io/amadeus-php/
MIT License
11 stars 13 forks source link

Exception in Resource::toResourceObject() #91

Open alslimany opened 2 years ago

alslimany commented 2 years ago

While trying to read allowance weight for traveler, the infants has no weight information. But when calling getIncludedCheckedBags() method it's throw an exception.

TypeError Amadeus\Resources\Resource::toResourceObject(): Argument #1 ($object) must be of type object, null given, called in /Users/abdullahishtiwy/Sites/booking-core/vendor/amadeus4dev/amadeus-php/src/resources/FlightFareDetailsBySegment.php on line 98.

and there is no way to check if it has a data or not.

https://github.com/amadeus4dev/amadeus-php/blob/f7249b5659976ee838dee0222497e547937fba93/src/resources/FlightFareDetailsBySegment.php#L94

xianqiliu commented 2 years ago

@alslimany >

heyyy! Thank you for creating an issue! I would like to help you, but firstly would you like to provide the request information like the URL or the post body for this API? And if you want to check if it has a data or not, you can try to call this API by using POSTMAN or use the SDK to call it in a direct way as follows:

// Make a GET request only using path
$amadeus->getClient()->getWithOnlyPath("/v1/airport/direct-destinations?departureAirportCode=MAD");

// Make a GET request using path and passed parameters
$amadeus->getClient()->getWithArrayParams("/v1/airport/direct-destinations", ["departureAirportCode" => "MAD"]);

// Make a POST request using path and passed body
$amadeus->getClient()->postWithStringBody("/v1/shopping/availability/flight-availabilities", $body);