Class: EasyBroker::Query
- Inherits:
-
Object
- Object
- EasyBroker::Query
- Defined in:
- lib/easy_broker/query.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#query_params ⇒ Object
readonly
Returns the value of attribute query_params.
Instance Method Summary collapse
- #get(page = nil) ⇒ Object
-
#initialize(api_client, endpoint, query_params) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(api_client, endpoint, query_params) ⇒ Query
6 7 8 9 10 |
# File 'lib/easy_broker/query.rb', line 6 def initialize(api_client, endpoint, query_params) @api_client = api_client @endpoint = endpoint @query_params = query_params end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
4 5 6 |
# File 'lib/easy_broker/query.rb', line 4 def api_client @api_client end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
4 5 6 |
# File 'lib/easy_broker/query.rb', line 4 def endpoint @endpoint end |
#query_params ⇒ Object (readonly)
Returns the value of attribute query_params.
4 5 6 |
# File 'lib/easy_broker/query.rb', line 4 def query_params @query_params end |
Instance Method Details
#get(page = nil) ⇒ Object
12 13 14 15 16 |
# File 'lib/easy_broker/query.rb', line 12 def get(page = nil) query_params[:page] = page if page response = api_client.get(endpoint, query: query_params) JSON.parse(response.body, object_class: OpenStruct) end |