Search in sources :

Example 1 with LatLng

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;
}
Also used : PostalAddress(com.google.api.services.actions_fulfillment.v2.model.PostalAddress) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) LatLng(com.google.api.services.actions_fulfillment.v2.model.LatLng) Location(com.google.api.services.actions_fulfillment.v2.model.Location)

Example 2 with LatLng

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);
}
Also used : SearchJobsRequest(com.google.api.services.jobs.v3.model.SearchJobsRequest) SearchJobsResponse(com.google.api.services.jobs.v3.model.SearchJobsResponse) JobQuery(com.google.api.services.jobs.v3.model.JobQuery) CommuteFilter(com.google.api.services.jobs.v3.model.CommuteFilter) LatLng(com.google.api.services.jobs.v3.model.LatLng) RequestMetadata(com.google.api.services.jobs.v3.model.RequestMetadata)

Aggregations

LatLng (com.google.api.services.actions_fulfillment.v2.model.LatLng)1 Location (com.google.api.services.actions_fulfillment.v2.model.Location)1 PostalAddress (com.google.api.services.actions_fulfillment.v2.model.PostalAddress)1 CommuteFilter (com.google.api.services.jobs.v3.model.CommuteFilter)1 JobQuery (com.google.api.services.jobs.v3.model.JobQuery)1 LatLng (com.google.api.services.jobs.v3.model.LatLng)1 RequestMetadata (com.google.api.services.jobs.v3.model.RequestMetadata)1 SearchJobsRequest (com.google.api.services.jobs.v3.model.SearchJobsRequest)1 SearchJobsResponse (com.google.api.services.jobs.v3.model.SearchJobsResponse)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1