Last active
June 9, 2020 18:20
-
-
Save ottomata/c677df2965bf4e9c82699321326dc8ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_all_schedule_b_results( | |
committee_id=['C00618389', 'C00637512'], | |
sort='-disbursement_date', | |
two_year_transaction_period=[2018, 2020] | |
): | |
""" | |
Gets all paginated results of schedule b results for the given parameters. | |
The returned value will be the list of all result object records. | |
""" | |
last_index = None | |
results = [] | |
is_last_page = False | |
while not is_last_page: | |
try: | |
api_response = disbursements_api.schedules_schedule_b_get( | |
api_key, | |
committee_id=committee_id, | |
sort=sort, | |
two_year_transaction_period=two_year_transaction_period, | |
last_index=last_index | |
) | |
except ApiException as e: | |
print("Exception when calling DisbursementsApi->schedules_schedule_b_get: %s\n" % e) | |
api_response_dict = api_response.to_dict() | |
is_last_page = api_response_dict[....] | |
last_index = api_response_dict['pagination']['last_indexes']['last_index'] | |
results += api_response_dict['results'] | |
return results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment