Sha256: af09627a7eafd20c96c589e7da9954a665ff1291d815eabcc776b3bdfb97cb22

Contents?: true

Size: 652 Bytes

Versions: 5

Compression:

Stored size: 652 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 = send_request(method: :get, url: end_point)
      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

5 entries across 5 versions & 1 rubygems

Version Path
economic-rest-0.6.4 lib/economic/product_repo.rb
economic-rest-0.6.3 lib/economic/product_repo.rb
economic-rest-0.6.2 lib/economic/product_repo.rb
economic-rest-0.6.1 lib/economic/product_repo.rb
economic-rest-0.6.0 lib/economic/product_repo.rb