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

Fix type of "load_relations" param #8

Merged
merged 2 commits into from
Feb 11, 2017
Merged

Conversation

danizord
Copy link
Collaborator

Hey @bakura10!

When trying to make a request loadnig additional relations, I got this error:

Validation errors: [load_relations] must be of type array

So this PR changes the descriptors to make "load_relations" a string (since json_encode transforns the array in string).

But unfortunately this does not fix my problem at all. Now I'm getting a 400 response because Guzzle is serializing the load_relations value like that: load_relations=%22%5B%5C%22Contact%5C%22%5D%22.
And Lighstpeed Retail API expects load_relations=["Contact"]. How can I tell Guzzle to serialize the value without encoding it?

@bakura10
Copy link
Member

Hmmm... their serialization model is strange. It's not really an array (whcih should be load_relations[]="Contact") nor a string. It's really ugly but maybe you could try set it up as a string, remove the json_encode, and do that:

$client->foo('load_relations' => '["Contact"]');

Maybe you can try to use the $commandToRequest serializer (https://github.com/guzzle/guzzle-services/blob/master/src/GuzzleClient.php#L38) to decode the request ?

Or you can maybe try to use a custom query serializer: https://github.com/guzzle/guzzle-services/blob/master/src/QuerySerializer/QuerySerializerInterface.php ?

@danizord
Copy link
Collaborator Author

danizord commented Feb 11, 2017

Ok, I'm taking the easy path for now and removing the json_encode filter. Opened #9 to fix that properly later.

Mergeable? :)

@bakura10 bakura10 merged commit fe32e49 into master Feb 11, 2017
@danizord danizord deleted the hotfix/load-relations-string branch February 11, 2017 21:08
@danizord
Copy link
Collaborator Author

Meh, that does not fix the issue neither. Still serializing to load_relations=%22%5B%5C%22Contact%5C%22%5D%22.

Seems like we'll need to use a custom QuerySerializer anyway. I'll make a PR tomorrow.

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

Successfully merging this pull request may close these issues.

2 participants