Sha256: bdec6db594e9c4b6efc810ac3edcb24e5c02be251e6ee3ddec6759ae85fef81a

Contents?: true

Size: 671 Bytes

Versions: 3

Compression:

Stored size: 671 Bytes

Contents

module Economic
  class ProductRepo < Economic::BaseRepo
    def self.in_group(product_group_or_product_group_number)
      id = product_group_or_product_group_number.product_group_number if product_group_or_product_group_number.respond_to? :product_group_number
      id ||= product_group_or_product_group_number

      end_point = [ProductGroupRepo.endpoint_url, id, 'products'].join('/')
      response = test_response(RestClient.get(URI.escape(end_point), headers))
      entry_hash = JSON.parse(response.body)
      products = []

      entry_hash['collection'].each do |product|
        products.push Product.new(product)
      end
      products
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
economic-rest-0.3.4 lib/economic/product_repo.rb
economic-rest-0.3.3 lib/economic/product_repo.rb
economic-rest-0.3.2 lib/economic/product_repo.rb