Class: Quandora::Request
- Inherits:
-
Object
- Object
- Quandora::Request
- Defined in:
- lib/quandora/request.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #index(args = {}) ⇒ Object
-
#initialize(conn, api, params) ⇒ Request
constructor
A new instance of Request.
- #show(id, args = {}) ⇒ Object
Constructor Details
#initialize(conn, api, params) ⇒ Request
Returns a new instance of Request.
4 5 6 7 8 |
# File 'lib/quandora/request.rb', line 4 def initialize(conn, api, params) @conn = conn @api = api @params = params end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
2 3 4 |
# File 'lib/quandora/request.rb', line 2 def api @api end |
#params ⇒ Object
Returns the value of attribute params.
2 3 4 |
# File 'lib/quandora/request.rb', line 2 def params @params end |
Instance Method Details
#index(args = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/quandora/request.rb', line 10 def index(args = {}) args = args.stringify_keys @params.merge!("o": args["o"]) unless args.fetch('o', nil).nil? @params.merge!("l": args["l"]) unless args.fetch('l', nil).nil? resp = @conn.get(@api.to_s) do |req| req.params = @params req.headers['Content-Type'] = 'application/json' end end |
#show(id, args = {}) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/quandora/request.rb', line 22 def show(id, args = {}) args = args.stringify_keys resp = @conn.get("#{@api}/#{id}") do |req| req.params = @params req.headers['Content-Type'] = 'application/json' end end |