Skip to content

Latest commit

 

History

History
193 lines (141 loc) · 5.28 KB

locations.md

File metadata and controls

193 lines (141 loc) · 5.28 KB

Locations

locations_api = client.locations

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.

def list_locations(self)

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type List Locations Response.

Example Usage

result = locations_api.list_locations()
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

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.

def create_location(self,
                   body)

Parameters

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

See the corresponding object definition for field details.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Create Location Response.

Example Usage

body = {
    'location': {
        'name': 'Midtown',
        'address': {
            'address_line_1': '1234 Peachtree St. NE',
            'locality': 'Atlanta',
            'administrative_district_level_1': 'GA',
            'postal_code': '30309'
        },
        'description': 'Midtown Atlanta store'
    }
}

result = locations_api.create_location(body)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Retrieve Location

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

def retrieve_location(self,
                     location_id)

Parameters

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

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Retrieve Location Response.

Example Usage

location_id = 'location_id4'

result = locations_api.retrieve_location(location_id)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Update Location

Updates a location.

def update_location(self,
                   location_id,
                   body)

Parameters

Parameter Type Tags Description
location_id str Template, Required The ID of the location to update.
body Update Location Request Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a ApiResponse instance. The body property of this instance returns the response data which is of type Update Location Response.

Example Usage

location_id = 'location_id4'

body = {
    'location': {
        'business_hours': {
            'periods': [
                {
                    'day_of_week': 'FRI',
                    'start_local_time': '07:00',
                    'end_local_time': '18:00'
                },
                {
                    'day_of_week': 'SAT',
                    'start_local_time': '07:00',
                    'end_local_time': '18:00'
                },
                {
                    'day_of_week': 'SUN',
                    'start_local_time': '09:00',
                    'end_local_time': '15:00'
                }
            ]
        },
        'description': 'Midtown Atlanta store - Open weekends'
    }
}

result = locations_api.update_location(
    location_id,
    body
)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)