Class: Spear::Request
- Inherits:
-
Object
- Object
- Spear::Request
- Extended by:
- ActiveModel::Callbacks
- Includes:
- HTTParty
- Defined in:
- lib/spear/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#method ⇒ Object
Returns the value of attribute method.
-
#query ⇒ Object
Returns the value of attribute query.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(method, endpoint, params = {}) ⇒ Request
constructor
params: => {, :query => {}}.
Constructor Details
#initialize(method, endpoint, params = {}) ⇒ Request
params: => {, :query => {}}
18 19 20 21 22 23 24 25 |
# File 'lib/spear/request.rb', line 18 def initialize(method, endpoint, params={}) @method = method @query = params[:query] || {} @body = params[:body] || {} @header = params[:header] || {} @api_options = params[:api_options] || {} @url = Spear.base_uri + endpoint end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
15 16 17 |
# File 'lib/spear/request.rb', line 15 def body @body end |
#method ⇒ Object
Returns the value of attribute method.
15 16 17 |
# File 'lib/spear/request.rb', line 15 def method @method end |
#query ⇒ Object
Returns the value of attribute query.
15 16 17 |
# File 'lib/spear/request.rb', line 15 def query @query end |
#url ⇒ Object
Returns the value of attribute url.
15 16 17 |
# File 'lib/spear/request.rb', line 15 def url @url end |
Instance Method Details
#execute ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/spear/request.rb', line 27 def execute run_callbacks(:execute) { response = exec begin self.api_response = response rescue NoMethodError => e # if we don't use save api info plugin, it'll throw NoMethodError. response end } end |