Class: Gbif::Request
- Inherits:
-
Object
- Object
- Gbif::Request
- Defined in:
- lib/gbifrb/request.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#endpt ⇒ Object
Returns the value of attribute endpt.
-
#options ⇒ Object
Returns the value of attribute options.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(endpt, args, verbose, options) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
Constructor Details
#initialize(endpt, args, verbose, options) ⇒ Request
Returns a new instance of Request.
20 21 22 23 24 25 |
# File 'lib/gbifrb/request.rb', line 20 def initialize(endpt, args, verbose, ) self.endpt = endpt self.args = args self.verbose = verbose self. = ( or {}).merge({params_encoder: Faraday::FlatParamsEncoder}) end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
16 17 18 |
# File 'lib/gbifrb/request.rb', line 16 def args @args end |
#endpt ⇒ Object
Returns the value of attribute endpt.
15 16 17 |
# File 'lib/gbifrb/request.rb', line 15 def endpt @endpt end |
#options ⇒ Object
Returns the value of attribute options.
18 19 20 |
# File 'lib/gbifrb/request.rb', line 18 def @options end |
#verbose ⇒ Object
Returns the value of attribute verbose.
17 18 19 |
# File 'lib/gbifrb/request.rb', line 17 def verbose @verbose end |
Instance Method Details
#perform ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gbifrb/request.rb', line 27 def perform if verbose conn = Faraday.new(:url => Gbif.base_url, :request => self. || []) do |f| f.response :logger f.response :raise_error f.adapter Faraday.default_adapter end else conn = Faraday.new(:url => Gbif.base_url, :request => self. || []) do |f| f.response :raise_error f.adapter Faraday.default_adapter end end conn.headers[:user_agent] = make_ua conn.headers["X-USER-AGENT"] = make_ua res = conn.get self.endpt, self.args return MultiJson.load(res.body) end |