-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
755 additions
and
82 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
118 changes: 118 additions & 0 deletions
118
examples/src/main/java/com/expediagroup/sdk/rapid/examples/RapidSdkGeographyDemoApp.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,118 @@ | ||
package com.expediagroup.sdk.rapid.examples; | ||
|
||
import com.expediagroup.sdk.rapid.examples.salesprofiles.DefaultRapidPartnerProfile; | ||
import com.expediagroup.sdk.rapid.examples.scenarios.geography.GetListOfRegionNamesScenario; | ||
import com.expediagroup.sdk.rapid.examples.scenarios.geography.GetRegionByAncestorIdScenario; | ||
import com.expediagroup.sdk.rapid.examples.scenarios.geography.GetRegionDetailsAndPropertyIdsScenario; | ||
import com.expediagroup.sdk.rapid.examples.scenarios.geography.ParseRegionAncestorsScenario; | ||
import com.expediagroup.sdk.rapid.examples.scenarios.geography.ParseRegionCategoriesScenario; | ||
import com.expediagroup.sdk.rapid.examples.scenarios.geography.ParseRegionCoordinatesScenario; | ||
import com.expediagroup.sdk.rapid.examples.scenarios.geography.ParseRegionDescendantsScenario; | ||
import com.expediagroup.sdk.rapid.examples.scenarios.geography.ParseRegionWithMultiPolygonCoordinatesScenario; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.concurrent.ExecutionException; | ||
|
||
|
||
public class RapidSdkGeographyDemoApp { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(RapidSdkGeographyDemoApp.class); | ||
|
||
public static void main(String[] args) throws ExecutionException, InterruptedException { | ||
|
||
logger.info("======================================================================================="); | ||
logger.info("======================================================================================="); | ||
logger.info("== =="); | ||
logger.info("== Howdy! This is a demonstration of Expedia Group RAPID SDK Geography, Enjoy! =="); | ||
logger.info("== =="); | ||
logger.info("======================================================================================="); | ||
logger.info("======================================================================================="); | ||
|
||
logger.info("=============================== Running Geography Scenarios ==========================="); | ||
|
||
/* Run Get List of Region Names Scenario using the default profile | ||
This scenario demonstrates the following: | ||
1. Getting all regions with details in a paginated manner | ||
2. Filtering region names | ||
*/ | ||
GetListOfRegionNamesScenario getListOfRegionNamesScenario = new GetListOfRegionNamesScenario(); | ||
getListOfRegionNamesScenario.setProfile(new DefaultRapidPartnerProfile()); | ||
getListOfRegionNamesScenario.run(); | ||
|
||
/* Run Get Region Name of Region Scenario using the default profile | ||
This scenario demonstrates the following: | ||
1. Getting region details by region id | ||
2. Accessing region details | ||
*/ | ||
GetRegionDetailsAndPropertyIdsScenario getRegionNameOfRegionScenario = new GetRegionDetailsAndPropertyIdsScenario(); | ||
getRegionNameOfRegionScenario.setProfile(new DefaultRapidPartnerProfile()); | ||
getRegionNameOfRegionScenario.run(); | ||
|
||
/* Run Get Region By Ancestor Id Scenario using the default profile | ||
This scenario demonstrates the following: | ||
1. Getting paginated regions details by ancestor id | ||
2. Accessing region details | ||
*/ | ||
GetRegionByAncestorIdScenario getRegionByAncestorIdScenario = new GetRegionByAncestorIdScenario(); | ||
getRegionByAncestorIdScenario.setProfile(new DefaultRapidPartnerProfile()); | ||
getRegionByAncestorIdScenario.run(); | ||
|
||
/* Run Get Region With MultiPolygon Coordinates Scenario using the default profile | ||
This scenario demonstrates the following: | ||
1. Getting region details with multipolygon coordinates by region id | ||
2. Accessing region coordinates of type multipolygon | ||
3. Accessing every polygon list of coordinates. | ||
*/ | ||
ParseRegionWithMultiPolygonCoordinatesScenario parseRegionWithMultiPolygonCoordinatesScenario = new ParseRegionWithMultiPolygonCoordinatesScenario(); | ||
parseRegionWithMultiPolygonCoordinatesScenario.setProfile(new DefaultRapidPartnerProfile()); | ||
parseRegionWithMultiPolygonCoordinatesScenario.run(); | ||
|
||
/* Run Parse Region Ancestors Scenario using the default profile | ||
This scenario demonstrates the following: | ||
1. Getting region details with ancestors by region id | ||
2. Parsing region ancestors | ||
*/ | ||
ParseRegionAncestorsScenario parseRegionAncestorsScenario = new ParseRegionAncestorsScenario(); | ||
parseRegionAncestorsScenario.setProfile(new DefaultRapidPartnerProfile()); | ||
parseRegionAncestorsScenario.run(); | ||
|
||
/* Run Parse Region Descendants Scenario using the default profile | ||
This scenario demonstrates the following: | ||
1. Getting region details with descendants by region id | ||
2. Parsing region descendants | ||
*/ | ||
ParseRegionDescendantsScenario parseRegionDescendantsScenario = new ParseRegionDescendantsScenario(); | ||
parseRegionDescendantsScenario.setProfile(new DefaultRapidPartnerProfile()); | ||
parseRegionDescendantsScenario.run(); | ||
|
||
/* Run Parse Region Coordinates Scenario using the default profile | ||
This scenario demonstrates the following: | ||
1. Getting region details with coordinates by region id | ||
2. Parsing region coordinates | ||
*/ | ||
ParseRegionCoordinatesScenario parseRegionCoordinatesScenario = new ParseRegionCoordinatesScenario(); | ||
parseRegionCoordinatesScenario.setProfile(new DefaultRapidPartnerProfile()); | ||
parseRegionCoordinatesScenario.run(); | ||
|
||
/* Run Parse Region Categories Scenario using the default profile | ||
This scenario demonstrates the following: | ||
1. Getting region details with property ids by region id | ||
2. Parsing region categories | ||
*/ | ||
ParseRegionCategoriesScenario parseRegionCategoriesScenario = new ParseRegionCategoriesScenario(); | ||
parseRegionCategoriesScenario.setProfile(new DefaultRapidPartnerProfile()); | ||
parseRegionCategoriesScenario.run(); | ||
|
||
logger.info("=============================== End of Geography Scenarios ==========================="); | ||
|
||
logger.info("======================================================================================="); | ||
logger.info("======================================================================================="); | ||
logger.info("== =="); | ||
logger.info("== That's all folks! That was the demonstration of RAPID SDK Geography. =="); | ||
logger.info("== =="); | ||
logger.info("======================================================================================="); | ||
logger.info("======================================================================================="); | ||
System.exit(0); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...rc/main/java/com/expediagroup/sdk/rapid/examples/scenarios/addelivery/GetAdsScenario.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,57 @@ | ||
package com.expediagroup.sdk.rapid.examples.scenarios.addelivery; | ||
|
||
import com.expediagroup.sdk.core.model.Response; | ||
import com.expediagroup.sdk.rapid.examples.Constants; | ||
import com.expediagroup.sdk.rapid.examples.salesprofiles.RapidPartnerSalesProfile; | ||
import com.expediagroup.sdk.rapid.examples.scenarios.RapidScenario; | ||
import com.expediagroup.sdk.rapid.examples.services.ShopService; | ||
import com.expediagroup.sdk.rapid.examples.services.AdDeliveryService; | ||
import com.expediagroup.sdk.rapid.models.AdsResponse; | ||
import com.expediagroup.sdk.rapid.models.Property; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class GetAdsScenario implements RapidScenario { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(GetAdsScenario.class); | ||
private AdDeliveryService adDeliveryService = new AdDeliveryService(); | ||
private ShopService shopService = new ShopService(); | ||
private RapidPartnerSalesProfile rapidPartnerSalesProfile; | ||
|
||
@Override | ||
public void setProfile(RapidPartnerSalesProfile rapidPartnerSalesProfile) { | ||
this.rapidPartnerSalesProfile = rapidPartnerSalesProfile; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
|
||
logger.info("Running Get Lodging Ads..."); | ||
|
||
// Shopping for properties | ||
logger.info("Getting property availability for test property: {}", Constants.TEST_PROPERTY_ID); | ||
|
||
List<Property> propertyAvailabilityList = shopService.getPropertiesAvailability(Arrays.asList("2"), this.rapidPartnerSalesProfile).getData(); | ||
|
||
if (propertyAvailabilityList == null || propertyAvailabilityList.isEmpty()) { | ||
throw new IllegalStateException("No property availability found for the test property."); | ||
} | ||
|
||
// Get the property ids from response | ||
ArrayList<String> propertyIds = new ArrayList<>(); | ||
propertyAvailabilityList.forEach(property -> propertyIds.add(property.getPropertyId())); | ||
|
||
// call Ad Delivery API | ||
logger.info("Calling GetAdsOperation for property ids:"); | ||
propertyIds.forEach(propertyId -> logger.info("Property Id: [{}]", propertyId)); | ||
|
||
Response<AdsResponse> adsResponse = adDeliveryService.getAds(propertyIds); | ||
logger.info("Get ads response status: [{}]", adsResponse.getStatusCode()); | ||
logger.info("Get ads response, number of sponsored listings: {}", adsResponse.getData() | ||
.getSponsoredListings().size()); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
examples/src/main/java/com/expediagroup/sdk/rapid/examples/services/AdDeliveryService.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,54 @@ | ||
package com.expediagroup.sdk.rapid.examples.services; | ||
|
||
import com.expediagroup.sdk.core.model.Response; | ||
import com.expediagroup.sdk.rapid.examples.Constants; | ||
import com.expediagroup.sdk.rapid.models.AdsRequest; | ||
import com.expediagroup.sdk.rapid.models.AdsResponse; | ||
import com.expediagroup.sdk.rapid.models.Coordinates1; | ||
import com.expediagroup.sdk.rapid.models.GuestCounts; | ||
import com.expediagroup.sdk.rapid.models.PageType; | ||
import com.expediagroup.sdk.rapid.models.ProductLine; | ||
import com.expediagroup.sdk.rapid.models.SalesChannel; | ||
import com.expediagroup.sdk.rapid.operations.GetAdsOperation; | ||
import com.expediagroup.sdk.rapid.operations.GetAdsOperationParams; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDate; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class AdDeliveryService extends RapidService { | ||
|
||
public Response<AdsResponse> getAds(List<String> propertyIds) { | ||
GetAdsOperationParams getAdsOperationParams = getAdsOperationParams(); | ||
|
||
AdsRequest adsRequest = AdsRequest.builder() | ||
.checkin(LocalDate.now().plusDays(20).toString()) | ||
.checkout(LocalDate.now().plusDays(23).toString()) | ||
.occupancies(Arrays.asList(GuestCounts.builder().adultCount(2).childCount(0).build())) | ||
.searchProductLines(Arrays.asList(ProductLine.LODGING)) | ||
.propertyIds(propertyIds) | ||
.pageType(PageType.SEARCH_RESULTS) | ||
.salesChannel(SalesChannel.WEBSITE) | ||
.countryCode("US") | ||
.experimentIds(Arrays.asList("1234")) | ||
.language("en-US") | ||
.travelerLocation(Coordinates1.builder() | ||
.latitude(BigDecimal.valueOf(37.7749)) | ||
.longitude(BigDecimal.valueOf(-122.4194)) | ||
.build()) | ||
.build(); | ||
|
||
GetAdsOperation getAdsOperation = | ||
new GetAdsOperation(getAdsOperationParams, adsRequest); | ||
|
||
return rapidClient.execute(getAdsOperation); | ||
} | ||
|
||
private GetAdsOperationParams getAdsOperationParams() { | ||
return GetAdsOperationParams | ||
.builder() | ||
.customerIp(Constants.CUSTOMER_IP) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.