Skip to content

Commit 9e6cf0e

Browse files
authored
Add support for ai-generated photos (#55)
* add support for ai-generated photos * add tests and example * fix intendation * fix intendation
1 parent 8ed52c6 commit 9e6cf0e

File tree

9 files changed

+240
-1
lines changed

9 files changed

+240
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ SeatMap[] seatmap = amadeus.shopping.seatMaps.get(Params
350350
// What is the the seat map of a given flight?
351351
// The body can be a String version of your JSON or a JsonObject
352352
SeatMap[] seatmap = amadeus.shopping.seatMaps.post(body);
353+
354+
// AI-Generated Photos
355+
GeneratedPhoto photo = amadeus.media.files.generatedPhotos.get(Params
356+
.with("category", "BEACH"));
353357
```
354358

355359
## Development & Contributing

src/main/java/com/amadeus/Amadeus.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ public class Amadeus extends HTTPClient {
6969
*/
7070
public Booking booking;
7171

72+
/**
73+
* <p>
74+
* A namespaced client for the <code>/v2/media</code> endpoints.
75+
* </p>
76+
*/
77+
public Media media;
78+
7279
protected Amadeus(Configuration configuration) {
7380
super(configuration);
7481
this.referenceData = new ReferenceData(this);
@@ -77,6 +84,8 @@ protected Amadeus(Configuration configuration) {
7784
this.ereputation = new EReputation(this);
7885
this.airport = new Airport(this);
7986
this.booking = new Booking(this);
87+
this.media = new Media(this);
88+
8089
}
8190

8291
/**
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.amadeus;
2+
3+
import com.amadeus.media.Files;
4+
5+
/**
6+
* <p>
7+
* A namespaced client for the
8+
* <code>/v2/media</code> endpoints.
9+
* </p>
10+
*
11+
* <p>
12+
* Access via the Amadeus client object.
13+
* </p>
14+
*
15+
* <pre>
16+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
17+
* amadeus.media;</pre>
18+
*
19+
* @hide
20+
*/
21+
public class Media {
22+
/**
23+
* <p>
24+
* A namespaced client for the
25+
* <code>/v2/media/files</code> endpoints.
26+
* </p>
27+
*/
28+
public Files files;
29+
30+
/**
31+
* Constructor.
32+
* @hide
33+
*/
34+
public Media(Amadeus client) {
35+
this.files = new Files(client);
36+
}
37+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.amadeus.media;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.media.files.GeneratedPhotos;
5+
6+
/**
7+
* <p>
8+
* A namespaced client for the
9+
* <code>/v2/media/files</code> endpoints.
10+
* </p>
11+
*
12+
* <p>
13+
* Access via the Amadeus client object.
14+
* </p>
15+
*
16+
* <pre>
17+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
18+
* amadeus.media.files;</pre>
19+
*
20+
* @hide
21+
*/
22+
public class Files {
23+
/**
24+
* <p>
25+
* A namespaced client for the
26+
* <code>/v2/media/files/generated-photos</code> endpoints.
27+
* </p>
28+
*/
29+
public GeneratedPhotos generatedPhotos;
30+
31+
/**
32+
* Constructor.
33+
*
34+
* @hide
35+
*/
36+
public Files(Amadeus client) {
37+
this.generatedPhotos = new GeneratedPhotos(client);
38+
}
39+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.amadeus.media.files;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.Params;
5+
import com.amadeus.Response;
6+
import com.amadeus.exceptions.ResponseException;
7+
import com.amadeus.resources.GeneratedPhoto;
8+
import com.amadeus.resources.Resource;
9+
10+
/**
11+
* <p>
12+
* A namespaced client for the
13+
* <code>/v2/media/files/generated-photos</code> endpoints.
14+
* </p>
15+
*
16+
* <p>
17+
* Access via the Amadeus client object.
18+
* </p>
19+
*
20+
* <pre>
21+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
22+
* amadeus.media.files.generatedPhotos;</pre>
23+
*/
24+
public class GeneratedPhotos {
25+
private Amadeus client;
26+
27+
/**
28+
* Constructor.
29+
* @hide
30+
*/
31+
public GeneratedPhotos(Amadeus client) {
32+
this.client = client;
33+
}
34+
35+
/**
36+
* <p>
37+
* Returns a link to download a rendered image of a landscape.
38+
* </p>
39+
*
40+
* <pre>
41+
* amadeus.media.files.generatedPhotos.get(Params
42+
* .with("category", "BEACH"));</pre>
43+
*
44+
* @param params the parameters to send to the API
45+
* @return an API response object
46+
* @throws ResponseException when an exception occurs
47+
*/
48+
public GeneratedPhoto get(Params params) throws ResponseException {
49+
Response response = client.get("/v2/media/files/generated-photos", params);
50+
return (GeneratedPhoto) Resource.fromObject(response, GeneratedPhoto.class);
51+
}
52+
53+
/**
54+
* Convenience method for calling <code>get</code> without any parameters.
55+
* @see GeneratedPhotos#get()
56+
*/
57+
public GeneratedPhoto get() throws ResponseException {
58+
return get(null);
59+
}
60+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.amadeus.resources;
2+
3+
import lombok.Getter;
4+
import lombok.ToString;
5+
6+
/**
7+
* An GeneratedPhoto object as returned by the AI-Generated Photos API.
8+
* @see Traveled#get()
9+
*/
10+
@ToString
11+
public class GeneratedPhoto extends Resource {
12+
protected GeneratedPhoto() {}
13+
14+
private @Getter String type;
15+
private @Getter String owner;
16+
private @Getter String attachmentUri;
17+
private @Getter String description;
18+
private @Getter String fileKbSize;
19+
private @Getter String expirationDateTime;
20+
private @Getter MediaMetadata mediaMetadata;
21+
22+
/**
23+
* A MediaMetadata-related object as returned by the AI-Generated Photos API.
24+
* @see GeneratedPhotos#get()
25+
*/
26+
@ToString
27+
public class MediaMetadata {
28+
protected MediaMetadata() {}
29+
30+
private @Getter Dimension dimensions;
31+
32+
/**
33+
* A MediaMetadata-related object as returned by the AI-Generated Photos API.
34+
* @see GeneratedPhotos#get()
35+
*/
36+
@ToString
37+
public class Dimension {
38+
protected Dimension() {}
39+
40+
private @Getter String height;
41+
private @Getter String width;
42+
43+
}
44+
}
45+
}

src/main/java/com/amadeus/resources/PointOfInterest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import lombok.ToString;
55

66
/**
7-
* An PointOfInterest object as returned by the Locaion API.
7+
* An PointOfInterest object as returned by the Location API.
88
* @see com.amadeus.referenceData.locations.PointOfInterest#get()
99
*/
1010
@ToString
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package examples.media.files;
2+
3+
import com.amadeus.Amadeus;
4+
import com.amadeus.Params;
5+
import com.amadeus.exceptions.ResponseException;
6+
import com.amadeus.resources.GeneratedPhoto;
7+
8+
public class AIGeneratedPhotos {
9+
/**
10+
* <p>
11+
* An example to call the AI-Generated Photos API
12+
* <code>/v2/media/files/generated-photos</code> endpoints.
13+
* </p>
14+
*
15+
* <p>
16+
* Access via the Amadeus client object.
17+
* </p>
18+
*
19+
* <pre>
20+
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build();
21+
* amadeus.media.files.generatedPhotos;</pre>
22+
*/
23+
public static void main(String[] args) throws ResponseException {
24+
25+
26+
Amadeus amadeus = Amadeus
27+
.builder("YOUR_API_ID","YOUR_API_SECRET")
28+
.build();
29+
30+
GeneratedPhoto photo = amadeus.media.files.generatedPhotos.get(Params
31+
.with("category", "BEACH"));
32+
System.out.println(photo);
33+
}
34+
}

src/test/java/com/amadeus/NamespaceTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.amadeus.booking.FlightOrders;
66
import com.amadeus.ereputation.HotelSentiments;
77
import com.amadeus.exceptions.ResponseException;
8+
import com.amadeus.media.files.GeneratedPhotos;
89
import com.amadeus.referenceData.Airlines;
910
import com.amadeus.referenceData.Location;
1011
import com.amadeus.referenceData.Locations;
@@ -64,6 +65,7 @@ public void testAllNamespacesExist() {
6465
TestCase.assertNotNull(client.shopping.hotelOffer("XXX"));
6566
TestCase.assertNotNull(client.airport.predictions.onTime);
6667
TestCase.assertNotNull(client.booking.flightOrder("XXX"));
68+
TestCase.assertNotNull(client.media.files.generatedPhotos);
6769
}
6870

6971
@Before
@@ -298,6 +300,15 @@ public void testGetMethods() throws ResponseException {
298300
FlightOrder flightOrder = new FlightOrder(client, "XXX");
299301
TestCase.assertNotNull(flightOrder.get());
300302
TestCase.assertNotNull(flightOrder.get(params));
303+
304+
// Testing AI-generated photos
305+
Mockito.when(client.get("/v2/media/files/generated-photos", null))
306+
.thenReturn(singleResponse);
307+
Mockito.when(client.get("/v2/media/files/generated-photos", params))
308+
.thenReturn(singleResponse);
309+
GeneratedPhotos photo = new GeneratedPhotos(client);
310+
TestCase.assertNotNull(photo.get());
311+
TestCase.assertNotNull(photo.get(params));
301312
}
302313

303314
@Test

0 commit comments

Comments
 (0)