Skip to content

How to load all the Invoices with Utils

Daniel edited this page Mar 30, 2022 · 1 revision
    from ad_api.api import Invoices
    from ad_api.base import Marketplaces
    from ad_api.base import Utils
    @Utils.load_all_pages(throttle_by_seconds=1, next_token_param="cursor")
    def get_list_invoices(**kwargs):
        return Invoices(account=store, marketplace=marketplace).list_invoices(**kwargs)
    bill_status = 'PAID_IN_FULL'
    for page in get_list_invoices(invoiceStatuses=bill_status):
        res = page.payload
        payload = res.get("payload")
        invoice_summaries = payload.get("invoiceSummaries")
        for invoice in invoice_summaries:
            logging.info(invoice)
Clone this wiki locally