Class: Sendowl::Request
- Inherits:
-
Object
- Object
- Sendowl::Request
- Defined in:
- lib/sendowl/request.rb
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'Content-Type' => 'application/json; charset=utf8', 'Accept' => 'application/json', 'User-Agent' => "sendowl-ruby/#{Sendowl::VERSION}" }
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
Returns the value of attribute method.
-
#model ⇒ Object
Returns the value of attribute model.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#path ⇒ Object
Returns the value of attribute path.
-
#query ⇒ Object
Returns the value of attribute query.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(path, method, model, options = {}) ⇒ Request
constructor
A new instance of Request.
- #run ⇒ Object
Constructor Details
#initialize(path, method, model, options = {}) ⇒ Request
Returns a new instance of Request.
15 16 17 18 19 20 21 22 |
# File 'lib/sendowl/request.rb', line 15 def initialize(path, method, model, ={}) @path = path @method = method @model = model @parameters = [:params] || {} @query = [:query] || {} @headers = [:headers] || {} end |
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
7 8 9 |
# File 'lib/sendowl/request.rb', line 7 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
7 8 9 |
# File 'lib/sendowl/request.rb', line 7 def method @method end |
#model ⇒ Object
Returns the value of attribute model.
7 8 9 |
# File 'lib/sendowl/request.rb', line 7 def model @model end |
#parameters ⇒ Object
Returns the value of attribute parameters.
7 8 9 |
# File 'lib/sendowl/request.rb', line 7 def parameters @parameters end |
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/sendowl/request.rb', line 7 def path @path end |
#query ⇒ Object
Returns the value of attribute query.
7 8 9 |
# File 'lib/sendowl/request.rb', line 7 def query @query end |
Instance Method Details
#call ⇒ Object
29 30 31 |
# File 'lib/sendowl/request.rb', line 29 def call model.parse run end |
#run ⇒ Object
24 25 26 27 |
# File 'lib/sendowl/request.rb', line 24 def run response = RestClient::Request.execute request_params JSON.parse response.body end |