Class: AppfiguresClient::Endpoints::Products

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/appfigures_client/endpoints/products.rb

Constant Summary collapse

FILTERS =
%w(mac ios google amazon)

Instance Method Summary collapse

Methods inherited from Endpoint

#initialize

Constructor Details

This class inherits a constructor from AppfiguresClient::Endpoints::Endpoint

Instance Method Details

#all(store = nil) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/appfigures_client/endpoints/products.rb', line 24

def all(store = nil)
  path = @routes[:mine]
  options = nil
  if store && @api.data.stores[store].present?
    options = {store: store}
  end
  @request.make path, options
end

#get(id) ⇒ Object



7
8
9
10
# File 'lib/appfigures_client/endpoints/products.rb', line 7

def get(id)
  path = @routes[:default] + id.to_s
  @request.make path
end

#search(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/appfigures_client/endpoints/products.rb', line 12

def search(options={})
  path = @routes[:search]

  raise '"term" option is required' unless options[:term].present?

  if options[:options].present? && options[:options][:filter].present?
    raise 'Wrong "filter" param' unless options[:options][:filter].in? FILTERS
  end

  @request.make path + options[:term], options[:options]
end