Class: RubyLokaliseApi::Endpoints::BaseEndpoint
- Inherits:
-
Object
- Object
- RubyLokaliseApi::Endpoints::BaseEndpoint
- Includes:
- Request
- Defined in:
- lib/ruby_lokalise_api/endpoints/base_endpoint.rb
Direct Known Subclasses
Constant Summary collapse
- BASE_URL =
''
- PARTIAL_URI_TEMPLATE =
'{/segments*}'
- HTTP_METHODS =
%i[get post put delete patch].freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#req_params ⇒ Object
readonly
Returns the value of attribute req_params.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #base_url ⇒ Object
- #full_uri ⇒ Object
-
#initialize(client, params = {}) ⇒ BaseEndpoint
constructor
A new instance of BaseEndpoint.
- #reinitialize(query_params: nil, req_params: {}) ⇒ Object
Methods included from Request
#delete, #get, #patch, #post, #put
Methods included from Connection
Methods included from JsonHandler
Constructor Details
#initialize(client, params = {}) ⇒ BaseEndpoint
Returns a new instance of BaseEndpoint.
15 16 17 18 19 20 |
# File 'lib/ruby_lokalise_api/endpoints/base_endpoint.rb', line 15 def initialize(client, params = {}) @query_params = params[:query].to_array @client = client @req_params = params[:req] @uri = nil end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/ruby_lokalise_api/endpoints/base_endpoint.rb', line 9 def client @client end |
#req_params ⇒ Object (readonly)
Returns the value of attribute req_params.
9 10 11 |
# File 'lib/ruby_lokalise_api/endpoints/base_endpoint.rb', line 9 def req_params @req_params end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/ruby_lokalise_api/endpoints/base_endpoint.rb', line 9 def uri @uri end |
Instance Method Details
#base_url ⇒ Object
30 31 32 |
# File 'lib/ruby_lokalise_api/endpoints/base_endpoint.rb', line 30 def base_url self.class::BASE_URL end |
#full_uri ⇒ Object
34 35 36 |
# File 'lib/ruby_lokalise_api/endpoints/base_endpoint.rb', line 34 def full_uri base_url + uri.to_s end |
#reinitialize(query_params: nil, req_params: {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/ruby_lokalise_api/endpoints/base_endpoint.rb', line 22 def reinitialize(query_params: nil, req_params: {}) @query_params = query_params || @query_params @req_params = req_params || @req_params @uri = partial_uri(base_query(*@query_params)) self end |