Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedded resources in api result #91

Closed
blieb opened this issue Jun 24, 2020 · 1 comment
Closed

Embedded resources in api result #91

blieb opened this issue Jun 24, 2020 · 1 comment

Comments

@blieb
Copy link

blieb commented Jun 24, 2020

Hi,

I'm trying to understand if it is possible to get add related resources to response.

I do a request to the API to get messages, the response contains an array of the user that it posted id. simple example:

{
	"id": "36f23f2bc90d35f0",
	"created": "2020-06-24T09:27:40.217+00:00",
	"body": "This is a message",
	"user": {
		"id": 1,
		"name": "jan",
		"email": "test@test.com"
	}
}

is it possible some way that the user array transforms to a User resource inside the Message Resource? At the moment when I do $this->_transformResults($query->endpoint(), $messages); it will returns a MessageResource with an array instead of user resource.

@ADmad
Copy link
Member

ADmad commented Jun 24, 2020

Currently there's no support for associations so there's no way for the MessagesEndpoint to know that user array should be converted into User resource. You'll have to handle the conversion yourself, for e.g. in the Message resource class' constructor.

@ADmad ADmad closed this as completed Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants