ILocationsApi locationsApi = client.LocationsApi;
LocationsApi
Provides details about all of the seller's locations,
including those with an inactive status. Locations are listed alphabetically by name
.
ListLocationsAsync()
Task<Models.ListLocationsResponse>
try
{
ListLocationsResponse result = await locationsApi.ListLocationsAsync();
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
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.
CreateLocationAsync(
Models.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. |
Task<Models.CreateLocationResponse>
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();
try
{
CreateLocationResponse result = await locationsApi.CreateLocationAsync(body);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Retrieves details of a single location. Specify "main" as the location ID to retrieve details of the main location.
RetrieveLocationAsync(
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. |
Task<Models.RetrieveLocationResponse>
string locationId = "location_id4";
try
{
RetrieveLocationResponse result = await locationsApi.RetrieveLocationAsync(locationId);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}
Updates a location.
UpdateLocationAsync(
string locationId,
Models.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. |
Task<Models.UpdateLocationResponse>
string locationId = "location_id4";
UpdateLocationRequest body = new UpdateLocationRequest.Builder()
.Location(
new Location.Builder()
.BusinessHours(
new BusinessHours.Builder()
.Periods(
new List<BusinessHoursPeriod>
{
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();
try
{
UpdateLocationResponse result = await locationsApi.UpdateLocationAsync(
locationId,
body
);
}
catch (ApiException e)
{
// TODO: Handle exception here
Console.WriteLine(e.Message);
}