From eb3a578ebb914720583ad5c6140e3a38619f1acf Mon Sep 17 00:00:00 2001 From: Joshua Decosta Date: Tue, 1 Dec 2020 20:49:37 -0500 Subject: [PATCH 1/5] init --- mycity/mycity/intents/trash_intent.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mycity/mycity/intents/trash_intent.py b/mycity/mycity/intents/trash_intent.py index c76f27d..f5a974f 100644 --- a/mycity/mycity/intents/trash_intent.py +++ b/mycity/mycity/intents/trash_intent.py @@ -247,7 +247,9 @@ def get_address_api_info(address, neighborhood): 'service_id': value, 'place_id': value, 'area_id': value, - 'name': value + 'name': value, + 'start_date': value, + 'end_date': value } """ @@ -273,6 +275,8 @@ def get_address_api_info(address, neighborhood): if len(unique_addresses) > 1: raise MultipleAddressError(unique_addresses) + api_params = result_json[0] + api_params['start_date'] = return result_json[0] @@ -288,7 +292,7 @@ def get_trash_day_data(api_parameters): if "name" in api_parameters: api_parameters["formatted_address"] = api_parameters.pop("name") - base_url = "https://recollect.net/api/places" + base_url = "https://api.recollect.net/api/places/{}/services/{}/events" request_result = requests.get(base_url, api_parameters) if request_result.status_code != requests.codes.ok: From e8e8eba04bfc6f7cbb1c89639a7c2f74129bff21 Mon Sep 17 00:00:00 2001 From: Joshua Decosta Date: Tue, 5 Jan 2021 19:41:30 -0500 Subject: [PATCH 2/5] updates --- hooks/build.sh | 0 mycity/run_tests.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 hooks/build.sh mode change 100755 => 100644 mycity/run_tests.sh diff --git a/hooks/build.sh b/hooks/build.sh old mode 100755 new mode 100644 diff --git a/mycity/run_tests.sh b/mycity/run_tests.sh old mode 100755 new mode 100644 From 14b0070e057e7e64e61ac42b3fc66a51f9fb677c Mon Sep 17 00:00:00 2001 From: Joshua Decosta Date: Tue, 19 Jan 2021 20:24:02 -0500 Subject: [PATCH 3/5] adds basic request --- mycity/mycity/intents/trash_intent.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mycity/mycity/intents/trash_intent.py b/mycity/mycity/intents/trash_intent.py index f5a974f..7654d8d 100644 --- a/mycity/mycity/intents/trash_intent.py +++ b/mycity/mycity/intents/trash_intent.py @@ -262,7 +262,7 @@ def get_address_api_info(address, neighborhood): url_params = {'q': full_address, 'locale': 'en-US'} request_result = requests.get(base_url, url_params) - if request_result.status_code != requests.codes.ok: + if request_result.status_code != 200: logger.debug('Error getting ReCollect API info. Got response: {}' .format(request_result.status_code)) return {} @@ -276,7 +276,6 @@ def get_address_api_info(address, neighborhood): raise MultipleAddressError(unique_addresses) api_params = result_json[0] - api_params['start_date'] = return result_json[0] @@ -295,7 +294,7 @@ def get_trash_day_data(api_parameters): base_url = "https://api.recollect.net/api/places/{}/services/{}/events" request_result = requests.get(base_url, api_parameters) - if request_result.status_code != requests.codes.ok: + if request_result.status_code != 200: logger.debug("Error getting trash info from ReCollect API info. " \ "Got response: {}".format(request_result.status_code)) return {} From 2619ad5b3b16ae8f19baa864e31a348d486a245f Mon Sep 17 00:00:00 2001 From: Joshua Decosta Date: Tue, 19 Jan 2021 20:25:16 -0500 Subject: [PATCH 4/5] 775 for build.sh --- hooks/build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 hooks/build.sh diff --git a/hooks/build.sh b/hooks/build.sh old mode 100644 new mode 100755 From 5f7ae859f3c6121dcd89790fba16c45f4a4db7c7 Mon Sep 17 00:00:00 2001 From: Joshua Decosta Date: Tue, 26 Jan 2021 20:04:32 -0500 Subject: [PATCH 5/5] somewhat working --- mycity/mycity/intents/trash_intent.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mycity/mycity/intents/trash_intent.py b/mycity/mycity/intents/trash_intent.py index 7654d8d..90ff697 100644 --- a/mycity/mycity/intents/trash_intent.py +++ b/mycity/mycity/intents/trash_intent.py @@ -275,7 +275,6 @@ def get_address_api_info(address, neighborhood): if len(unique_addresses) > 1: raise MultipleAddressError(unique_addresses) - api_params = result_json[0] return result_json[0] @@ -287,11 +286,14 @@ def get_trash_day_data(api_parameters): :return: JSON object containing all trash data """ logger.debug('api_parameters: ' + str(api_parameters)) + api_parameters["after"] = '2020-01-02' + api_parameters["before"] = '2020-12-02' # Rename the default API parameter "name" to "formatted_address" if "name" in api_parameters: api_parameters["formatted_address"] = api_parameters.pop("name") - base_url = "https://api.recollect.net/api/places/{}/services/{}/events" + base_url = "https://api.recollect.net/api/places/{}/services/{}/events" \ + .format(api_parameters['place_id'], api_parameters['service_id']) request_result = requests.get(base_url, api_parameters) if request_result.status_code != 200: