Sha256: 8cd2d6a8eb3828385302c342e7a12b62fc2584618b86701f25588e4289f338dc
Contents?: true
Size: 654 Bytes
Versions: 9
Compression:
Stored size: 654 Bytes
Contents
# frozen_string_literal: true class Wegift::Products < Wegift::Response PATH = '/products' attr_accessor :all # Product Details List # GET /api/b2b-sync/v1/products/ def get(ctx) response = ctx.request(:get, PATH) parse(response) end # Find all products by fieldname. def find(name, value) Wegift::Products.new(all: all.select! { |p| p.send(name).eql?(value) }) end 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 end
Version data entries
9 entries across 9 versions & 1 rubygems