-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from amadeus4dev/tours-activities-support
Tours and activities support
- Loading branch information
Showing
7 changed files
with
325 additions
and
0 deletions.
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,46 @@ | ||
package com.amadeus.resources; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
/** | ||
* An Activity object as returned by the Tours and Activities API. | ||
* @see com.amadeus.shopping.Activity#get() | ||
*/ | ||
@ToString | ||
public class Activity extends Resource { | ||
protected Activity() {} | ||
|
||
private @Getter String type; | ||
private @Getter String id; | ||
private @Getter String name; | ||
private @Getter String shortDescription; | ||
private @Getter String description; | ||
private @Getter GeoCode geoCode; | ||
private @Getter String rating; | ||
private @Getter String bookingLink; | ||
private @Getter String minimumDuration; | ||
private @Getter ElementaryPrice price; | ||
private @Getter String[] pictures; | ||
|
||
|
||
/** | ||
* An Activity-related object as returned by the Tours and Activities API. | ||
* @see com.amadeus.shopping.Activity#get() | ||
*/ | ||
@ToString | ||
public class GeoCode { | ||
protected GeoCode() {} | ||
|
||
private @Getter double latitude; | ||
private @Getter double longitude; | ||
} | ||
|
||
@ToString | ||
public class ElementaryPrice { | ||
protected ElementaryPrice() {} | ||
|
||
private @Getter String amount; | ||
private @Getter String currencyCode; | ||
} | ||
} |
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,73 @@ | ||
package com.amadeus.shopping; | ||
|
||
import com.amadeus.Amadeus; | ||
import com.amadeus.Params; | ||
import com.amadeus.Response; | ||
import com.amadeus.exceptions.ResponseException; | ||
import com.amadeus.resources.Activity; | ||
import com.amadeus.resources.Resource; | ||
import com.amadeus.shopping.activities.BySquare; | ||
|
||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v1/shopping/activities</code> endpoints. | ||
* </p> | ||
* | ||
* <p> | ||
* Access via the Amadeus client object. | ||
* </p> | ||
* | ||
* <pre> | ||
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); | ||
* amadeus.shopping.activities;</pre> | ||
*/ | ||
public class Activities { | ||
private Amadeus client; | ||
|
||
|
||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v1/shopping/activities/by-square</code> endpoints. | ||
* </p> | ||
*/ | ||
public BySquare bySquare; | ||
|
||
/** | ||
* Constructor. | ||
* @hide | ||
*/ | ||
public Activities(Amadeus client) { | ||
this.client = client; | ||
this.bySquare = new BySquare(client); | ||
} | ||
|
||
|
||
/** | ||
* <p> | ||
* Returns a list of activities near to a given point. | ||
* </p> | ||
* | ||
* <pre> | ||
* amadeus.amadeus.shopping.activities.get(Params | ||
* .with("longitude", 2.160873) | ||
* .and("latitude", 41.397158));</pre> | ||
* | ||
* @param params the parameters to send to the API | ||
* @return an API response object | ||
* @throws ResponseException when an exception occurs | ||
*/ | ||
public Activity[] get(Params params) throws ResponseException { | ||
Response response = client.get("/v1/shopping/activities", params); | ||
return (Activity[]) Resource.fromArray(response, Activity[].class); | ||
} | ||
|
||
/** | ||
* Convenience method for calling <code>get</code> without any parameters. | ||
* @see Activities#get() | ||
*/ | ||
public Activity[] 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,63 @@ | ||
package com.amadeus.shopping; | ||
|
||
import com.amadeus.Amadeus; | ||
import com.amadeus.Params; | ||
import com.amadeus.Response; | ||
import com.amadeus.exceptions.ResponseException; | ||
import com.amadeus.resources.Resource; | ||
|
||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v1/shopping/activities</code> endpoints. | ||
* </p> | ||
* | ||
* <p> | ||
* Access via the Amadeus client object. | ||
* </p> | ||
* | ||
* <pre> | ||
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); | ||
* amadeus.shopping.activity;</pre> | ||
*/ | ||
public class Activity { | ||
private Amadeus client; | ||
private String id; | ||
|
||
|
||
/** | ||
* Constructor. | ||
* @hide | ||
*/ | ||
public Activity(Amadeus client, String id) { | ||
this.client = client; | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* <p> | ||
* Returns a single activity from a given id. | ||
* </p> | ||
* | ||
* <pre> | ||
* amadeus.shopping.activity.("4615").get();</pre> | ||
* | ||
* @param params the parameters to send to the API | ||
* @return an API response object | ||
* @throws ResponseException when an exception occurs | ||
*/ | ||
public com.amadeus.resources.Activity get(Params params) throws ResponseException { | ||
String path = String.format("/v1/shopping/activities/%s", id); | ||
Response response = client.get(path, params); | ||
return (com.amadeus.resources.Activity) Resource.fromObject( | ||
response, com.amadeus.resources.Activity.class); | ||
} | ||
|
||
/** | ||
* Convenience method for calling <code>get</code> without any parameters. | ||
* @see Activity#get() | ||
*/ | ||
public com.amadeus.resources.Activity get() throws ResponseException { | ||
return get(null); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/amadeus/shopping/activities/BySquare.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,64 @@ | ||
package com.amadeus.shopping.activities; | ||
|
||
import com.amadeus.Amadeus; | ||
import com.amadeus.Params; | ||
import com.amadeus.Response; | ||
import com.amadeus.exceptions.ResponseException; | ||
import com.amadeus.resources.Activity; | ||
import com.amadeus.resources.Resource; | ||
|
||
/** | ||
* <p> | ||
* A namespaced client for the | ||
* <code>/v1/shopping/activities/by-square</code> endpoints. | ||
* </p> | ||
* | ||
* <p> | ||
* Access via the Amadeus client object. | ||
* </p> | ||
* | ||
* <pre> | ||
* Amadeus amadeus = Amadeus.builder("clientId", "secret").build(); | ||
* amadeus.shopping.activities.bySquare;</pre> | ||
*/ | ||
public class BySquare { | ||
private Amadeus client; | ||
|
||
/** | ||
* Constructor. | ||
* @hide | ||
*/ | ||
public BySquare(Amadeus client) { | ||
this.client = client; | ||
} | ||
|
||
/** | ||
* <p> | ||
* Returns a list of activities within a square defined by | ||
* cardinal points. | ||
* </p> | ||
* | ||
* <pre> | ||
* amadeus.shopping.activities.bySquare.get(Params | ||
* .with("north", 41.397158) | ||
* .and("west", 2.160873) | ||
* .and("south", 41.394582) | ||
* .and("east", 2.177181));</pre> | ||
* | ||
* @param params the parameters to send to the API | ||
* @return an API response object | ||
* @throws ResponseException when an exception occurs | ||
*/ | ||
public Activity[] get(Params params) throws ResponseException { | ||
Response response = client.get("/v1/shopping/activities/by-square", params); | ||
return (Activity[]) Resource.fromArray(response, Activity[].class); | ||
} | ||
|
||
/** | ||
* Convenience method for calling <code>get</code> without any parameters. | ||
* @see Activities#get() | ||
*/ | ||
public Activity[] 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