-
Notifications
You must be signed in to change notification settings - Fork 183
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
Simplify signature of the low-level API #341
Comments
Another point that I would like to improve is the "content type guessing" based on the path in the clients. In if ($this->isUploadCall($path)) { // (false !== strpos($path, '/uploads.json')) || (false !== strpos($path, '/uploads.xml'))
$httpHeaders[] = 'Content-Type: application/octet-stream';
} elseif ('json' === substr($tmp['path'], -4)) {
$httpHeaders[] = 'Content-Type: application/json';
} elseif ('xml' === substr($tmp['path'], -3)) {
$httpHeaders[] = 'Content-Type: text/xml';
} This method is very speculative and uncertain. The client should not make any assumptions about the request. Instead we should add a way to provide the content type via the Usage of the low-level API could then work like this: $response = $this->getHttpClient()->request(XmlRequest::put(
'/issues/' . $id . '.xml',
['issue' => $params],
));
$array = XmlSerializer::createFromString($response->getContent())->toArray(); |
At the moment we have these 7 methods to interact with the low-level API:
The first 4 methods will send a request to the server and save the response in the Client. The last 3 methods can now be used to get the response details. This has some downsides:
AbstractApi::retrieveData()
), only the latest response will be available in the client. This leads to possible race conditions: There is no way to guarantee, that the last response in Client really belongs to our request.Proposal
I propose to introduce a new
Request
containing the method, path, content type and body and a newResponse
interface, containing the status code, content type and body.The client methods could then simplified into one method.
The text was updated successfully, but these errors were encountered: