Skip to content

Is there a way to have an attribute defined as a struct of some sort? #50

@joegaudet

Description

@joegaudet

I have a JSONAPI endpoint that returns nested value objects, such as a contact. Wondering if there's a way to express that here, or if jsonapi-requests only supports primitives?

Example:

class LogisticsDelivery(jsonapi_requests.orm.ApiModel):
    class Meta:
        type = 'logistics-deliveries'
        api = api

    contact = jsonapi_requests.orm.AttributeField('contact')

deliveries = LogisticsDelivery.get_list()
for delivery in deliveries:
    pprint(delivery.contact)

Which outputs

{'email': 'Vancouver_client@food.ee',
 'extension': None,
 'first-name': 'Vancouver',
 'last-name': 'Client',
 'phone-number': '+12122708174',
 'phone-type': 'none',
 'sms-number': '4797755354'}

What I'd love is to be able to define a data class that could wrap this dictionary in a real object, that would allow for getting / setting.

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