amadeus4dev / amadeus-java Goto Github PK
View Code? Open in Web Editor NEWJava library for the Amadeus Self-Service travel APIs
Home Page: https://developers.amadeus.com/
License: MIT License
Java library for the Amadeus Self-Service travel APIs
Home Page: https://developers.amadeus.com/
License: MIT License
Tried to implemented support for Trip Parser #28. The string created for the POST can't be handled because it exceeds the 64kb limit and returns the error "constant string too long".
Switch to #59 and run the following code by replacing the base64string with the actual base64 from the swagger.
String body = "{\"data\":{\"type\":\"trip-parser-job\",\"content\":\"base64string\"}}"; TripParser tripParser = amadeus.travel.tripParserJobs.post(body);
Expected Behavior: Starts parsing job
Actual Behavior: constant string too long
[Describe the issue]
I have integrated the hotel search API successfully to my website but I keep getting 1 image per hotel, how can I get more images per hotel?
Expected Behavior: [What you expect to happen]
Actual Behavior: [What actually happens]
Stable Behavior? [What percentage of the time does it reproduce?]
[What version of Java/JVM are you running? What Operating System are you on?]
Please make sure you checked the following:
// Flight Create Orders to book a flight
// Using a JSonObject or String
FlightOrder createdOrder = amadeus.booking.flightOrders.pricing.post(body);
This is not the way to call create orders, I think it should be FlightOrder order = amadeus.booking.flightOrders.post(body)
Attempt to invoke virtual method 'java.lang.String com.google.gson.JsonElement.getAsString()' on a null object reference
The above error occurs when I call the Locations endpoint via this library. Below is the complete stacktrace:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.gson.JsonElement.getAsString()' on a null object reference
at com.amadeus.Response.detectError(Response.java:69)
at com.amadeus.HTTPClient.execute(HTTPClient.java:223)
at com.amadeus.HTTPClient.unauthenticatedRequest(HTTPClient.java:117)
at com.amadeus.HTTPClient.request(HTTPClient.java:202)
at com.amadeus.HTTPClient.get(HTTPClient.java:66)
at com.amadeus.referenceData.Locations.get(Locations.java:67)
Below, is how I am implementing the call:
**//Initialize using parameters
new Thread(new Runnable() {
@OverRide
public void run() {
Amadeus amadeus = Amadeus
.builder(Constants.AMADEUS_CLIENT_ID, Constants.AMADEUS_SECRET_KEY)
.build();
try{
Location[] locations = amadeus.referenceData.locations.get(Params
.with("keyword", "LON")
.and("subType", Locations.ANY));
// The raw response, as a string
locations[0].getResponse().getBody();
Log.e("amadeus::", locations[0].getResponse().getBody());
}catch (ResponseException ex){
Log.e("amadeus::", ex.getResponse().toString());
}
}
}).start();**
Spotted at:
Find a Flight
Get Flight Inspiration
com.amadeus.AmadeusTest > testBuilderWithInvalidEnvironment FAILED
java.lang.AssertionError
86 tests completed, 1 failed
FAILURE: Build failed with an exception.
safetyRatings is always null in the results (these lat,lng returns results in the sandbox):
Amadeus amadeus = Amadeus.builder("[hidden]", "[hidden]").build(); try { SafePlace[] safetyScore = amadeus.safety.safetyRatedLocations .get(Params.with("latitude", 51.50735).and("longitude", -0.12775)); System.out.println(); } catch (ResponseException e) { e.printStackTrace(); }
using
com.amadeus
amadeus-java
5.3.0
Issue posted on stackoverflow:
if a Gate is specified: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at path $[0].flightPoints[0].departure.gate
ongoing #50
Based on the API Reference of Flight Offers Price :
The Price values (including base, total and grandTotal) expecting String in JSON request while the SearchPrice class in the SDK defined these variables as double :
So calling the method by passing the FlightOfferSearch as parameter like this :
FlightPrice flightPrice = amadeus.shopping.flightOffersSearch.pricing.post(flightOfferSearch)
would cause generating the below request :
Request(verb=POST, scheme=https, host=test.api.amadeus.com, path=/v1/shopping/flight-offers/pricing, params=null, body={"data":{"type":"flight-offers-pricing","flightOffers":[{"type":"flight-offer","id":"3","source":"GDS","instantTicketingRequired":false,"nonHomogeneous":false,"oneWay":false,"lastTicketingDate":"2021-11-29","numberOfBookableSeats":4,"itineraries":[{"duration":"PT2H15M","segments":[{"departure":{"iataCode":"IKA","at":"2021-11-30T15:10:00"},"arrival":{"iataCode":"DXB","terminal":"3","at":"2021-11-30T17:55:00"},"carrierCode":"FZ","number":"1928","aircraft":{"code":"7M9"},"duration":"PT2H15M","id":"29","numberOfStops":0,"blacklistedInEU":false}]},{"duration":"PT2H20M","segments":[{"departure":{"iataCode":"DXB","terminal":"3","at":"2021-12-07T12:20:00"},"arrival":{"iataCode":"IKA","at":"2021-12-07T14:10:00"},"carrierCode":"FZ","number":"1927","aircraft":{"code":"7M9"},"duration":"PT2H20M","id":"100","numberOfStops":0,"blacklistedInEU":false}]}],"price":{"currency":"IRR","total":9.4406E7,"base":7.924E7,"fees":[{"amount":0.0,"type":"SUPPLIER"},{"amount":0.0,"type":"TICKETING"}],"grandTotal":9.4406E7},"pricingOptions":{"includedCheckedBagsOnly":true,"fareType":["PUBLISHED"],"refundableFare":false,"noRestrictionFare":false,"noPenaltyFare":false},"validatingAirlineCodes":["FZ"],"travelerPricings":[{"travelerId":"1","fareOption":"STANDARD","travelerType":"ADULT","price":{"currency":"IRR","total":9.4406E7,"base":7.924E7,"grandTotal":0.0},"fareDetailsBySegment":[{"segmentId":"29","cabin":"ECONOMY","fareBasis":"TRL7IR1","class":"T","includedCheckedBags":{"weight":30,"weightUnit":"KG"}},{"segmentId":"100","cabin":"ECONOMY","fareBasis":"TRL7IR1","class":"T","includedCheckedBags":{"weight":30,"weightUnit":"KG"}}]}]}]}}, bearerToken=Bearer xxxxxxxxxxxxxxxxxxxxxxxx, clientVersion=5.8.0, languageVersion=1.8.0_162, appId=null, appVersion=null, ssl=true, port=443, headers={Authorization=Bearer xxxxxxxxxxxxxxxxxxxxxxxxx, Accept=application/json, application/vnd.amadeus+json, User-Agent=amadeus-java/5.8.0 java/1.8.0_162, Content-Type=application/vnd.amadeus+json}, uri=https://test.api.amadeus.com:443/v1/shopping/flight-offers/pricing?, connection=null)
and the result would be like this :
{ "errors": [ { "code": 477, "title": "INVALID FORMAT", "detail": "This attribute should be a number", "source": { "pointer": "/data/flightOffers[0]/price/grandTotal" }, "status": 400 }, { "code": 477, "title": "INVALID FORMAT", "detail": "This attribute should be a number", "source": { "pointer": "/data/flightOffers[0]/price/total" }, "status": 400 }, { "code": 477, "title": "INVALID FORMAT", "detail": "This attribute should be a number", "source": { "pointer": "/data/flightOffers[0]/price/base" }, "status": 400 }, { "code": 477, "title": "INVALID FORMAT", "detail": "This attribute should be a number", "source": { "pointer": "/data/flightOffers[0]/travelerPricings[0]/price/total" }, "status": 400 }, { "code": 477, "title": "INVALID FORMAT", "detail": "This attribute should be a number", "source": { "pointer": "/data/flightOffers[0]/travelerPricings[0]/price/base" }, "status": 400 } ] }
It seems that GSON is serializing the double values without double quotes and this is causing INVALID FORMAT error from the server side.
Any suggestion ?
_Hamid
Update the ruby SDK to support the new APIs
If you call the Amadeus next-function without a response object which contains a meta-element (which is usually the case after you retrieved the last bunch of data) a Nullpointer is raised.
java.lang.NullPointerException: null
at com.amadeus.resources.Resource.fromArray(Resource.java:31) ~[amadeus-java-5.0.0.jar!/:5.0.0]
at com.amadeus.HTTPClient.page(HTTPClient.java:445) ~[amadeus-java-5.0.0.jar!/:5.0.0]
at com.amadeus.HTTPClient.next(HTTPClient.java:293) ~[amadeus-java-5.0.0.jar!/:5.0.0]
Seems to be that this line in HTTPClient is the problem. Because then in here HTTPClient the Nullpointer is raised.
Expected Behavior: No NullPointer. :-)
Would expect that the result of amadeus.next is null in this case. Or maybe better return a List instead of an array and use Collections.emptyList();
Actual Behavior: Nullpointer
Stable Behavior? No. 100% chance to hit it if you load the full data which is a common case.
OpenJDK / Docker Linux
Please make sure you checked the following:
The responses can contain "dictionaries" and/or "meta".
Those parts of the JSON don't have an object mapping in our Java SDK.
Implementation at #43
When I try to use the library in Android App. I have noticed that it always send POST request instead of GET request.
The reason is under com.amadeus/Request.java you have
protected void establishConnection() throws IOException {
this.connection = (HttpURLConnection) new URL(uri).openConnection();
connection.setRequestMethod(verb);
connection.setDoInput(true);
connection.setDoOutput(true);
So no matter setRequestMethod is, when setDoOutput=true, it always POST
According to https://developer.android.com/reference/java/net/HttpURLConnection
HTTP Methods
HttpURLConnection uses the GET method by default. It will use POST if setDoOutput(true) has been called. Other HTTP methods (OPTIONS, HEAD, PUT, DELETE and TRACE) can be used with setRequestMethod(String).
Suggestion fix:
connection.setDoOuput(true) only when the verb is POST
[ ] Flight Offer Price: detailed fare rules
[ ] Flight Create Order: CO2 emission
[ ] SeatMap
Strings can be handled more properly, Example
if (verb == "GET" && params != null) ## Request.java line 147
"GET" can be put in Constants file and re-used everywhere.
That will improve performance
Support for Trip Parser v3.
java.lang.NullPointerException: null
at com.amadeus.exceptions.ResponseException.getErrorsDescription(ResponseException.java:93)
at com.amadeus.exceptions.ResponseException.determineLongDescription(ResponseException.java:66)
at com.amadeus.exceptions.ResponseException.determineDescription(ResponseException.java:45)
at com.amadeus.exceptions.ResponseException.<init>(ResponseException.java:22)
at com.amadeus.exceptions.ClientException.<init>(ClientException.java:14)
at com.amadeus.Response.detectError(Response.java:77)
at com.amadeus.HTTPClient.execute(HTTPClient.java:361)
at com.amadeus.HTTPClient.unauthenticatedRequest(HTTPClient.java:253)
at com.amadeus.HTTPClient.request(HTTPClient.java:339)
at com.amadeus.HTTPClient.get(HTTPClient.java:67)
at com.amadeus.shopping.HotelOffers.get(HotelOffers.java:50)
ResponseException.java:93
message.append(String.format("%s", json.get("detail").getAsString()));
I assume the problem is that there's no detail
in the body?
Make a hotel offers request for the 12th of April 2021 in London, with a 150KM radius.
Or anything that results in an error without a detail
key?
Expected Behavior: An exception with some information on what the error is.
Actual Behavior: A NullPointerException.
Stable Behavior? I'm not sure what actual error response is causing this - it seems a bit random from my perspective. I don't always get an error, even with the same request. I suppose I could try and make requests manually to dig a bit further, but that defeats the point of using the SDK.
kotlin("jvm") version "1.3.72"
Please make sure you checked the following:
I am trying to integrate Amadeus SOAP enterprise web services using Java. How to call and make headers 4.0 and requests in Java?
Any prerequisite jar provided to create header and to call services?
Hello we need to update our pnrs with
"OSI EK DFNT"
so we can confirm the booking with emirate,
can you please tell us how to add the OSI please ?
Thanks for your help
Kind regards
Nicolas
[Describe the issue]
Expected Behavior: [What you expect to happen]
Actual Behavior: [What actually happens]
Stable Behavior? [What percentage of the time does it reproduce?]
[What version of Java/JVM are you running? What Operating System are you on?]
Please make sure you checked the following:
Not sure what's causing this but when I make an API call it gives me a network exception error. This only happens on my API 19 android device. Otherwise it works fine on my API 27 emulator + API 28 real device.
com.amadeus.exceptions.NetworkException: [---]
The Flight Orders Management API returns en empty body with status code 204 when an order is deleted successfully. The SDK doesn't handle this use case properly; it throws a ParserException as the API does not return a FlightOrder object, instead returns the empty response with code 204.
How to reproduce
import com.amadeus.Amadeus;
import com.amadeus.booking.FlightOrder;
import com.amadeus.exceptions.ResponseException;
public class FlightOrderManagement {
public static void main(String[] args) throws ResponseException {
Amadeus amadeus = Amadeus
.builder("client_key","client_secret")
.build();
com.amadeus.resources.FlightOrder order = amadeus.booking.flightOrder("eJzTd9cP8A8y8nIDAAtUAlk").delete();
if (order.getResponse().getStatusCode() != 204) {
System.out.println("Wrong status code: " + order.getResponse().getStatusCode());
System.exit(-1);
}
System.out.println("deleted");
}
}
Exception in thread "main" com.amadeus.exceptions.ParserException: [204]
at com.amadeus.Response.detectError(Response.java:79)
at com.amadeus.HTTPClient.execute(HTTPClient.java:361)
at com.amadeus.HTTPClient.unauthenticatedRequest(HTTPClient.java:253)
at com.amadeus.HTTPClient.request(HTTPClient.java:339)
at com.amadeus.HTTPClient.delete(HTTPClient.java:94)
at com.amadeus.booking.FlightOrder.delete(FlightOrder.java:85)
at com.amadeus.booking.FlightOrder.delete(FlightOrder.java:95)
at flightsearch.FlightSearch.main(FlightSearch.java:17)
The Travel/Most Searched API has been decommissioned but not removed from the SDK
Example here
We are managing the version at 2 different places:
1 in the Amadeus constant file
1 in the gradle file
It's painful when releasing a new version to update both (+ the unit test)
As of today, the build.gradle is managing the deployment. It will be better to split into 2 different files
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.