Make address_type and address_type_number available.

e911_addr
Chris Lacina 7 years ago
parent 187667d15b
commit 440446750e
  1. 27
      e911_demo.py
  2. 32
      flowroutenumbersandmessaging/controllers/e911s_controller.py

@ -42,7 +42,9 @@ try:
city="Seattle", city="Seattle",
state="WA", state="WA",
country="US", country="US",
zipcode="98101") zipcode="98101",
address_type="Suite",
address_type_number="600")
pprint.pprint(result) pprint.pprint(result)
except Exception as e: except Exception as e:
print(str(e)) print(str(e))
@ -59,7 +61,28 @@ try:
city="Seattle", city="Seattle",
state="WA", state="WA",
country="US", country="US",
zipcode="98101") zipcode="98101",
address_type="Suite",
address_type_number="600")
pprint.pprint(result)
except Exception as e:
print(str(e))
print(e.context.response.raw_body)
print("\n--Create and Validate an Address")
try:
result = e911s_controller.create_address(
label="E911 Test",
first_name="Chris",
last_name="Smith",
street_name="3rd Ave",
street_number="1218",
city="Seattle",
state="WA",
country="US",
zipcode="98101",
address_type='Suite',
address_type_number='700')
pprint.pprint(result) pprint.pprint(result)
except Exception as e: except Exception as e:
print(str(e)) print(str(e))

@ -103,7 +103,9 @@ class E911sController(BaseController):
city, city,
state, state,
country, country,
zipcode): zipcode,
address_type=None,
address_type_number=None):
"""Does a POST request to /v2/e911s/validate. """Does a POST request to /v2/e911s/validate.
Returns a 204 No Content on success, or a 404 with error data Returns a 204 No Content on success, or a 404 with error data
@ -118,6 +120,8 @@ class E911sController(BaseController):
state (2 character string): state (2 character string):
country (string USA or Canada): country (string USA or Canada):
zipcode (string postal code) zipcode (string postal code)
address_type (string address type)
address_type_number (string when address_type used, required)
Returns: Returns:
mixed: Response from the API. A 204 - No Content or a mixed: Response from the API. A 204 - No Content or a
@ -142,11 +146,15 @@ class E911sController(BaseController):
'city': city, 'city': city,
'state': state, 'state': state,
'country': country, 'country': country,
'zip': zipcode 'zip': zipcode,
} }
} }
} }
if address_type and address_type_number:
body['data']['attributes']['address_type'] = address_type
body['data']['attributes']['address_type_number'] = address_type_number
# Prepare query URL # Prepare query URL
_query_builder = Configuration.base_uri _query_builder = Configuration.base_uri
_query_builder += '/v2/e911s/validate' _query_builder += '/v2/e911s/validate'
@ -175,7 +183,9 @@ class E911sController(BaseController):
city, city,
state, state,
country, country,
zipcode): zipcode,
address_type=None,
address_type_number=None):
"""Does a POST request to /v2/e911s. """Does a POST request to /v2/e911s.
Creates an address record that can then be associated Creates an address record that can then be associated
@ -191,6 +201,8 @@ class E911sController(BaseController):
state (2 character string): state (2 character string):
country (string USA or Canada): country (string USA or Canada):
zipcode (string postal code) zipcode (string postal code)
address_type (string address type)
address_type_number (string required if address_type specified)
Returns: Returns:
mixed: Response from the API. A JSON object containing the new mixed: Response from the API. A JSON object containing the new
@ -215,11 +227,15 @@ class E911sController(BaseController):
'city': city, 'city': city,
'state': state, 'state': state,
'country': country, 'country': country,
'zip': zipcode 'zip': zipcode,
} }
} }
} }
if address_type and address_type_number:
body['data']['attributes']['address_type'] = address_type
body['data']['attributes']['address_type_number'] = address_type_number
# Prepare query URL # Prepare query URL
_query_builder = Configuration.base_uri _query_builder = Configuration.base_uri
_query_builder += '/v2/e911s' _query_builder += '/v2/e911s'
@ -249,7 +265,9 @@ class E911sController(BaseController):
city=None, city=None,
state=None, state=None,
country=None, country=None,
zipcode=None): zipcode=None,
address_type=None,
address_type_number=None):
"""Does a PATCH request to /v2/e911s/<e911_id>. """Does a PATCH request to /v2/e911s/<e911_id>.
@ -303,6 +321,10 @@ class E911sController(BaseController):
record_data['data']['attributes']['zip'] = str(zipcode) record_data['data']['attributes']['zip'] = str(zipcode)
record_data['data']['attributes']['zip_code'] = str(zipcode) record_data['data']['attributes']['zip_code'] = str(zipcode)
record_data['data']['attributes']['address_type'] = address_type
record_data['data']['attributes']['address_type_number'] = \
address_type_number
# Fix address_type if not used # Fix address_type if not used
if 'address_type' in record_data['data']['attributes'] and \ if 'address_type' in record_data['data']['attributes'] and \
record_data['data']['attributes']['address_type'] == u'': record_data['data']['attributes']['address_type'] == u'':

Loading…
Cancel
Save