Skip to content

Commit 6a61e09

Browse files
committed
add transfer management java and curl
1 parent d94e26c commit 6a61e09

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.TransferCancellation;
6+
7+
public class TransferManagement {
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("confirmNbr", "12029761");
15+
16+
TransferCancellation transfers = amadeus.ordering
17+
.transferOrder("VEg0Wk43fERPRXwyMDIzLTA2LTE1VDE1OjUwOjE4").transfers.cancellation.post(params);
18+
if (transfers.getResponse().getStatusCode() != 200) {
19+
System.out.println("Wrong status code: " + transfers.getResponse().getStatusCode());
20+
System.exit(-1);
21+
}
22+
23+
System.out.println(transfers);
24+
}
25+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Authentication: $AMADEUS_CLIENT_ID & $AMADEUS_CLIENT_SECRET can be defined
2+
# in your environmental variables or directly in your script
3+
ACCESS_TOKEN=$(curl -H "Content-Type: application/x-www-form-urlencoded" \
4+
https://test.api.amadeus.com/v1/security/oauth2/token \
5+
-d "grant_type=client_credentials&client_id=$AMADEUS_CLIENT_ID&client_secret=$AMADEUS_CLIENT_SECRET" \
6+
| grep access_token | sed 's/"access_token": "\(.*\)"\,/\1/' | tr -d '[:space:]')
7+
8+
curl -X POST -H "Authorization: Bearer $ACCESS_TOKEN" \
9+
-H "Content-Type: application/json" \
10+
https://test.api.amadeus.com/v1/ordering/transfer-orders/VEg0Wk43fERPRXwyMDIzLTA2LTE1VDE1OjUwOjE4/transfers/cancellation?confirmNbr=12029761' \
11+
-d ''

0 commit comments

Comments
 (0)