Skip to content

Design a mechanism to parse Personal Data Fields (PDF) from API responses for Cardholders using pydantic #1

@devraj

Description

@devraj

Gallagher's REST APIs return configurable fields (per instance of the server) called Personal Data Fields (PDFs). These are additional fields that are relevant to the organisation and are not common. These key of the fields are always prefixed with an @ symbol e.g @Student ID in an example from their docs:

{
  "href": "https://localhost:8904/api/cardholders/325",
  "id": "325",
  "firstName": "Algernon",
  "lastName": "Boothroyd",
  "shortName": "Q",
  "description": "Quartermaster",
  "authorised": true,
  "lastSuccessfulAccessTime": "2004-11-18T19:21:52Z",
  "lastSuccessfulAccessZone": {
    "href": "https://localhost:8904/api/access_zones/333",
    "name": "Twilight zone"
  },
  "serverDisplayName": "ruatoria.satellite.int",
  "division": {
    "href": "https://localhost:8904/api/divisions/2"
  },
  "@Student ID": "8904640"
}

We are using pyndatic schemas to parse the API response. The aim would be to use event based methods to dynamically parse these and make them available as a dictionary:

cardholder.pdfs["StudentId"]

for the API user to access these fields in a Pythonic manner.

Note that the response has a field called personalDataDefinitions which contains references to each one of the PDF definitions.

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationpending-releasePending release for the nexdt versiontestingRequires completing test cases

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions