-
-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Is your feature request related to a problem? Please describe.
Personal Data Definition fields (PDFs) can contain binary data like images, the contents are downloadable by access the href of the value property which is different to the value being inline if the data is a primitive.
{
"@Photo": {
"definition": {
"id": "331",
"name": "Photo",
"type": "image"
},
"href": "https://commandcentre-api-au.security.gallagher.cloud/api/cardholders/186837/personal_data/331",
"value": {
"href": "https://commandcentre-api-au.security.gallagher.cloud/api/cardholders/186837/personal_data/331"
}
}
}The API does not provide a way to access the binary data that is accessible at the href
Describe the solution you'd like
Based on the good work done in #1 we should extend the API to provide a wrapper that calls the href and makes the contents available as bytes.
I don't think it's necessary for the API client to provide convenience methods to write to files or streams.
Proposed syntax:
binary_contents = cardholder.pdf.photo.contents()Describe alternatives you've considered
At the moment I am simply using httpx to construct a request to fetch that href URL, this does mean that I have to construct the client and then provide it authentication headers.
async with httpx.AsyncClient() as client:
# add the header "Authorization: GGL-API-KEY"
client.headers["Authorization"] = "GGL-API-KEY " + os.environ.get("GACC_API_KEY")
response = await client.get(str(cardholder.pdf.photo.value.href))Additional context