Class: Lagotto::Request
- Inherits:
-
Object
- Object
- Lagotto::Request
- Defined in:
- lib/lagotto-rb/request.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#ids ⇒ Object
Returns the value of attribute ids.
-
#info ⇒ Object
Returns the value of attribute info.
-
#key ⇒ Object
Returns the value of attribute key.
-
#options ⇒ Object
Returns the value of attribute options.
-
#order ⇒ Object
Returns the value of attribute order.
-
#page ⇒ Object
Returns the value of attribute page.
-
#path ⇒ Object
Returns the value of attribute path.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#publisher ⇒ Object
Returns the value of attribute publisher.
-
#source ⇒ Object
Returns the value of attribute source.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(url, path, ids, type, source, publisher, order, per_page, page, key, options, verbose) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
Constructor Details
#initialize(url, path, ids, type, source, publisher, order, per_page, page, key, options, verbose) ⇒ Request
Returns a new instance of Request.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lagotto-rb/request.rb', line 23 def initialize(url, path, ids, type, source, publisher, order, per_page, page, key, , verbose) self.url = url self.path = path self.ids = ids self.type = type self.source = source self.publisher = publisher self.order = order self.per_page = per_page self.page = page self.key = key self. = self.verbose = verbose end |
Instance Attribute Details
#ids ⇒ Object
Returns the value of attribute ids.
11 12 13 |
# File 'lib/lagotto-rb/request.rb', line 11 def ids @ids end |
#info ⇒ Object
Returns the value of attribute info.
13 14 15 |
# File 'lib/lagotto-rb/request.rb', line 13 def info @info end |
#key ⇒ Object
Returns the value of attribute key.
19 20 21 |
# File 'lib/lagotto-rb/request.rb', line 19 def key @key end |
#options ⇒ Object
Returns the value of attribute options.
20 21 22 |
# File 'lib/lagotto-rb/request.rb', line 20 def @options end |
#order ⇒ Object
Returns the value of attribute order.
16 17 18 |
# File 'lib/lagotto-rb/request.rb', line 16 def order @order end |
#page ⇒ Object
Returns the value of attribute page.
18 19 20 |
# File 'lib/lagotto-rb/request.rb', line 18 def page @page end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/lagotto-rb/request.rb', line 10 def path @path end |
#per_page ⇒ Object
Returns the value of attribute per_page.
17 18 19 |
# File 'lib/lagotto-rb/request.rb', line 17 def per_page @per_page end |
#publisher ⇒ Object
Returns the value of attribute publisher.
15 16 17 |
# File 'lib/lagotto-rb/request.rb', line 15 def publisher @publisher end |
#source ⇒ Object
Returns the value of attribute source.
14 15 16 |
# File 'lib/lagotto-rb/request.rb', line 14 def source @source end |
#type ⇒ Object
Returns the value of attribute type.
12 13 14 |
# File 'lib/lagotto-rb/request.rb', line 12 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/lagotto-rb/request.rb', line 9 def url @url end |
#verbose ⇒ Object
Returns the value of attribute verbose.
21 22 23 |
# File 'lib/lagotto-rb/request.rb', line 21 def verbose @verbose end |
Instance Method Details
#perform ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/lagotto-rb/request.rb', line 41 def perform args = { ids: self.ids, type: self.type, source: self.source, publisher: self.publisher, order: self.order, per_page: self.per_page, page: self.page, api_key: self.key } 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 |