You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having a dataMapper type method would be a nice to have. I'm having to work with a janky API which doesn't have consistency in it's results. It also is quiet generic and just returns 'data' without any description of what I'm getting back. Having a 'dataMapper' option to trigger a function/callable to iterate over the results mapping the key->values would be a way to do this. I've been able to wire this up using Guzzle Middleware::mapResponse(). However, I can't find an easy way to inject this sort of behavior based on the service/operation being called. I've got a pile of code working by overriding the ServiceClient->__call() method which seeks out the description->command->config.. which I've added an extra array element 'dataMapper' => 'App\Name\Space' and then dynamically instantiate it in the __call() method. It's an ugly ugly hack at best. Suggestions?
The text was updated successfully, but these errors were encountered:
Take a look at #138, @danizord had an interesting approach using a filter (e66162a) and @Konafetsposted an example of an own command client implementation where the result gets wrapped by your own custom object, which could handle your data mapping.
I'm currently implementing my own data mapper based on a custom \GuzzleHttp\Command\Guzzle\Deserializer.
My current solution is much like what @Konafets did but with the mapper defined in the service config array. It'd be nice if the 'model' configuration would instantiate an actual 'type' object. Then you could define all your result models and they'd be assignable.
Having a dataMapper type method would be a nice to have. I'm having to work with a janky API which doesn't have consistency in it's results. It also is quiet generic and just returns 'data' without any description of what I'm getting back. Having a 'dataMapper' option to trigger a function/callable to iterate over the results mapping the key->values would be a way to do this. I've been able to wire this up using Guzzle Middleware::mapResponse(). However, I can't find an easy way to inject this sort of behavior based on the service/operation being called. I've got a pile of code working by overriding the ServiceClient->__call() method which seeks out the description->command->config.. which I've added an extra array element 'dataMapper' => 'App\Name\Space' and then dynamically instantiate it in the __call() method. It's an ugly ugly hack at best. Suggestions?
The text was updated successfully, but these errors were encountered: