Closed vizvamitra closed 6 years ago
user_agent
method though. It seems like it belongs to a Client/API instance.@dmitry-mukhin nope, Uploadcare
module is just a namespace for other logics and API client is an instance of Uploadcare::Api
class.
The problem with this method is that it is public, and so it is a part of the gem's public interface. Every part of a public interface should be somehow useful for gem users, but how can this method be useful? I believe it was meant for internal usage only, was occasionally made public and now pollutes gem's public interface.
Same thing with Uploadcare::USER_AGENT
constant. Why would gem user ever want to use it in his code?
We don't need the constant.
But again, I think getUserAgent
(and/or setUserAgent
) semantically should be a method of Uploadcare::Api
class.
Agree that it shouldn't be just in the namespace
@dmitry-mukhin Uploadcare::API
's responsibility is to handle API calls. User-Agent is a lower-level detail and thus it belongs to a lower-level class. ApiConnection
/UploadConnection
classes that handle connection details and they are the two places where User-Agent header is actually being set, but the format of this header itself is an even more lower-level. I thought that it has enough logics in its own to create a class that'll encapsulate this logics.
Ideally an instance of this class should be injected into ApiConnection
/UploadConnection
during the initialization (as it is an external dependency), but it seems that this kind of design doesn't fit well to our current code.
@dmitry-mukhin check out the changes please
I believe nobody is using
Uploadcare::USER_AGENT
constant andUploadcare::user_agent
method, so I've deprecated them.I also think that I should backport this changes to uploadcare-ruby 1.x (updating patch version) so that uploadcare-rails 1.x users could get this update
Usage example: