Skip to content

Latest commit

 

History

History
205 lines (159 loc) · 5.27 KB

locations.md

File metadata and controls

205 lines (159 loc) · 5.27 KB

Locations

ILocationsApi locationsApi = client.LocationsApi;

Class Name

LocationsApi

Methods

List Locations

Provides details about all of the seller's locations, including those with an inactive status. Locations are listed alphabetically by name.

ListLocationsAsync()

Response Type

Task<Models.ListLocationsResponse>

Example Usage

try
{
    ListLocationsResponse result = await locationsApi.ListLocationsAsync();
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Create Location

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)

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

Task<Models.CreateLocationResponse>

Example Usage

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);
}

Retrieve Location

Retrieves details of a single location. Specify "main" as the location ID to retrieve details of the main location.

RetrieveLocationAsync(
    string locationId)

Parameters

Parameter Type Tags Description
locationId string Template, Required The ID of the location to retrieve. Specify the string
"main" to return the main location.

Response Type

Task<Models.RetrieveLocationResponse>

Example Usage

string locationId = "location_id4";
try
{
    RetrieveLocationResponse result = await locationsApi.RetrieveLocationAsync(locationId);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Update Location

Updates a location.

UpdateLocationAsync(
    string locationId,
    Models.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

Task<Models.UpdateLocationResponse>

Example Usage

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);
}