Skip to content

Commit 235e36b

Browse files
committed
transfer booking java
1 parent d3848f8 commit 235e36b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// How to install the library at https://github.com/amadeus4dev/amadeus-java
2+
import com.amadeus.Amadeus;
3+
import com.amadeus.Params;
4+
import com.amadeus.exceptions.ResponseException;
5+
import com.amadeus.resources.TransferOrder;
6+
7+
public class TransferOrders {
8+
9+
public static void main(String[] args) throws ResponseException {
10+
11+
Amadeus amadeus = Amadeus
12+
.builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
13+
.build();
14+
Params params = Params.with("offerId", "5976726751");
15+
16+
String body = "{\n \"data\": {\n \"note\": \"Note to driver\",\n \"passengers\": [\n {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"title\": \"MR\",\n \"contacts\": {\n \"phoneNumber\": \"+33123456789\",\n \"email\": \"user@email.com\"\n },\n \"billingAddress\": {\n \"line\": \"Avenue de la Bourdonnais, 19\",\n \"zip\": \"75007\",\n \"countryCode\": \"FR\",\n \"cityName\": \"Paris\"\n }\n }\n ],\n \"agency\": {\n \"contacts\": [\n {\n \"email\": {\n \"address\": \"abc@test.com\"\n }\n }\n ]\n },\n \"payment\": {\n \"methodOfPayment\": \"CREDIT_CARD\",\n \"creditCard\": {\n \"number\": \"4111111111111111\",\n \"holderName\": \"JOHN DOE\",\n \"vendorCode\": \"VI\",\n \"expiryDate\": \"0928\",\n \"cvv\": \"111\"\n }\n },\n \"extraServices\": [\n {\n \"code\": \"EWT\",\n \"itemId\": \"EWT0291\"\n }\n ],\n \"equipment\": [\n {\n \"code\": \"BBS\"\n }\n ],\n \"corporation\": {\n \"address\": {\n \"line\": \"5 Avenue Anatole France\",\n \"zip\": \"75007\",\n \"countryCode\": \"FR\",\n \"cityName\": \"Paris\"\n },\n \"info\": {\n \"AU\": \"FHOWMD024\",\n \"CE\": \"280421GH\"\n }\n },\n \"startConnectedSegment\": {\n \"transportationType\": \"FLIGHT\",\n \"transportationNumber\": \"AF380\",\n \"departure\": {\n \"uicCode\": \"7400001\",\n \"iataCode\": \"CDG\",\n \"localDateTime\": \"2023-03-27T20:03:00\"\n },\n \"arrival\": {\n \"uicCode\": \"7400001\",\n \"iataCode\": \"CDG\",\n \"localDateTime\": \"2023-03-27T20:03:00\"\n }\n },\n \"endConnectedSegment\": {\n \"transportationType\": \"FLIGHT\",\n \"transportationNumber\": \"AF380\",\n \"departure\": {\n \"uicCode\": \"7400001\",\n \"iataCode\": \"CDG\",\n \"localDateTime\": \"2023-03-27T20:03:00\"\n },\n \"arrival\": {\n \"uicCode\": \"7400001\",\n \"iataCode\": \"CDG\",\n \"localDateTime\": \"2023-03-27T20:03:00\"\n }\n }\n }\n}";
17+
18+
TransferOrder transfers = amadeus.ordering.tranferOrders.post(body, params);
19+
if (transfers.getResponse().getStatusCode() != 200) {
20+
System.out.println("Wrong status code: " + transfers.getResponse().getStatusCode());
21+
System.exit(-1);
22+
}
23+
24+
System.out.println(transfers);
25+
}
26+
}

0 commit comments

Comments
 (0)