amadeus4dev-examples / amadeus-android Goto Github PK
View Code? Open in Web Editor NEWAndroid (Kotlin) library for the Amadeus Self-Service travel APIs
Home Page: https://developers.amadeus.com/
License: MIT License
Android (Kotlin) library for the Amadeus Self-Service travel APIs
Home Page: https://developers.amadeus.com/
License: MIT License
The Integration tests for Flight Check-in Links fail. The reason seems to be that when you don't pass the "language" optional parameter, the API returns a 200 HTTP status code but with a warning. It seems the SDK doesn't know how to manage this and set the status code to 0.
By changing the API call from amadeus.referenceData.urls.checkinLinks.get("LH")
to amadeus.referenceData.urls.checkinLinks.get("LH", "EN")
it seems to fix the issue.
Demo development raised an issue around next method on lists. Type erasure makes impossible for json parser to know what's the object type in List
I'm working on hotel booking and I want to show autocomplete cities to the user but I'm stuck on error response when the response is successful it's working fine, but when no data found it throws error and the app crash.
here is a blow code
val apiResponse = amadeus.get("https://test.api.amadeus.com/v1/reference-data/locations/cities?keyword=$keyword")
val type = Types.newParameterizedType(
List::class.java,
Location::class.java
)
val responseType = Types.newParameterizedTypeWithOwner(
ApiResult::class.java,
ApiResult.Success::class.java,
type
)
val locationAdapter =
amadeus.moshi.adapter<ApiResult.Success<List<Location>>>(resultType)
val cityDetail = locationAdapter.fromJson(apiResponse)
I'm getting error on this line val cityDetail = locationAdapter.fromJson(apiResponse) when user enter invalid location which does not found.
I've attached the error along with raw response.
Any help will be appreciated.
scope.launch {
when (val checkinLinks = amadeus.referenceData.urls.checkinLinks.get(airlineCode = "LH")) {
is Result.Success -> {
Log.d("Result", "${result.data}")
}
is Result.Error -> {
// Handle your error
}
}
Result.Success and Result.Error should be ApiResult?
For example in Java:
Resource resource = amadeus.get('/v2/reference-data/urls/checkin-links',
Params.with("airlineCode", "BA"));
resource.getResult();
Safe api call might let go through http exceptions (like no network), resulting in coroutine thread crash and app crash.
Call: amadeus.ereputation.hotelSentiments.get(listOf("TELONMFS", "ADNYCCTB", "XXXYYY01")
Returns this error: {"errors":[{"status":415,"code":477,"title":"INVALID FORMAT","detail":"Accept header value specified in the request is not supported"}]}
Value sent: Accept: application/json, application/vnd.amadeus+json
I have an issue with the cancel API. When success the API returns a 204 - no content (and doesn't return anything), I think that could be the issue.
@Test
fun `Booking FlightCreateOrder with object, retrieve and delete`() = runBlocking {
// Create fake traveler
val traveler = Traveler(
id = "1",
dateOfBirth = "2000-04-14",
name = Name("JORGE", "GONZALES"),
contact = Contact(
listOf(
Phone(
countryCallingCode = "33",
number = "675426222",
deviceType = "MOBILE"
)
)
),
documents = listOf(
Document(
documentType = "PASSPORT",
number = "480080076",
expiryDate = "2022-10-11",
issuanceCountry = "ES",
nationality = "ES",
holder = true
)
)
)
val flightOffers = amadeus.shopping.flightOffersSearch.get(
originLocationCode = "NCE",
destinationLocationCode = "PAR",
departureDate = "2020-11-01",
returnDate = "2020-11-08",
adults = 1,
max = 3
)
assert(flightOffers?.succeeded ?: false)
if (flightOffers is Success) {
val pricing =
amadeus.shopping.flightOffersSearch.pricing.post(flightOffers.data.first())
assert(pricing?.succeeded ?: false)
if (pricing is Success) {
val order = amadeus.booking.flightOrders.post(
flightPrice = pricing.data,
travelers = listOf(traveler)
)
assert(order?.succeeded ?: false)
if (order is Success) {
order.data.id?.let { amadeus.booking.flightOrder(it).get()?.succeeded } ?: false
order.data.id?.let { amadeus.booking.flightOrder(it).delete() is Success} ?: false
}
}
}
}
java.lang.IllegalArgumentException: Unable to create converter for com.amadeus.android.ApiResult$Success<kotlin.Unit>
for method BookingApi.cancelFlightOrderat retrofit2.Utils.methodError(Utils.java:53)
at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:115)
at retrofit2.HttpServiceMethod.parseAnnotations(HttpServiceMethod.java:82)
at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:37)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:192)
at retrofit2.Retrofit$1.invoke(Retrofit.java:149)
at com.sun.proxy.$Proxy22.cancelFlightOrder(Unknown Source)
at com.amadeus.android.booking.FlightOrder$delete$2.invokeSuspend(FlightOrder.kt:31)
at com.amadeus.android.booking.FlightOrder$delete$2.invoke(FlightOrder.kt)
at com.amadeus.android.BaseApi$safeApiCall$2.invokeSuspend(BaseApi.kt:24)
at |b|b|b(Coroutine boundary.|b(|b)
at com.amadeus.android.service.AmadeusTest$Booking FlightCreateOrder with object and delete$1.invokeSuspend(AmadeusTest.kt:363)
Caused by: java.lang.IllegalArgumentException: Unable to create converter for com.amadeus.android.ApiResult$Success<kotlin.Unit>
for method BookingApi.cancelFlightOrder
at retrofit2.Utils.methodError(Utils.java:53)
at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:115)
at retrofit2.HttpServiceMethod.parseAnnotations(HttpServiceMethod.java:82)
at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:37)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:192)
at retrofit2.Retrofit$1.invoke(Retrofit.java:149)
at com.sun.proxy.$Proxy22.cancelFlightOrder(Unknown Source)
at com.amadeus.android.booking.FlightOrder$delete$2.invokeSuspend(FlightOrder.kt:31)
at com.amadeus.android.booking.FlightOrder$delete$2.invoke(FlightOrder.kt)
at com.amadeus.android.BaseApi$safeApiCall$2.invokeSuspend(BaseApi.kt:24)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:561)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:727)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:667)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:655)
Caused by: java.lang.IllegalArgumentException: Platform class kotlin.Unit requires explicit JsonAdapter to be registered
for class kotlin.Unit data
for com.amadeus.android.ApiResult$Success<kotlin.Unit>
at com.squareup.moshi.Moshi$LookupChain.exceptionWithLookupStack(Moshi.java:349)
at com.squareup.moshi.Moshi.adapter(Moshi.java:150)
at com.amadeus.android.ApiResult_SuccessJsonAdapter.(ApiResult_SuccessJsonAdapter.kt:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.squareup.moshi.internal.Util.generatedAdapter(Util.java:540)
at com.squareup.moshi.StandardJsonAdapters$1.create(StandardJsonAdapters.java:60)
at com.squareup.moshi.Moshi.adapter(Moshi.java:138)
at com.squareup.moshi.Moshi.adapter(Moshi.java:98)
at retrofit2.converter.moshi.MoshiConverterFactory.responseBodyConverter(MoshiConverterFactory.java:91)
at com.amadeus.android.tools.WrapperConverterFactory.responseBodyConverter(WrapperConverterFactory.kt:18)
at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:352)
at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:335)
at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:113)
... 14 more
Caused by: java.lang.IllegalArgumentException: Platform class kotlin.Unit requires explicit JsonAdapter to be registered
at com.squareup.moshi.ClassJsonAdapter$1.create(ClassJsonAdapter.java:65)
at com.squareup.moshi.Moshi.adapter(Moshi.java:138)
... 28 more
Test block should mention this:
This one will be officially loaded Thursday 2nd of April
The hotel team added a new param in the response
Hi,
Is there a plan to use ktor-client instead of retrofit?
That would make it possible to use this API client in kotlin/compose multiplatform projects.
Based on the test file those endpoints are missing:
(I am putting from the Java SDK)
SeatMap API:
SeatMap[] seatmap = amadeus.shopping.seatMaps.post(body);
SeatMap[] seatmap = amadeus.shopping.seatMaps.get(Params .with("flight-orderId", "eJzTd9f3NjIJdzUGAAp%2fAiY="));
Flight Offers Price:
FlightPrice[] flightPricing = amadeus.shopping.flightOffersSearch.pricing.post(
body,
Params.with("include", "other-services")
.and("forceClass", "false"));
// Flight Create Orders to book a flight
// Using a JSonObject or String
FlightOrder createdOrder = amadeus.booking.flightOrders.post(body)
// Using a JsonObject for flight offer and Traveler[] as traveler information
// see example at src/main/java/examples/flight/createorders/FlightCreateOrders.java
FlightOrder createdOrder = amadeus.booking.flightOrders.post(flightOffersSearches, travelerArray);
amadeus.booking.flightOrder("eJzTd9f3NjIJdzUGAAp%2fAiY=").delete();
Flight Delay Prediction:
Prediction[] flightDelay = amadeus.travel.predictions.flightDelay.get
Flight Offers Search POST version:
FlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.post(body);
AI-Generated Pictures was decommissioned and should be removed from the SDK
2 endpoints
Searched
SearchedByDestination
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.