Skip to content

Latest commit

 

History

History
210 lines (164 loc) · 6.2 KB

locations.md

File metadata and controls

210 lines (164 loc) · 6.2 KB

Locations

LocationsApi locationsApi = client.getLocationsApi();

Class Name

LocationsApi

Methods

List Locations

Provides information of all locations of a business.

Most other Connect API endpoints have a required location_id path parameter. The id field of the Location objects returned by this endpoint correspond to that location_id parameter.

CompletableFuture<ListLocationsResponse> listLocationsAsync()

Response Type

ListLocationsResponse

Example Usage

locationsApi.listLocationsAsync().thenAccept(result -> {
    // TODO success callback handler
}).exceptionally(exception -> {
    // TODO failure callback handler
    return null;
});

Create Location

Creates a location. For more information about locations, see Locations API Overview.

CompletableFuture<CreateLocationResponse> createLocationAsync(
    final CreateLocationRequest body)

Parameters

Parameter Type Tags Description
body CreateLocationRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

CreateLocationResponse

Example Usage

Address bodyLocationAddress = new Address.Builder()
    .addressLine1("1234 Peachtree St. NE")
    .addressLine2("address_line_26")
    .addressLine3("address_line_32")
    .locality("Atlanta")
    .sublocality("sublocality6")
    .administrativeDistrictLevel1("GA")
    .postalCode("30309")
    .build();
List<String> bodyLocationCapabilities = new LinkedList<>();
bodyLocationCapabilities.add("CREDIT_CARD_PROCESSING");
bodyLocationCapabilities.add("CREDIT_CARD_PROCESSING");
bodyLocationCapabilities.add("CREDIT_CARD_PROCESSING");
Location bodyLocation = new Location.Builder()
    .id("id0")
    .name("New location name")
    .address(bodyLocationAddress)
    .timezone("timezone0")
    .capabilities(bodyLocationCapabilities)
    .description("My new location.")
    .facebookUrl("null")
    .build();
CreateLocationRequest body = new CreateLocationRequest.Builder()
    .location(bodyLocation)
    .build();

locationsApi.createLocationAsync(body).thenAccept(result -> {
    // TODO success callback handler
}).exceptionally(exception -> {
    // TODO failure callback handler
    return null;
});

Retrieve Location

Retrieves details of a location. You can specify "main" as the location ID to retrieve details of the main location. For more information, see Locations API Overview.

CompletableFuture<RetrieveLocationResponse> retrieveLocationAsync(
    final String locationId)

Parameters

Parameter Type Tags Description
locationId String Template, Required The ID of the location to retrieve. If you specify the string "main",
then the endpoint returns the main location.

Response Type

RetrieveLocationResponse

Example Usage

String locationId = "location_id4";

locationsApi.retrieveLocationAsync(locationId).thenAccept(result -> {
    // TODO success callback handler
}).exceptionally(exception -> {
    // TODO failure callback handler
    return null;
});

Update Location

Updates a location.

CompletableFuture<UpdateLocationResponse> updateLocationAsync(
    final String locationId,
    final UpdateLocationRequest body)

Parameters

Parameter Type Tags Description
locationId String Template, Required The ID of the location to update.
body UpdateLocationRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

UpdateLocationResponse

Example Usage

String locationId = "location_id4";
Address bodyLocationAddress = new Address.Builder()
    .addressLine1("1234 Peachtree St. NE")
    .addressLine2("address_line_26")
    .addressLine3("address_line_32")
    .locality("Atlanta")
    .sublocality("sublocality6")
    .administrativeDistrictLevel1("GA")
    .postalCode("30309")
    .build();
List<String> bodyLocationCapabilities = new LinkedList<>();
bodyLocationCapabilities.add("CREDIT_CARD_PROCESSING");
bodyLocationCapabilities.add("CREDIT_CARD_PROCESSING");
bodyLocationCapabilities.add("CREDIT_CARD_PROCESSING");
List<BusinessHoursPeriod> bodyLocationBusinessHoursPeriods = new LinkedList<>();

BusinessHoursPeriod bodyLocationBusinessHoursPeriods0 = new BusinessHoursPeriod.Builder()
    .dayOfWeek("MON")
    .startLocalTime("09:00")
    .endLocalTime("17:00")
    .build();
bodyLocationBusinessHoursPeriods.add(bodyLocationBusinessHoursPeriods0);

BusinessHours bodyLocationBusinessHours = new BusinessHours.Builder()
    .periods(bodyLocationBusinessHoursPeriods)
    .build();
Location bodyLocation = new Location.Builder()
    .id("id0")
    .name("Updated nickname")
    .address(bodyLocationAddress)
    .timezone("timezone0")
    .capabilities(bodyLocationCapabilities)
    .businessHours(bodyLocationBusinessHours)
    .description("Updated description")
    .twitterUsername("twitter")
    .instagramUsername("instagram")
    .facebookUrl("null")
    .build();
UpdateLocationRequest body = new UpdateLocationRequest.Builder()
    .location(bodyLocation)
    .build();

locationsApi.updateLocationAsync(locationId, body).thenAccept(result -> {
    // TODO success callback handler
}).exceptionally(exception -> {
    // TODO failure callback handler
    return null;
});