class Flexibee::ProductList
Public Class Methods
new(client)
click to toggle source
By default called with { detail: ‘full’ }, normal response does not have any usefull information in it
# File lib/flexibee/product_list.rb, line 6 def initialize(client) @client = client end
Public Instance Methods
all(params={})
click to toggle source
# File lib/flexibee/product_list.rb, line 10 def all(params={}) create_products(find(nil, params)) end
find(filter=nil, params={})
click to toggle source
# File lib/flexibee/product_list.rb, line 14 def find(filter=nil, params={}) @client.get("/cenik", params.merge({ detail: 'full' }), filter)['winstrom']['cenik'] end
find_by_ean(ean)
click to toggle source
# File lib/flexibee/product_list.rb, line 26 def find_by_ean(ean) create_products(find("eanKod='#{ean}'")).first end
find_by_id(id)
click to toggle source
# File lib/flexibee/product_list.rb, line 18 def find_by_id(id) create_products(find("id='#{id}'")).first end
find_by_name(name)
click to toggle source
# File lib/flexibee/product_list.rb, line 22 def find_by_name(name) create_products(find("nazev='#{name}'")).first end
Private Instance Methods
create_products(response)
click to toggle source
# File lib/flexibee/product_list.rb, line 32 def create_products(response) response.map { |p| Flexibee::Product.new(p, @client) } end