use of com.google.api.services.actions_fulfillment.v2.model.LatLng in project dialogflow-transactions-java by actions-on-google.
the class LocationDeserializer method deserialize.
@Override
public Location deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject();
Location location = new Location();
JsonElement city = jsonObject.get("city");
JsonElement coordinates = jsonObject.get("coordinates");
JsonElement name = jsonObject.get("name");
JsonElement notes = jsonObject.get("notes");
JsonElement phoneNumber = jsonObject.get("phoneNumber");
JsonElement placeId = jsonObject.get("placeId");
JsonElement zipCode = jsonObject.get("zipCode");
JsonElement formattedAddress = jsonObject.get("formattedAddress");
JsonElement postalAddress = jsonObject.get("postalAddress");
if (city != null) {
location.setCity(city.getAsString());
}
if (name != null) {
location.setName(name.getAsString());
}
if (notes != null) {
location.setNotes(notes.getAsString());
}
if (phoneNumber != null) {
location.setPhoneNumber(phoneNumber.getAsString());
}
if (placeId != null) {
location.setPlaceId(placeId.getAsString());
}
if (zipCode != null) {
location.setZipCode(zipCode.getAsString());
}
if (formattedAddress != null) {
location.setFormattedAddress(formattedAddress.getAsString());
}
if (postalAddress != null) {
PostalAddress address = context.deserialize(postalAddress.getAsJsonObject(), PostalAddress.class);
location.setPostalAddress(address);
}
if (coordinates != null) {
LatLng coords = context.deserialize(coordinates.getAsJsonObject(), LatLng.class);
location.setCoordinates(coords);
}
return location;
}
use of com.google.api.services.actions_fulfillment.v2.model.LatLng in project java-docs-samples by GoogleCloudPlatform.
the class CommuteSearchSample method commuteSearch.
// [START commute_search]
public static void commuteSearch(String companyName) throws IOException, InterruptedException {
// Make sure to set the requestMetadata the same as the associated search request
RequestMetadata requestMetadata = new RequestMetadata().setUserId("HashedUserId").setSessionId("HashedSessionID").setDomain("www.google.com");
JobQuery jobQuery = new JobQuery().setCommuteFilter(new CommuteFilter().setRoadTraffic("TRAFFIC_FREE").setCommuteMethod("TRANSIT").setTravelDuration("1000s").setStartCoordinates(new LatLng().setLatitude(37.422408).setLongitude(-122.085609)));
if (companyName != null) {
jobQuery.setCompanyNames(Arrays.asList(companyName));
}
SearchJobsRequest searchJobsRequest = new SearchJobsRequest().setJobQuery(jobQuery).setRequestMetadata(requestMetadata).setJobView("JOB_VIEW_FULL").setRequirePreciseResultSize(true);
SearchJobsResponse response = talentSolutionClient.projects().jobs().search(DEFAULT_PROJECT_ID, searchJobsRequest).execute();
Thread.sleep(1000);
System.out.printf("Search jobs for commute results: %s\n", response);
}
Aggregations