-
Notifications
You must be signed in to change notification settings - Fork 7
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
version 4 installation with psr client #15
Comments
i don't see you explicitly using the curl client in any tests. if you remove the requirement, the discovery composer plugin should now automatically install a psr client if needed. oh, i tried this in the code and noticed you use the old httplug instead of psr18 client. HttpClientDiscovery is deprecated in favor of Psr18ClientDiscovery. |
Oh, thanks! I have fixed the dependency : 51101f2 It's not really easy to understand, I read an good but old article about in order to help me: https://madewithlove.com/blog/building-an-sdk-with-php-part-1/ |
yay, that looks right to me. the tutorial seems good to me, only unfortunately while it talks about Psr18 client, the code uses the old httplug discovery which likely is what mislead you. |
What do you think about these repetitions of |
I rewrote the code, but the API have a swagger, what do you recommend to generate the code? |
for the query: you could use the psr client directly and the psr17 request factory to build a request object. then you can use $request->withQueryParams. the HttpMethodsClient is a convenience wrapper but currently does not offer dedicated support for building the query string. for generating code from openapi spec, i used janephp once. the nice thing is that it builds you models for all the data. the not so nice thing is that the generated code is on the verbose side and if the openapi spec is not super nice the resulting sdk will also not be nice... |
Thanks, I think it's better to write my own code so...
Thanks for the help, but I think I don't get it... I tried not to use the ClientBuilder and Options class, but I missed something in the process.. My commit is here: 46728ff do you think you can help me? |
i don't think the http_build_query is bad, you asked about alternatives ;-) i think you would keep the structure the same with options and all, just change for the ClientInterface & the RequestFactoryInterface of psr17 (php-http/discovery has a Psr17FactoryDiscovery.php to find the request and uri factories). you then build the request with the factory, set the uri on it and have withQueryParams on that. the ClientInterface only has a method to send a request, no shortcuts like the HttpMethodsClient. but imho it was alright before, with the methods client. |
Ok, I changed to the ClientInterface in c305830 It's very interesting for me, I want to go further to understand it better but without a real example of code it's very difficult to understand 😲 |
the PluginClient is a decorator on the psr client, so you can return that one, to use the authentication middleware. when you look at ClientInterface, you can see that it only has the method i would create getter methods |
alternatively, you could do your own variant of the HttpMethodClient and use that in the application.
|
and analog methods for the other HTTP verbs that you use in the sdk. |
Hum, And VSCode tell me the same thing: |
oh damn, you are right. sorry about that - i did not look closely enough. sorry for the false trail, i think then the http_build_query really is the way to go. you could still do your own variant of client wrapper like i suggested in my comment above but have it use http_build_query and decorate the HttpMethodsClient (or you request factory, as you prefer) or you can just leave it as it was with the http_build_query in all the places. |
feat-v4 only is installable with the current instructions by "chance".
while the oauth2-client will probably always need a psr client, this is a rather indirect way. if you require php-http/discovery in your require section, the discovery plugin will install a client if none is already installed.
it should then also be possible to remove the require-dev for php-http/curl-client (unless you need specifically that one for mocking, i did not check that)
The text was updated successfully, but these errors were encountered: