Class: Zonomi::API::Request
- Inherits:
-
Object
- Object
- Zonomi::API::Request
- Defined in:
- lib/zonomi/api/request.rb
Constant Summary collapse
- REQUEST_METHOD =
:get
- RESULT_KEY =
'dnsapi_result'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Request
constructor
A new instance of Request.
- #send! ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Request
Returns a new instance of Request.
10 11 12 13 14 15 16 17 |
# File 'lib/zonomi/api/request.rb', line 10 def initialize(params = {}) @params = params @client = @params.delete(:client) @request_path = @params.delete(:request_path) @response = nil @result = nil self end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/zonomi/api/request.rb', line 8 def client @client end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/zonomi/api/request.rb', line 8 def params @params end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
8 9 10 |
# File 'lib/zonomi/api/request.rb', line 8 def response @response end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
8 9 10 |
# File 'lib/zonomi/api/request.rb', line 8 def result @result end |
Instance Method Details
#send! ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/zonomi/api/request.rb', line 19 def send! request_params = [ REQUEST_METHOD, path_for(*@request_path), { query: prepare(@params) } ] @response = self.client.class.send(*request_params) @result = Result.new(@response[RESULT_KEY]) self end |