anomaly / anomaly/gallagher

Provide a convenience wrapper for downloading contents such as images from Personal Data Definitions

オープン
#92 コメント 0 件 リアクション 0 件 担当者 1 名 @devraj が担当を希望しています GitHub で見る
enhancement
主要言語
Python
スター
17
フォーク
2
PR マージ指標
30日以内にマージされた PR はありません

説明

**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.

```json
{
"@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:
```python
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.

```python
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**

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。