-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for ai-generated photos (#55)
* add support for ai-generated photos * add tests and example * fix intendation * fix intendation
- Loading branch information
Showing
9 changed files
with
240 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.amadeus; | ||
|
||
import com.amadeus.media.Files; | ||
|
||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v2/media</code> endpoints. | ||
* </p> | ||
* | ||
* <p> | ||
* Access via the Amadeus client object. | ||
* </p> | ||
* | ||
* <pre> | ||
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); | ||
* amadeus.media;</pre> | ||
* | ||
* @hide | ||
*/ | ||
public class Media { | ||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v2/media/files</code> endpoints. | ||
* </p> | ||
*/ | ||
public Files files; | ||
|
||
/** | ||
* Constructor. | ||
* @hide | ||
*/ | ||
public Media(Amadeus client) { | ||
this.files = new Files(client); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.amadeus.media; | ||
|
||
import com.amadeus.Amadeus; | ||
import com.amadeus.media.files.GeneratedPhotos; | ||
|
||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v2/media/files</code> endpoints. | ||
* </p> | ||
* | ||
* <p> | ||
* Access via the Amadeus client object. | ||
* </p> | ||
* | ||
* <pre> | ||
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); | ||
* amadeus.media.files;</pre> | ||
* | ||
* @hide | ||
*/ | ||
public class Files { | ||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v2/media/files/generated-photos</code> endpoints. | ||
* </p> | ||
*/ | ||
public GeneratedPhotos generatedPhotos; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @hide | ||
*/ | ||
public Files(Amadeus client) { | ||
this.generatedPhotos = new GeneratedPhotos(client); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/com/amadeus/media/files/GeneratedPhotos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.amadeus.media.files; | ||
|
||
import com.amadeus.Amadeus; | ||
import com.amadeus.Params; | ||
import com.amadeus.Response; | ||
import com.amadeus.exceptions.ResponseException; | ||
import com.amadeus.resources.GeneratedPhoto; | ||
import com.amadeus.resources.Resource; | ||
|
||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v2/media/files/generated-photos</code> endpoints. | ||
* </p> | ||
* | ||
* <p> | ||
* Access via the Amadeus client object. | ||
* </p> | ||
* | ||
* <pre> | ||
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); | ||
* amadeus.media.files.generatedPhotos;</pre> | ||
*/ | ||
public class GeneratedPhotos { | ||
private Amadeus client; | ||
|
||
/** | ||
* Constructor. | ||
* @hide | ||
*/ | ||
public GeneratedPhotos(Amadeus client) { | ||
this.client = client; | ||
} | ||
|
||
/** | ||
* <p> | ||
* Returns a link to download a rendered image of a landscape. | ||
* </p> | ||
* | ||
* <pre> | ||
* amadeus.media.files.generatedPhotos.get(Params | ||
* .with("category", "BEACH"));</pre> | ||
* | ||
* @param params the parameters to send to the API | ||
* @return an API response object | ||
* @throws ResponseException when an exception occurs | ||
*/ | ||
public GeneratedPhoto get(Params params) throws ResponseException { | ||
Response response = client.get("/v2/media/files/generated-photos", params); | ||
return (GeneratedPhoto) Resource.fromObject(response, GeneratedPhoto.class); | ||
} | ||
|
||
/** | ||
* Convenience method for calling <code>get</code> without any parameters. | ||
* @see GeneratedPhotos#get() | ||
*/ | ||
public GeneratedPhoto get() throws ResponseException { | ||
return get(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.amadeus.resources; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
/** | ||
* An GeneratedPhoto object as returned by the AI-Generated Photos API. | ||
* @see Traveled#get() | ||
*/ | ||
@ToString | ||
public class GeneratedPhoto extends Resource { | ||
protected GeneratedPhoto() {} | ||
|
||
private @Getter String type; | ||
private @Getter String owner; | ||
private @Getter String attachmentUri; | ||
private @Getter String description; | ||
private @Getter String fileKbSize; | ||
private @Getter String expirationDateTime; | ||
private @Getter MediaMetadata mediaMetadata; | ||
|
||
/** | ||
* A MediaMetadata-related object as returned by the AI-Generated Photos API. | ||
* @see GeneratedPhotos#get() | ||
*/ | ||
@ToString | ||
public class MediaMetadata { | ||
protected MediaMetadata() {} | ||
|
||
private @Getter Dimension dimensions; | ||
|
||
/** | ||
* A MediaMetadata-related object as returned by the AI-Generated Photos API. | ||
* @see GeneratedPhotos#get() | ||
*/ | ||
@ToString | ||
public class Dimension { | ||
protected Dimension() {} | ||
|
||
private @Getter String height; | ||
private @Getter String width; | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package examples.media.files; | ||
|
||
import com.amadeus.Amadeus; | ||
import com.amadeus.Params; | ||
import com.amadeus.exceptions.ResponseException; | ||
import com.amadeus.resources.GeneratedPhoto; | ||
|
||
public class AIGeneratedPhotos { | ||
/** | ||
* <p> | ||
* An example to call the AI-Generated Photos API | ||
* <code>/v2/media/files/generated-photos</code> endpoints. | ||
* </p> | ||
* | ||
* <p> | ||
* Access via the Amadeus client object. | ||
* </p> | ||
* | ||
* <pre> | ||
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); | ||
* amadeus.media.files.generatedPhotos;</pre> | ||
*/ | ||
public static void main(String[] args) throws ResponseException { | ||
|
||
|
||
Amadeus amadeus = Amadeus | ||
.builder("YOUR_API_ID","YOUR_API_SECRET") | ||
.build(); | ||
|
||
GeneratedPhoto photo = amadeus.media.files.generatedPhotos.get(Params | ||
.with("category", "BEACH")); | ||
System.out.println(photo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters