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

Question? #23

Closed
GrahamCampbell opened this issue Jun 2, 2014 · 4 comments
Closed

Question? #23

GrahamCampbell opened this issue Jun 2, 2014 · 4 comments

Comments

@GrahamCampbell
Copy link
Member

Is there an easy way to add custom transformers to yield objects other than Command\Model? I know I can use events, but that would be a bit hacky if I am using Services\Description. For example, if I were to do this:

$description = new Description([
    'baseUrl' => 'http://127.0.0.1:8080/',
    'operations' => [
        'users' => [
            'httpMethod' => 'GET',
            'uri' => '/api/users',
            'responseModel' => 'users'
        ]
    ],
    'models' => [
        'users' => [
            'type' => 'object',
            'additionalProperties' => [
                'location' => 'json'
            ]
        ]
    ]
]);

I'd like to be able to return a collection of users, not a "Model".

I hope I'm not missing something obvious. I'm fairly new to guzzle.

@mtdowling
Copy link
Member

This is not part of Guzzle services as Guzzle services is meant to describe web services to serialize requests from command objects and to parse responses into Model objects. It sounds like you need to use Guzzle's parsing logic based on the service description, but you want to take the result of parsing with the description and put it into a custom Collection type object. This is exactly what the Guzzzle/command project (what this project is based on) was designed to be able to handle. Just add event listeners to the command that are registered after Guzzle parses the response using the service description that injects a custom result value.

@GrahamCampbell
Copy link
Member Author

Thanks! I guess when the aws sdk 3.0 gets onto github, I'll be able to take a look at how guzzle 4 is used in there. I assume that's months away yet though...

@mtdowling
Copy link
Member

Definitely. We are using the event system to inject custom model objects based (actually using a completely different service description). Stay tuned!

@GrahamCampbell
Copy link
Member Author

Looking forward to it. Thanks.

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