From 6ca8ef0a5956eb8e38a0dd2e4aa95c47741d5741 Mon Sep 17 00:00:00 2001 From: Maria Bermudez Date: Fri, 1 Jun 2018 12:31:47 -0700 Subject: [PATCH 1/8] Update accepted JSON format --- .../controllers/e911s_controller.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flowroutenumbersandmessaging/controllers/e911s_controller.py b/flowroutenumbersandmessaging/controllers/e911s_controller.py index 50861f8..843ecaa 100644 --- a/flowroutenumbersandmessaging/controllers/e911s_controller.py +++ b/flowroutenumbersandmessaging/controllers/e911s_controller.py @@ -156,7 +156,7 @@ class E911sController(BaseController): # Prepare headers _headers = { - 'accept': 'application/json' + 'accept': 'application/vnd.api+json' } # Prepare and execute request @@ -229,7 +229,7 @@ class E911sController(BaseController): # Prepare headers _headers = { - 'accept': 'application/json' + 'accept': 'application/vnd.api+json' } # Prepare and execute request @@ -318,7 +318,7 @@ class E911sController(BaseController): # Prepare headers _headers = { - 'accept': 'application/json' + 'accept': 'application/vnd.api+json' } # Prepare and execute request @@ -356,7 +356,7 @@ class E911sController(BaseController): # Prepare headers _headers = { - 'accept': 'application/json' + 'accept': 'application/vnd.api+json' } # Prepare and execute request @@ -394,7 +394,7 @@ class E911sController(BaseController): # Prepare headers _headers = { - 'accept': 'application/json' + 'accept': 'application/vnd.api+json' } # Prepare and execute request @@ -430,7 +430,7 @@ class E911sController(BaseController): # Prepare headers _headers = { - 'accept': 'application/json' + 'accept': 'application/vnd.api+json' } # Prepare and execute request From a1608d8c1ee883f54da4123521edc9377caef0f2 Mon Sep 17 00:00:00 2001 From: Maria Bermudez Date: Fri, 1 Jun 2018 13:00:10 -0700 Subject: [PATCH 2/8] Update anchor links for E911 and CNAM methods --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0a6544e..697b929 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ The Flowroute Python Library v3 provides methods for interacting with [Numbers v * [get_e911](#get_e911e911_id) * [validate_address](#validate_addresse911_attributes) * [create_address](#create_addresse911_attributes) - * [update_address](#e911_ide911_attribute) + * [update_address](#update_addresse911_id-e911_attributes) * [associate](#associatee911_id-number_id) * [list_dids_for_e911](#list_dids_for_e911e911_id) * [disconnect](#disconnectnumber_id) @@ -50,7 +50,7 @@ The Flowroute Python Library v3 provides methods for interacting with [Numbers v * [list_cnams](#list_cnams) * [get_cnam](#get_cnamcnam_id) * [create_cnam_record](#create_cnam_recordcnam_value) - * [associate_cnam](#associatecnam_id-number_id) + * [associate_cnam](#associate_cnamcnam_id-number_id) * [unassociate_cnam](#unassociate_cnamnumber_id) * [remove_cnam](#remove_cnamcnam_id) @@ -133,7 +133,7 @@ Contains all of the methods necessary to create, update, and validate new and ex * [create\_address(e911\_attributes)](#create_addresse911_attributes) \- Lets you create and validate an E911 address within the US and Canada which can then be assigned to any of the long code or tollĀ­free numbers on your account. To assign an E911 address to your number, see the [associate](#associatee911_id-number_id) method. * [update\_address(e911\_id, e911\_attributes)](#update_addresse911_id-e911_attributes) \- Lets you update and validate an existing E911 address on your account. You must create the E911 address first by following the [create\_address](#create_address) method. * [associate(e911\_id, number\_id)](#associatee911_id-number_id) \- Lets you assign a valid E911 address to a specific long code or toll-free phone number in your account. This method calls an endpoint which does not return an error for subsequent attempts at associating a phone number with the same E911 record. The E911 record assignment charge only occurs on the first successful attempt. Note that you can later assign a different `e911_id` to the same phone number and will be charged accordingly. -* [list\_dids\_for\_e911(e911\_id)](#list_dids_for_e911number_id) \- Returns a list of your Flowroute long code or toll-free phone numbers associated with a specified E911 record. +* [list\_dids\_for\_e911(e911\_id)](#list_dids_for_e911e911_id) \- Returns a list of your Flowroute long code or toll-free phone numbers associated with a specified E911 record. * [disconnect(number\_id)](#disconnectnumber_id) \- Lets you deactivate the current E911 service for your phone number. * [delete\_address(e911\_id)](#delete_addresse911_id) \- Lets you delete an E911 address associated with your account. You must remove all phone number associations first before you can successfully delete the specified E911 record. @@ -141,11 +141,11 @@ Contains all of the methods necessary to create, update, and validate new and ex Contains all of the methods necessary to create and delete CNAM records, view all of the CNAM records associated with your account, filter for specific CNAM records by status, review CNAM record details, and assign and unassign CNAM records to your Flowroute long code phone numbers. * [list\_cnams()](#list_cnams) \- Returns a list of all CNAM records on your account by default. You can apply search filters using any of the available query parameters. -* [get\_cnam(cnam\_id)](#get_cnam) \- Returns details pertaining to a specific CNAM record on your account, including long code numbers that are associated with the record. -* [create\_cnam\_record(cnam\_value)](#create_cnam_record) \- Lets you create a Caller ID record for your account which can then be assigned to any of your long code numbers. To assign a CNAM record to your number, see the [associate\_cnam](#associate_cnam) method. -* [associate\_cnam(cnam\_id, number\_id)](#associate) \- Lets you associate a CNAM record with a specified long code number on your account. Note that a CNAM record takes 1-2 days to be approved. -* [unassociate(number\_id)](#disconnect) \- Lets you unassign a CNAM record associated with a specified long code number on your account without deleting the CNAM record itself. -* [remove\_cnam(cnam\_id)](#remove_cnam) \- Lets you delete a CNAM record from your account. Note that this will automatically disassociate all numbers associated with the deleted CNAM record. +* [get\_cnam(cnam\_id)](#get_cnamcnam_id) \- Returns details pertaining to a specific CNAM record on your account, including long code numbers that are associated with the record. +* [create\_cnam\_record(cnam\_value)](#create_cnam_recordcnam_value) \- Lets you create a Caller ID record for your account which can then be assigned to any of your long code numbers. To assign a CNAM record to your number, see the [associate\_cnam](#associate_cnam) method. +* [associate\_cnam(cnam\_id, number\_id)](#associate_cnamcnam_id-number_id) \- Lets you associate a CNAM record with a specified long code number on your account. Note that a CNAM record takes 1-2 days to be approved. +* [unassociate(number\_id)](#unassociate_cnamnumber_id) \- Lets you unassign a CNAM record associated with a specified long code number on your account without deleting the CNAM record itself. +* [remove\_cnam(cnam\_id)](#remove_cnamcnam_id) \- Lets you delete a CNAM record from your account. Note that this will automatically disassociate all numbers associated with the deleted CNAM record. The following shows an example of a single Python file that imports the Flowroute API client and all the required modules. The Python Library v3 comes with three example demo files — **number_route_message_demo.py**, **e911_demo.py**, **cnam_demo.py** — files that you can edit and run for demonstration and testing purposes. @@ -1165,7 +1165,6 @@ On success, the HTTP status code in the response header is `200 OK` and the resp } } ``` -disconnect(number\_id)](#disconnectnumber_id) #### disconnect(number_id) From a161c094670aec8b15e2f72fab0efefa5dd4901a Mon Sep 17 00:00:00 2001 From: Chris Lacina Date: Mon, 4 Jun 2018 16:17:33 -0700 Subject: [PATCH 3/8] Added CNAM and E911 Demos --- cnam_demo.py | 20 +++++++++++++++---- .../controllers/e911s_controller.py | 2 +- number_route_message_demo.py | 8 ++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/cnam_demo.py b/cnam_demo.py index 8b72a28..742d061 100644 --- a/cnam_demo.py +++ b/cnam_demo.py @@ -3,19 +3,22 @@ import pprint import os import random import string -from flowroutenumbersandmessaging.flowroutenumbersandmessaging_client import FlowroutenumbersandmessagingClient +from flowroutenumbersandmessaging.flowroutenumbersandmessaging_client \ + import FlowroutenumbersandmessagingClient # Helper function for random strings def random_generator(size=4, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for x in range(size)) + # Set up your api credentials and test mobile number for outbound SMS or MMS basic_auth_user_name = os.environ.get('FR_ACCESS_KEY') basic_auth_password = os.environ.get('FR_SECRET_KEY') # Instantiate API client and create controllers for Numbers and E911s -client = FlowroutenumbersandmessagingClient(basic_auth_user_name, basic_auth_password) +client = FlowroutenumbersandmessagingClient(basic_auth_user_name, + basic_auth_password) numbers_controller = client.numbers cnams_controller = client.cnams cnam_id = None @@ -38,15 +41,24 @@ if len(result['data']): if len(result['data']): cnam_id = result['data']['id'] -print("\n--Search for CNAM Record") +print("\n--Search for CNAM Record by contains") result = cnams_controller.search_cnams(contains='CHRIS') pprint.pprint(result) +print("\n--Search for CNAM Record by startswith") +result = cnams_controller.search_cnams(starts_with='CHRIS') +pprint.pprint(result) + +print("\n--Search for CNAM Record by endswith") +result = cnams_controller.search_cnams(ends_with='CHRIS') +pprint.pprint(result) + print("\n--Create a CNAM Record") cnam_value = 'FR ' + random_generator() result = cnams_controller.create_cnam_record(cnam_value) pprint.pprint(result) -print("\nNOTE: Newly created CNAM records need to be approved first before they can be associated with your long code number.") +print("\nNOTE: Newly created CNAM records need to be approved first before " + "they can be associated with your long code number.") print("\n--Associate a CNAM Record to a DID") our_numbers = numbers_controller.list_account_phone_numbers() diff --git a/flowroutenumbersandmessaging/controllers/e911s_controller.py b/flowroutenumbersandmessaging/controllers/e911s_controller.py index 50861f8..14bbcd8 100644 --- a/flowroutenumbersandmessaging/controllers/e911s_controller.py +++ b/flowroutenumbersandmessaging/controllers/e911s_controller.py @@ -458,7 +458,7 @@ class E911sController(BaseController): """ # Prepare query URL _query_builder = Configuration.base_uri - _query_builder += '/v2/e911s/{}'.format(e911_id) + _query_builder += '/v2/e911s/{}/relationships/numbers'.format(e911_id) _query_url = APIHelper.clean_url(_query_builder) # Prepare and execute request diff --git a/number_route_message_demo.py b/number_route_message_demo.py index 4e0d175..8f60ab5 100755 --- a/number_route_message_demo.py +++ b/number_route_message_demo.py @@ -13,7 +13,7 @@ print("Number/Route Management v2 & Messaging v2.1 Demo") # Set up your api credentials and test mobile number for outbound SMS or MMS # basic_auth_user_name = os.environ.get('FR_ACCESS_KEY') # basic_auth_password = os.environ.get('FR_SECRET_KEY') -mobile_number = "YOUR_MOBILE_NUMBER" +mobile_number = "YOUR MOBILE NUMBER HERE" # Instantiate API client and create controllers for Numbers, @@ -212,10 +212,14 @@ request_body_with_dlr = '{ \ } \ }' -print("---Send A Message") +print("---Send an SMS Message") result = messages_controller.send_a_message(request_body) pprint.pprint(result) +print("---Send an MMS Message") +result = messages_controller.send_a_message(request_body_mms) +pprint.pprint(result) + print("---Send A Message with a DLR") sms_url = 'http://example.com/sms/special' result = messages_controller.send_a_message(request_body_with_dlr) From 230cf5bab7589342cc82160c43ebe7f1526df176 Mon Sep 17 00:00:00 2001 From: Chris Lacina Date: Tue, 5 Jun 2018 11:38:27 -0700 Subject: [PATCH 4/8] Have purchase number print proper error on insufficient funds. --- number_route_message_demo.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/number_route_message_demo.py b/number_route_message_demo.py index 8f60ab5..af4c186 100755 --- a/number_route_message_demo.py +++ b/number_route_message_demo.py @@ -67,10 +67,15 @@ pprint.pprint(result) purchasable_number = None if len(result['data']): print("--Purchase a Phone Number") - print("NOTE: This demo has been disabled as it pulls credit from your account") + print("NOTE: This demo has been disabled as it pulls " + "credit from your account") # purchasable_number = result['data'][0]['id'] - # result = numbers_controller.purchase_a_phone_number(purchasable_number) - # pprint.pprint(result) + # try: + # result = numbers_controller.purchase_a_phone_number(purchasable_number) + # pprint.pprint(result) + # except Exception as e: + # pprint.pprint(e.context.response.raw_body) + # purchasable_number = None print("--List Account Phone Numbers") starts_with = None @@ -213,17 +218,26 @@ request_body_with_dlr = '{ \ }' print("---Send an SMS Message") -result = messages_controller.send_a_message(request_body) -pprint.pprint(result) +try: + result = messages_controller.send_a_message(request_body) + pprint.pprint(result) +except Exception as e: + pprint.pprint(e.context.response.raw_body) print("---Send an MMS Message") -result = messages_controller.send_a_message(request_body_mms) -pprint.pprint(result) +try: + result = messages_controller.send_a_message(request_body_mms) + pprint.pprint(result) +except Exception as e: + pprint.pprint(e.context.response.raw_body) print("---Send A Message with a DLR") sms_url = 'http://example.com/sms/special' -result = messages_controller.send_a_message(request_body_with_dlr) -pprint.pprint(result) +try: + result = messages_controller.send_a_message(request_body_with_dlr) + pprint.pprint(result) +except Exception as e: + pprint.pprint(e.context.response.raw_body) print("---Look Up A Set Of Messages") start_date = datetime.datetime.now() - relativedelta(days=30) From 8581d9d7f90525e1c9925585d027fb2957c41f3a Mon Sep 17 00:00:00 2001 From: Maria Bermudez Date: Wed, 6 Jun 2018 15:21:16 -0700 Subject: [PATCH 5/8] Update URL for E911 and CNAM reference pages - conform to old resource URIs --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 697b929..054e597 100644 --- a/README.md +++ b/README.md @@ -902,7 +902,7 @@ All of the E911 address management methods are encapsulated in `e911_demo.py`. #### list\_e911s() -The method accepts `limit`, `offset`, and `state` as parameters which you can learn more about in the [API reference](https://developer.flowroute.com/api/e911s/v2.0/list-account-e911-addresses/). +The method accepts `limit`, `offset`, and `state` as parameters which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/list-account-e911-addresses/). ##### Example Request ```python @@ -953,7 +953,7 @@ On success, the HTTP status code in the response header is `200 OK` and the resp #### get\_e911(e911_id) -The method accepts an `e911_id` as a path parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/e911s/v2.0/list-e911-record-details/). +The method accepts an `e911_id` as a path parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/list-e911-record-details/). ##### Example Request ```python @@ -993,7 +993,7 @@ On success, the HTTP status code in the response header is `200 OK` and the resp #### validate_address(e911_attributes) -The method accepts the different attributes of an E911 address as parameters: `label`, `first_name`, `last_name`, `street_name`, `street_number`, `city`, `state`, `country`, and `zipcode`. Learn more about the different E911 attributes in the [API reference](https://developer.flowroute.com/api/e911s/v2.0/validate-e911-address/). Note that this method doesn't accept the `address_type` and `address_type_number` which are acceptable but not required E911 address attributes by the API. +The method accepts the different attributes of an E911 address as parameters: `label`, `first_name`, `last_name`, `street_name`, `street_number`, `city`, `state`, `country`, and `zipcode`. Learn more about the different E911 attributes in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/validate-e911-address/). Note that this method doesn't accept the `address_type` and `address_type_number` which are acceptable but not required E911 address attributes by the API. ##### Example Request ``` @@ -1025,7 +1025,7 @@ HTTP response not OK. ``` #### create_address(e911_attributes) -The method accepts the different attributes of an E911 address as parameters: `label`, `first_name`, `last_name`, `street_name`, `street_number`, `city`, `state`, `country`, and `zipcode`. Learn more about the different E911 attributes in the [API reference](https://developer.flowroute.com/api/e911s/v2.0/create-and-validate-new-e911-address/). Note that this method doesn't accept the `address_type` and `address_type\_number` which are acceptable but not required E911 address attributes by the API. +The method accepts the different attributes of an E911 address as parameters: `label`, `first_name`, `last_name`, `street_name`, `street_number`, `city`, `state`, `country`, and `zipcode`. Learn more about the different E911 attributes in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/create-and-validate-new-e911-address/). Note that this method doesn't accept the `address_type` and `address_type\_number` which are acceptable but not required E911 address attributes by the API. ##### Example Request ``` @@ -1068,7 +1068,7 @@ On success, the HTTP status code in the response header is `201 Created` and the ``` #### update_address(e911_id, e911_attributes) -The method accepts an E911 record id and the different attributes of an E911 address as parameters: `label`, `first_name`, `last_name`, `street_name`, `street_number`, `city`, `state`, `country`, and `zipcode`. Learn more about the different E911 attributes that you can update in the [API reference](https://developer.flowroute.com/api/e911s/v2.0/update-and-validate-existing-e911-address/). Note that this method doesn't accept the `address_type` and `address_type_number` which are acceptable but not required E911 address attributes by the API. In the following example, we will retrieve the record ID of our newly created E911 address and assign it to a variable, `record_id`. We then update the `last_name` of our selected E911 address to "Wiley". +The method accepts an E911 record id and the different attributes of an E911 address as parameters: `label`, `first_name`, `last_name`, `street_name`, `street_number`, `city`, `state`, `country`, and `zipcode`. Learn more about the different E911 attributes that you can update in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/update-and-validate-existing-e911-address/). Note that this method doesn't accept the `address_type` and `address_type_number` which are acceptable but not required E911 address attributes by the API. In the following example, we will retrieve the record ID of our newly created E911 address and assign it to a variable, `record_id`. We then update the `last_name` of our selected E911 address to "Wiley". ##### Example Request ``` @@ -1105,7 +1105,7 @@ On success, the HTTP status code in the response header is `200 OK` and the resp ``` #### associate(e911_id, number_id) -The method accepts an E911 record id and a phone number as parameters which you can learn more about in the [API reference](https://developer.flowroute.com/api/e911s/v2.0/assign-valid-e911-address-to-phone-number/). In the following example, we call the [list_account_phone_numbers](#list_account_phone_numbers) covered under Number Management and [list_e911s](#list_e911s), extract the values of the first items in the returned JSON arrays into variables `e911_id` and `did` then make the association between them. +The method accepts an E911 record id and a phone number as parameters which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/assign-valid-e911-address-to-phone-number/). In the following example, we call the [list_account_phone_numbers](#list_account_phone_numbers) covered under Number Management and [list_e911s](#list_e911s), extract the values of the first items in the returned JSON arrays into variables `e911_id` and `did` then make the association between them. ##### Example Request ``` @@ -1134,7 +1134,7 @@ On success, the HTTP status code in the response header is `204 No Content` whic #### list_dids_for_e911(e911_id) -The method accepts an E911 record id as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/e911s/v2.0/list-phone-numbers-associated-with-e911-record/). In the following example, we retrieve the list of phone numbers associated with our previously assigned `e911_id`. +The method accepts an E911 record id as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/list-phone-numbers-associated-with-e911-record/). In the following example, we retrieve the list of phone numbers associated with our previously assigned `e911_id`. ##### Example Request ``` @@ -1168,7 +1168,7 @@ On success, the HTTP status code in the response header is `200 OK` and the resp #### disconnect(number_id) -The method accepts a phone number as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/e911s/v2.0/deactivate-e911-service-for-phone-number/). In the following example, we deactivate the E911 service for our previously assigned `did`. +The method accepts a phone number as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/deactivate-e911-service-for-phone-number/). In the following example, we deactivate the E911 service for our previously assigned `did`. ##### Example Request ``` @@ -1190,7 +1190,7 @@ On success, the HTTP status code in the response header is `204 No Content` whic ``` #### delete_address(e911_id) -The method accepts an E911 record ID as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/e911s/v2.0/remove-e911-address-from-account/). Note that all phone number associations must be removed first before you are able to delete the specified `e911_id`. In the following example, we will attempt to delete the previously assigned `e911_id`. +The method accepts an E911 record ID as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/remove-e911-address-from-account/). Note that all phone number associations must be removed first before you are able to delete the specified `e911_id`. In the following example, we will attempt to delete the previously assigned `e911_id`. ##### Example Request ``` @@ -1221,7 +1221,7 @@ All of the CNAM record management methods are encapsulated in `cnam_demo.py`. #### list\_cnams() -The method accepts `limit`, `offset`, and `is_approved` as parameters which you can learn more about in the [API reference](https://developer.flowroute.com/api/cnams/v2.0/list-account-cnam-records/). +The method accepts `limit`, `offset`, and `is_approved` as parameters which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/list-account-cnam-records/). ##### Example Request ```python @@ -1300,7 +1300,7 @@ On success, the HTTP status code in the response header is `200 OK` and the resp ``` #### get_cnam(cnam_id) -The method accepts a CNAM record ID as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/cnams/v2.0/list-cnam-record-details/). In the following example, we query for approved CNAM records on your account and then extract the ID of the first record returned and retrieve the details of that specific CNAM record. +The method accepts a CNAM record ID as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/list-cnam-record-details/). In the following example, we query for approved CNAM records on your account and then extract the ID of the first record returned and retrieve the details of that specific CNAM record. ##### Example Request ``` @@ -1330,7 +1330,7 @@ On success, the HTTP status code in the response header is `200 OK` and the resp ``` #### create_cnam_record(cnam_value) -The method accepts a Caller ID value as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/cnams/v2.0/create-a-new-cnam-record/). In the following example, we reuse the `random_generator()` function to generate a four-character random string which we will concatenate with FR and assign as our CNAM value. +The method accepts a Caller ID value as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/create-a-new-cnam-record/). In the following example, we reuse the `random_generator()` function to generate a four-character random string which we will concatenate with FR and assign as our CNAM value. ##### Example Request ``` @@ -1365,7 +1365,7 @@ NOTE: Newly created CNAM records need to be approved first before they can be as ``` #### associate_cnam(cnam_id, number_id) -The method accepts a CNAM record ID and a phone number as parameters which you can learn more about in the [API reference](https://developer.flowroute.com/api/cnams/v2.0/assign-cnam-record-to-phone-number/). In the following example, we will call `list_account_phone_numbers()` and associate the first number in the returned array with our previously assigned `cnam_id`. +The method accepts a CNAM record ID and a phone number as parameters which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/assign-cnam-record-to-phone-number/). In the following example, we will call `list_account_phone_numbers()` and associate the first number in the returned array with our previously assigned `cnam_id`. ##### Example Request ``` @@ -1391,7 +1391,7 @@ On success, the HTTP status code in the response header is `202 Accepted` and th ``` #### unassociate_cnam(number_id) -The method accepts a phone number as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/cnams/v2.0/unassign-a-cnam-record-from-phone-number/). In the following example, we will disassociate the same phone number that we've used in `associate_cnam()`. +The method accepts a phone number as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/unassign-a-cnam-record-from-phone-number/). In the following example, we will disassociate the same phone number that we've used in `associate_cnam()`. ##### Example Request ``` @@ -1411,7 +1411,7 @@ On success, the HTTP status code in the response header is `202 Accepted` and th ``` #### remove_cnam(cnam_id) -The method accepts a CNAM record ID as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/cnams/v2.0/remove-cnam-record-from-account/). In the following example, we will be deleting our previously extracted `cnam_id` from the "List Approved CNAM Records" function call. +The method accepts a CNAM record ID as a parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/remove-cnam-record-from-account/). In the following example, we will be deleting our previously extracted `cnam_id` from the "List Approved CNAM Records" function call. ##### Example Request ``` From 917a12edfd156e187d303984c30070f9955cdd8a Mon Sep 17 00:00:00 2001 From: Maria Bermudez Date: Thu, 21 Jun 2018 13:02:56 -0700 Subject: [PATCH 6/8] Remove duplicate messaging functions list --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 054e597..1ceee00 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,6 @@ The Flowroute Python Library v3 provides methods for interacting with [Numbers v * [unassociate_cnam](#unassociate_cnamnumber_id) * [remove_cnam](#remove_cnamcnam_id) - * [Messaging](#messaging) - * [send_a_message](#send_a_messagemessage_body) - * [look_up_a_set_of_messagesstart_date](#look_up_a_set_of_messagesstart_date) - * [look_up_a_message_detail_record](#look_up_a_message_detail_recordmessage_id) * [Errors](#errors) * [Testing](#testing) From 440446750e3927294452ad5b3a38026e4d3069df Mon Sep 17 00:00:00 2001 From: Chris Lacina Date: Fri, 22 Jun 2018 13:34:51 -0700 Subject: [PATCH 7/8] Make address_type and address_type_number available. --- e911_demo.py | 27 ++++++++++++++-- .../controllers/e911s_controller.py | 32 ++++++++++++++++--- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/e911_demo.py b/e911_demo.py index b88d575..0970e8a 100644 --- a/e911_demo.py +++ b/e911_demo.py @@ -42,7 +42,9 @@ try: city="Seattle", state="WA", country="US", - zipcode="98101") + zipcode="98101", + address_type="Suite", + address_type_number="600") pprint.pprint(result) except Exception as e: print(str(e)) @@ -59,7 +61,28 @@ try: city="Seattle", state="WA", 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) except Exception as e: print(str(e)) diff --git a/flowroutenumbersandmessaging/controllers/e911s_controller.py b/flowroutenumbersandmessaging/controllers/e911s_controller.py index a346cf2..c393d90 100644 --- a/flowroutenumbersandmessaging/controllers/e911s_controller.py +++ b/flowroutenumbersandmessaging/controllers/e911s_controller.py @@ -103,7 +103,9 @@ class E911sController(BaseController): city, state, country, - zipcode): + zipcode, + address_type=None, + address_type_number=None): """Does a POST request to /v2/e911s/validate. Returns a 204 No Content on success, or a 404 with error data @@ -118,6 +120,8 @@ class E911sController(BaseController): state (2 character string): country (string USA or Canada): zipcode (string postal code) + address_type (string address type) + address_type_number (string when address_type used, required) Returns: mixed: Response from the API. A 204 - No Content or a @@ -142,11 +146,15 @@ class E911sController(BaseController): 'city': city, 'state': state, '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 _query_builder = Configuration.base_uri _query_builder += '/v2/e911s/validate' @@ -175,7 +183,9 @@ class E911sController(BaseController): city, state, country, - zipcode): + zipcode, + address_type=None, + address_type_number=None): """Does a POST request to /v2/e911s. Creates an address record that can then be associated @@ -191,6 +201,8 @@ class E911sController(BaseController): state (2 character string): country (string USA or Canada): zipcode (string postal code) + address_type (string address type) + address_type_number (string required if address_type specified) Returns: mixed: Response from the API. A JSON object containing the new @@ -215,11 +227,15 @@ class E911sController(BaseController): 'city': city, 'state': state, '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 _query_builder = Configuration.base_uri _query_builder += '/v2/e911s' @@ -249,7 +265,9 @@ class E911sController(BaseController): city=None, state=None, country=None, - zipcode=None): + zipcode=None, + address_type=None, + address_type_number=None): """Does a PATCH request to /v2/e911s/. @@ -303,6 +321,10 @@ class E911sController(BaseController): record_data['data']['attributes']['zip'] = 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 if 'address_type' in record_data['data']['attributes'] and \ record_data['data']['attributes']['address_type'] == u'': From e3f6dc62ea681c2728ec42264d3e8bcc9996d3dd Mon Sep 17 00:00:00 2001 From: Maria Bermudez Date: Fri, 29 Jun 2018 09:12:46 -0700 Subject: [PATCH 8/8] Update E911 address to be validated --- README.md | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1ceee00..1d23310 100644 --- a/README.md +++ b/README.md @@ -947,7 +947,7 @@ On success, the HTTP status code in the response header is `200 OK` and the resp 'self': 'https://api.flowroute.com/v2/e911s?limit=2&offset=0'}} ``` -#### get\_e911(e911_id) +#### get\_e911(e911\_id) The method accepts an `e911_id` as a path parameter which you can learn more about in the [API reference](https://developer.flowroute.com/api/numbers/v2.0/list-e911-record-details/). @@ -971,20 +971,28 @@ On success, the HTTP status code in the response header is `200 OK` and the resp ``` --Get Details for a specific E911 Record -{'data': {'attributes': {'address_type': 'L', - 'address_type_number': '12', - 'city': 'Seattle', - 'country': 'USA', - 'first_name': 'Maria', - 'label': 'Example E911', - 'last_name': 'Bermudez', - 'state': 'WA', - 'street_name': '20th Ave SW', - 'street_number': '7742', - 'zip': '98106'}, - 'id': '20930', - 'links': {'self': 'https://api.flowroute.com/v2/e911s/20930'}, - 'type': 'e911'}} +{ + "data": { + "attributes": { + "address_type": "Suite", + "address_type_number": "333", + "city": "Seattle", + "country": "US", + "first_name": "Albus", + "label": "Office Space III", + "last_name": "Rasputin, Jr.", + "state": "WA", + "street_name": "Main St", + "street_number": "666", + "zip": "98101" + }, + "id": "21845", + "links": { + "self": "https://api.flowroute.com/v2/e911s/21845" + }, + "type": "e911" + } +} ``` #### validate_address(e911_attributes)