Class: Webceo::Api::Request
- Inherits:
-
Object
- Object
- Webceo::Api::Request
- Defined in:
- lib/webceo/api/request.rb
Overview
Class Request provides wrapper for the request parameters for the api call to be made It also provides a to_json method to build the JSON format request to be sent as the body for the API call
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
Instance Method Summary collapse
-
#initialize(method_name, data = {}) ⇒ Request
constructor
Initializes a Request instance for use in our Client.
-
#to_json ⇒ JSON
This method returns a JSON format of the complete request to be sent to the Webceo API server.
Constructor Details
#initialize(method_name, data = {}) ⇒ Request
Initializes a Request instance for use in our Client
19 20 21 22 |
# File 'lib/webceo/api/request.rb', line 19 def initialize(method_name, data = {}) @method_name = method_name @data = data.with_indifferent_access end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
11 12 13 |
# File 'lib/webceo/api/request.rb', line 11 def data @data end |
#method_name ⇒ Object
Returns the value of attribute method_name.
11 12 13 |
# File 'lib/webceo/api/request.rb', line 11 def method_name @method_name end |
Instance Method Details
#to_json ⇒ JSON
This method returns a JSON format of the complete request to be sent to the Webceo API server
It also appends the api_key necessary for the API call to be successfull
33 34 35 36 37 38 39 40 |
# File 'lib/webceo/api/request.rb', line 33 def to_json MultiJson.dump({ method: @method_name.to_s, key: Webceo.configuration.api_key, id: @data[:id], data: @data }) end |