class Wegift::Products

Constants

PATH

Attributes

all[RW]

Public Instance Methods

find(name, value) click to toggle source

Find all products by fieldname.

# File lib/wegift/models/products.rb, line 16
def find(name, value)
  Wegift::Products.new(all: all.select! { |p| p.send(name).eql?(value) })
end
get(ctx) click to toggle source

Product Details List GET /api/b2b-sync/v1/products/

# File lib/wegift/models/products.rb, line 10
def get(ctx)
  response = ctx.request(:get, PATH)
  parse(response)
end
parse(response) click to toggle source
Calls superclass method Wegift::Response#parse
# File lib/wegift/models/products.rb, line 20
def parse(response)
  super(response)

  if is_successful?
    # TODO: separate?
    if @payload['products']
      @all = @payload['products'].map { |p| Wegift::Product.new(p) }
    end
  else
    @all = []
  end

  self
end