Class: Lagotto::BasicRequest
- Inherits:
-
Object
- Object
- Lagotto::BasicRequest
- Defined in:
- lib/lagotto-rb/req.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#addargs ⇒ Object
Returns the value of attribute addargs.
-
#key ⇒ Object
Returns the value of attribute key.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
-
#url ⇒ Object
Returns the value of attribute url.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(url, path, key, options, verbose, addargs) ⇒ BasicRequest
constructor
A new instance of BasicRequest.
- #perform ⇒ Object
Constructor Details
#initialize(url, path, key, options, verbose, addargs) ⇒ BasicRequest
Returns a new instance of BasicRequest.
16 17 18 19 20 21 22 23 24 |
# File 'lib/lagotto-rb/req.rb', line 16 def initialize(url, path, key, , verbose, addargs) self.url = url self.path = path self.key = key self. = self.verbose = verbose self.addargs = addargs end |
Instance Attribute Details
#addargs ⇒ Object
Returns the value of attribute addargs.
14 15 16 |
# File 'lib/lagotto-rb/req.rb', line 14 def addargs @addargs end |
#key ⇒ Object
Returns the value of attribute key.
11 12 13 |
# File 'lib/lagotto-rb/req.rb', line 11 def key @key end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/lagotto-rb/req.rb', line 12 def end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/lagotto-rb/req.rb', line 10 def path @path end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/lagotto-rb/req.rb', line 9 def url @url end |
#verbose ⇒ Object
Returns the value of attribute verbose.
13 14 15 |
# File 'lib/lagotto-rb/req.rb', line 13 def verbose @verbose end |
Instance Method Details
#perform ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/lagotto-rb/req.rb', line 26 def perform args = { api_key: self.key } args = args.merge(addargs) opts = args.delete_if { |k, v| v.nil? } if verbose conn = Faraday.new(:url => self.url, :request => ) do |f| f.response :logger f.headers['Accept'] = 'application/json' f.adapter Faraday.default_adapter end else conn = Faraday.new(:url => self.url, :request => ) do |f| f.headers['Accept'] = 'application/json' f.adapter Faraday.default_adapter end end res = conn.get self.path, opts return MultiJson.load(res.body) end |