def test_list_invoices_url(): from datetime import date, timedelta df = date(1970, 1, 1) dt = df + timedelta(days=30) req = Request().list(params=dict(date_from=df, date_to=dt, page=7)) res = req.execute(FakeHttpModule) assert req.data is None assert (GET, "https://www.ifirma.pl/iapi/faktury.json?typ=prz_faktura_kraj" "&dataOd=1970-01-01&dataDo=1970-01-31&strona=7&iloscNaStronie=20" ) == get_url(res)
import requests from pprint import pprint script_path = os.path.realpath(__file__) module_path = os.path.dirname(os.path.dirname(script_path)) sys.path.append(module_path) print("Module path: " + module_path) from ifirma.request import Request if __name__ == "__main__": date_from = date(2022, 1, 1) params = dict(date_from=date_from, date_to=date_from + timedelta(days=30)) req = Request().list(params) resp = req.execute(requests) resp.raise_for_status() invoices_json = resp.json()['response'] pprint(invoices_json) if invoices_json['Kod'] == 0 and invoices_json['Wynik']: invoice_id = invoices_json['Wynik'][0]['FakturaId'] print(f"\nDetails of the invoice id: {invoice_id}\n") req = Request().get(invoice_id) resp = req.execute(requests) resp.raise_for_status() pprint(resp.json())