Skip to content

Commit

Permalink
added pdf and png downloads for abha card
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar committed Jul 5, 2023
1 parent 5af1584 commit 5205e18
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 10 additions & 3 deletions care/abdm/api/viewsets/healthid.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,17 @@ def get_abha_card(self, request):
if not patient.abha_number:
raise ValidationError({"abha": "Patient hasn't linked thier abha"})

response = HealthIdGateway().get_abha_card_png(
{"refreshToken": patient.abha_number.refresh_token}
)
if data["type"] == "png":
response = HealthIdGateway().get_abha_card_png(
{"refreshToken": patient.abha_number.refresh_token}
)
return Response(response, status=status.HTTP_200_OK)

response = HealthIdGateway().get_abha_card_pdf(
{"refreshToken": patient.abha_number.refresh_token}
)
return Response(response, status=status.HTTP_200_OK)


@swagger_auto_schema(
# /v1/registration/aadhaar/searchByHealthId
Expand Down
11 changes: 10 additions & 1 deletion care/abdm/utils/api_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,16 @@ def get_abha_card_png(self, data):
path = "/v1/account/getPngCard"
access_token = self.generate_access_token(data)
response = self.api.get(path, {}, access_token)
return response

return b64encode(response.content)

def get_abha_card_pdf(self, data):
path = "/v1/account/getCard"
access_token = self.generate_access_token(data)
response = self.api.get(path, {}, access_token)

return b64encode(response.content)


# /v1/account/qrCode
def get_qr_code(self, data, auth):
Expand Down

0 comments on commit 5205e18

Please sign in to comment.