Report generation based on constant parameters. Object oriented design

Viewed 15

I have to generate a report based on a given API. Each key-value pair in the API signifies a section in text report. Here is an example response from the API,

{
    "status": "active"
}

Now if the status is active in the API response then I have a hardcoded text to display in the report. If the status was inactive the text to display will be something different. Likewise there are around 20 such sections.

Here is my first approach. I am working in Python. My first instinct was to create a dict of all such values like for example

{
    "active" : "Text to display when status is active goes here",
    "inactive" : "Text to display when status is inactive goes here",
}

In case there are new sections that we want to add, we can add details in the dict.

Wanted to reach out to the community to understand what other solutions can we implement.

Thank you for your time.

0 Answers
Related