LocationsApi locationsApi = client.getLocationsApi();
LocationsApi
Provides details about all of the seller's locations,
including those with an inactive status. Locations are listed alphabetically by name
.
CompletableFuture<ListLocationsResponse> listLocationsAsync()
locationsApi.listLocationsAsync().thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Creates a location. Creating new locations allows for separate configuration of receipt layouts, item prices, and sales reports. Developers can use locations to separate sales activity through applications that integrate with Square from sales activity elsewhere in a seller's account. Locations created programmatically with the Locations API last forever and are visible to the seller for their own management. Therefore, ensure that each location has a sensible and unique name.
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. |
CreateLocationRequest body = new CreateLocationRequest.Builder()
.location(new Location.Builder()
.name("Midtown")
.address(new Address.Builder()
.addressLine1("1234 Peachtree St. NE")
.locality("Atlanta")
.administrativeDistrictLevel1("GA")
.postalCode("30309")
.build())
.description("Midtown Atlanta store")
.build())
.build();
locationsApi.createLocationAsync(body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Retrieves details of a single location. Specify "main" as the location ID to retrieve details of the main location.
CompletableFuture<RetrieveLocationResponse> retrieveLocationAsync(
final String locationId)
Parameter | Type | Tags | Description |
---|---|---|---|
locationId |
String |
Template, Required | The ID of the location to retrieve. Specify the string "main" to return the main location. |
String locationId = "location_id4";
locationsApi.retrieveLocationAsync(locationId).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
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";
UpdateLocationRequest body = new UpdateLocationRequest.Builder()
.location(new Location.Builder()
.businessHours(new BusinessHours.Builder()
.periods(Arrays.asList(
new BusinessHoursPeriod.Builder()
.dayOfWeek("FRI")
.startLocalTime("07:00")
.endLocalTime("18:00")
.build(),
new BusinessHoursPeriod.Builder()
.dayOfWeek("SAT")
.startLocalTime("07:00")
.endLocalTime("18:00")
.build(),
new BusinessHoursPeriod.Builder()
.dayOfWeek("SUN")
.startLocalTime("09:00")
.endLocalTime("15:00")
.build()
))
.build())
.description("Midtown Atlanta store - Open weekends")
.build())
.build();
locationsApi.updateLocationAsync(locationId, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});