Giter Club home page Giter Club logo

Comments (1)

rikvermeer avatar rikvermeer commented on September 21, 2024

@classmethod BunqModel._from_json_list assumes that the endpoint name is the same as the model name.
This does not work for the "abstract" type NotificationFilterUrl which can be loaded from multiple endpoints (NotificationFilterUrlUser, NotificationFilterUrlMonetaryAccount)

item_unwrapped in BunqModel._from_json_list needs to be deserialized to NotificationFilterUrl (wrapper) when cls is NotificationFilterUrlUser or NotificationFilterUrlMonetaryAccount

# bunq/sdk/model/core/bunq_model.py:56
@classmethod
    def _unwrap_response_single(cls,
                                obj: Dict,
                                wrapper: str = None)
...

# bunq/sdk/model/core/bunq_model.py:60
         if wrapper is not None:
            return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST][wrapper]
            from bunq.sdk.model.generated.endpoint import NotificationFilterUrlUser, NotificationFilterUrlMonetaryAccount
            if cls == NotificationFilterUrlUser or cls == NotificationFilterUrlMonetaryAccount:
                return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST]['NotificationFilterUrl']
            else:
                return obj[cls._FIELD_RESPONSE][cls._INDEX_FIRST][wrapper]

# bunq/sdk/model/core/bunq_model.py:91
@classmethod
    def _from_json_list(cls,
                        response_raw: BunqResponseRaw,
                        wrapper: str = None)
...
# bunq/sdk/model/core/bunq_model.py:102
      for item in array:
         item_unwrapped = item if wrapper is None else item[wrapper]

         # item_unwrapped needs to be deserialized to NotificationFilterUrl (wrapper) 
            #   when cls is NotificationFilterUrlUser or NotificationFilterUrlMonetaryAccount
            if wrapper=='NotificationFilterUrl':
                from bunq.sdk.model.generated.endpoint import NotificationFilterUrlUser, NotificationFilterUrlMonetaryAccount
                from bunq.sdk.model.generated.object_ import NotificationFilterUrl
                if cls == NotificationFilterUrlUser or cls == NotificationFilterUrlMonetaryAccount:
                    cls_orig = cls
                    cls = NotificationFilterUrl
                    #print(f'NotificationFilterUrlUser deserialization, changing cls from: {cls_orig} to: {cls}')
                    #TODO: Test deserialize for NotificationFilterUrlUser and NotificationFilterUrlMonetaryAccount

Please see:
e4fecd8

from sdk_python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.