LocationsApi locationsApi = client.getLocationsApi();
LocationsApi
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()
locationsApi.listLocationsAsync().thenAccept(result -> {
// TODO success callback handler
}).exceptionally(exception -> {
// TODO failure callback handler
return null;
});
Creates a location. For more information about locations, see Locations API Overview.
CompletableFuture<CreateLocationResponse> createLocationAsync(
final CreateLocationRequest body)
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. |
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;
});
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)
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. |
String locationId = "location_id4";
locationsApi.retrieveLocationAsync(locationId).thenAccept(result -> {
// TODO success callback handler
}).exceptionally(exception -> {
// TODO failure callback handler
return null;
});
Updates a location.
CompletableFuture<UpdateLocationResponse> updateLocationAsync(
final String locationId,
final UpdateLocationRequest body)
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. |
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;
});