Skip to content

Commit

Permalink
Merge branch 'main' into usage-calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyKh committed Apr 16, 2024
2 parents 576904d + 95c7553 commit b9d2adf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions iec_api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,20 @@ async def get_invoice_pdf(
session, url=GET_INVOICE_PDF_URL, headers=headers, json_data=request
)
return await response.read()


async def get_invoice_pdf(
session: ClientSession, token: JWT, bp_number: int | str, contract_id: int | str, invoice_number: int | str
) -> bytes:
"""Get Device Type data response from IEC API."""
headers = commons.add_auth_bearer_to_headers(HEADERS_WITH_AUTH, token.id_token)
headers = headers.copy() # don't modify original headers
headers.update({"accept": "application/pdf", "content-type": "application/json"})

request = GetPdfRequest(
invoice_number=str(invoice_number), contract_id=str(contract_id), bp_number=str(bp_number)
).to_dict()
response = await commons.send_non_json_post_request(
session, url=GET_INVOICE_PDF_URL, headers=headers, json_data=request
)
return await response.read()
2 changes: 2 additions & 0 deletions iec_api/iec_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,11 @@ async def get_kwh_tariff(self) -> float:

return self._kwh_tariff


async def get_usage_calculator(self) -> UsageCalculator:
return await static_data.get_usage_calculator(self._session)


async def get_efs_messages(
self, contract_id: Optional[str] = None, service_code: Optional[int] = None
) -> Optional[List[EfsMessage]]:
Expand Down

0 comments on commit b9d2adf

Please sign in to comment.