Skip to content

Latest commit

 

History

History
170 lines (120 loc) · 4.37 KB

locations.md

File metadata and controls

170 lines (120 loc) · 4.37 KB

Locations

locations_api = client.locations

Class Name

LocationsApi

Methods

List Locations

Provides information of all locations of a business.

Most other Connect API endpoints have a required location_id path parameter. The id field of the Location objects returned by this endpoint correspond to that location_id parameter.

def list_locations(self)

Response Type

List Locations Response

Example Usage

result = locations_api.list_locations()

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

Create Location

Creates a location. For more information about locations, see Locations API Overview.

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

Create Location Response

Example Usage

body = {}
body['location'] = {}
body['location']['name'] = 'New location name'
body['location']['address'] = {}
body['location']['address']['address_line_1'] = '1234 Peachtree St. NE'
body['location']['address']['locality'] = 'Atlanta'
body['location']['address']['administrative_district_level_1'] = 'GA'
body['location']['address']['postal_code'] = '30309'
body['location']['description'] = 'My new location.'

result = locations_api.create_location(body)

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

Retrieve Location

Retrieves details of a location.

def retrieve_location(self,
                     location_id)

Parameters

Parameter Type Tags Description
location_id string Template, Required The ID of the location to retrieve.

Response Type

Retrieve Location Response

Example Usage

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)

Update Location

Updates a location.

def update_location(self,
                   location_id,
                   body)

Parameters

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.

Response Type

Update Location Response

Example Usage

location_id = 'location_id4'
body = {}
body['location'] = {}
body['location']['name'] = 'Updated nickname'
body['location']['address'] = {}
body['location']['address']['address_line_1'] = '1234 Peachtree St. NE'
body['location']['address']['locality'] = 'Atlanta'
body['location']['address']['administrative_district_level_1'] = 'GA'
body['location']['address']['postal_code'] = '30309'
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'

result = locations_api.update_location(location_id, body)

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