Skip to content

Adding additional_transaction_information to the Event object #148

Closed
@haijeploeg

Description

@haijeploeg

I want to be able to lookup the category of an event. In the raw json the additional_transaction_information is available, but it is not in the serialized object.

Steps to reproduce:

pagination = Pagination()
pagination.count = 200
events = endpoint.Event.list(params=pagination.url_params_count_only)

for event in events.value:
    print(dir(event))

This will print:

['_BunqModel__STRING_FORMAT_EMPTY', '_BunqModel__STRING_FORMAT_FIELD_FOR_REQUEST_ONE_UNDERSCORE', '_BunqModel__STRING_FORMAT_FIELD_FOR_REQUEST_TWO_UNDERSCORE', '_ENDPOINT_URL_LISTING', '_ENDPOINT_URL_READ', '_FIELD_ID', '_FIELD_PAGINATION', '_FIELD_RESPONSE', '_FIELD_UUID', '_INDEX_FIRST', '_OBJECT_TYPE_GET', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_action', '_additional_transaction_information', '_created', '_determine_monetary_account_id', '_determine_user_id', '_from_json', '_from_json_array_nested', '_from_json_list', '_get_api_context', '_id_', '_monetary_account_id', '_object_', '_process_for_id', '_process_for_uuid', '_remove_field_for_request', '_status', '_unwrap_response_single', '_updated', '_user_id', 'action', 'created', 'from_json', 'get', 'id_', 'is_all_field_none', 'list', 'monetary_account_id', 'object_', 'status', 'to_json', 'updated', 'user_id']

What should happen:

An Object returning containing the additional_transaction_information key.

What happens:

Right now there is no additional_transaction_information key in the object that is being returned. I also cannot get the full raw json that the api returned, only the json that is converted.

SDK version and environment

  • Tested on 1.14.1
  • Sandbox
  • Production

Response id

  • Response id:

Extra info:

I have been playing with the code to add the additional_transaction_information key as a value property of the Event class, but I can't get it to work. I don't quite understand how the code is magically adding values. I someone can explain that to me I can possibly do a pull request regarding this issue. Also, is there any possible way (without creating a custom class) to get the full raw json? Right now I am using the code below to get the raw response.

class CustomEvent(BunqModel):
    # Endpoint constants.
    _ENDPOINT_URL_READ = "user/{}/event/{}"
    _ENDPOINT_URL_LISTING = "user/{}/event"

    # Object type.
    _OBJECT_TYPE_GET = "Event"

    _id_ = None
    _created = None
    _updated = None
    _action = None
    _user_id = None
    _monetary_account_id = None
    _object_ = None
    _status = None

    @classmethod
    def list(cls, params=None, custom_headers=None):
        if params is None:
            params = {}

        if custom_headers is None:
            custom_headers = {}

        api_client = ApiClient(cls._get_api_context())
        endpoint_url = cls._ENDPOINT_URL_LISTING.format(cls._determine_user_id())
        response_raw = api_client.get(endpoint_url, params, custom_headers)

        return response_raw

if __name__ == '__main__':
    apiContext = ApiContext.create(ENVIRONMENT_TYPE, API_KEY, DEVICE_DESCRIPTION)
    apiContext.save(API_CONTEXT_FILE_PATH)
    BunqContext.load_api_context(apiContext)

    pagination = Pagination()
    pagination.count = 200
    events = CustomEvent.list(params=pagination.url_params_count_only)

    my_json = events.body_bytes.decode('utf8').replace("'", '"')
    data = json.loads(my_json)
    s = json.dumps(data, indent=4, sort_keys=True)
    print(s)

Can anyone help me out? Thanks!

Regards,

Haije

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