locations_api = client.locationsLocationsApi
Provides details about all of the seller's locations, including those with an inactive status.
def list_locations(self)result = locations_api.list_locations()
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)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 via applications that integrate with Square from sales activity elsewhere in a seller's account. Locations created programmatically with the Locations API will last forever and are visible to the seller for their own management, so ensure that each location has a sensible and unique name.
def create_location(self,
body)| 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. |
body = {}
body['location'] = {}
body['location']['id'] = 'id0'
body['location']['name'] = 'New location name'
body['location']['address'] = {}
body['location']['address']['address_line_1'] = '1234 Peachtree St. NE'
body['location']['address']['address_line_2'] = 'address_line_26'
body['location']['address']['address_line_3'] = 'address_line_32'
body['location']['address']['locality'] = 'Atlanta'
body['location']['address']['sublocality'] = 'sublocality6'
body['location']['address']['administrative_district_level_1'] = 'GA'
body['location']['address']['postal_code'] = '30309'
body['location']['timezone'] = 'timezone0'
body['location']['capabilities'] = ['AUTOMATIC_TRANSFERS', 'CREDIT_CARD_PROCESSING', 'AUTOMATIC_TRANSFERS']
body['location']['description'] = 'My new location.'
body['location']['facebook_url'] = 'null'
result = locations_api.create_location(body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)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)| Parameter | Type | Tags | Description |
|---|---|---|---|
location_id |
string |
Template, Required | The ID of the location to retrieve. Specify the string "main" to return the main location. |
location_id = 'location_id4'
result = locations_api.retrieve_location(location_id)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)Updates a location.
def update_location(self,
location_id,
body)| Parameter | Type | Tags | Description |
|---|---|---|---|
location_id |
string |
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. |
location_id = 'location_id4'
body = {}
body['location'] = {}
body['location']['id'] = 'id0'
body['location']['name'] = 'Updated nickname'
body['location']['address'] = {}
body['location']['address']['address_line_1'] = '1234 Peachtree St. NE'
body['location']['address']['address_line_2'] = 'address_line_26'
body['location']['address']['address_line_3'] = 'address_line_32'
body['location']['address']['locality'] = 'Atlanta'
body['location']['address']['sublocality'] = 'sublocality6'
body['location']['address']['administrative_district_level_1'] = 'GA'
body['location']['address']['postal_code'] = '30309'
body['location']['timezone'] = 'timezone0'
body['location']['capabilities'] = ['AUTOMATIC_TRANSFERS', 'CREDIT_CARD_PROCESSING', 'AUTOMATIC_TRANSFERS']
body['location']['business_hours'] = {}
body['location']['business_hours']['periods'] = []
body['location']['business_hours']['periods'].append({})
body['location']['business_hours']['periods'][0]['day_of_week'] = 'MON'
body['location']['business_hours']['periods'][0]['start_local_time'] = '09:00'
body['location']['business_hours']['periods'][0]['end_local_time'] = '17:00'
body['location']['description'] = 'Updated description'
body['location']['twitter_username'] = 'twitter'
body['location']['instagram_username'] = 'instagram'
body['location']['facebook_url'] = 'null'
result = locations_api.update_location(location_id, body)
if result.is_success():
print(result.body)
elif result.is_error():
print(result.errors)