Skip to content

Instantly share code, notes, and snippets.

@ottomata
Last active June 9, 2020 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ottomata/c677df2965bf4e9c82699321326dc8ef to your computer and use it in GitHub Desktop.
Save ottomata/c677df2965bf4e9c82699321326dc8ef to your computer and use it in GitHub Desktop.
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