Class: EasyBroker::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_broker/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_clientObject (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

#endpointObject (readonly)

Returns the value of attribute endpoint.



4
5
6
# File 'lib/easy_broker/query.rb', line 4

def endpoint
  @endpoint
end

#query_paramsObject (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