Skip to content

Enums are Iterators so when Entity.to_dict() is called, all possible values get serialized. #98

@aayushchhabra1999

Description

@aayushchhabra1999

Describe the bug

PaddleStrEnum is implemented as an Iterator. So when to_dict is called on any instance of Entity (any class inheriting from Entity), all possible values of the enum field get serialized instead of serializing the current value of the enum in the instance.

The goal behavior should be serializing the current value of the field (which is exposed as to_json()) on the Enum.

The current workaround is that we have to loop through all the fields on any entity and manually call the to_json for Enum fields which defeats a large purpose of using the SDK.

Steps to reproduce

  1. Call to_dict on a Subscription or SubscriptionCreated instance.
  2. You will see all currency codes getting listed instead of the currency code of the instance.
Image

Expected behavior

The goal behavior should be serializing the current value of the enum fields (which is exposed as to_json() on the Enum)

Code snippets

Python version

Python 3.11

SDK version

paddle-python-sdk 1.6.0

API version

Paddle Version 1

Additional context

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions