Skip to content

Accessing Nested Resources #67

@lucasob

Description

@lucasob

Hey!

Not sure what people's opinions are here for implementing access to nested resources. One such example is the Spend Money Attachments: /{cf_uri}/Banking/SpendMoneyTxn/{Spend_Money_UID}/Attachment

The current implementation is fantastic and delightfully extensible for top-level resources, but doesn't make for easy implementation (at least to me) when querying nested resources.

Did anyone have any implementation ideas to get around this issue? I have one but it would involve a very large refactoring which isn't by any means ideal.

This idea would just centre around the below (using python-ish pseudocode)


MYOB_URL = "..."

def post<R>(url: str, body:R ): T
    return requests.post(url, body)
    
def get<T>(url: str) -> T:
    return requests.get(url)    


class SpendMoneyTxn:

    def get_attachments(self) -> SpendMoneyAttachment:
        return get(url=f"{MYOBURL}/Banking/SpendMoneyTxn/{self.id}/Atachment")
    

I am open to a way of trying to include the current managers but I'm not sure how that would look.

Thanks!

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