Class: Mitake::API::Base Private
- Inherits:
-
Object
- Object
- Mitake::API::Base
- Defined in:
- lib/mitake/api/base.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#execute ⇒ Net::HTTPResponse
private
Execute HTTP Request.
-
#initialize(path, params = {}) ⇒ Base
constructor
private
A new instance of Base.
-
#params ⇒ Hash
private
Return the request params.
- #request ⇒ Object private
-
#ssl? ⇒ TrueClass|FalseClass
private
Is the SSL request.
-
#uri ⇒ URI
private
The request URI.
Constructor Details
#initialize(path, params = {}) ⇒ Base
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Base.
16 17 18 19 |
# File 'lib/mitake/api/base.rb', line 16 def initialize(path, params = {}) @path = path @params = params end |
Instance Method Details
#execute ⇒ Net::HTTPResponse
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Execute HTTP Request
33 34 35 36 37 |
# File 'lib/mitake/api/base.rb', line 33 def execute Net::HTTP.start(uri.host, uri.port, use_ssl: ssl?) do |http| http.request request end end |
#params ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the request params
61 62 63 64 65 66 |
# File 'lib/mitake/api/base.rb', line 61 def params @params.merge( username: Mitake.credential.username, password: Mitake.credential.password ) end |
#request ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/mitake/api/base.rb', line 23 def request raise NotImplementedError, 'Request not defined!' end |
#ssl? ⇒ TrueClass|FalseClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns is the SSL request.
51 52 53 |
# File 'lib/mitake/api/base.rb', line 51 def ssl? @uri.scheme == 'https' end |
#uri ⇒ URI
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the request URI.
43 44 45 |
# File 'lib/mitake/api/base.rb', line 43 def uri @uri ||= URI("#{Mitake.credential.server}#{@path}") end |