Class: Economic::PricingRepo

Inherits:
ProductRepo show all
Defined in:
lib/economic/pricing_repo.rb

Constant Summary

Constants inherited from BaseRepo

BaseRepo::URL

Class Method Summary collapse

Methods inherited from ProductRepo

in_group

Methods inherited from BaseRepo

all, destroy, endpoint_url, filter, find, id_to_url_formatted_id, save, send, send_request, updated_after

Class Method Details

.currency_specific_sales_prices_for(product_or_product_number) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/economic/pricing_repo.rb', line 3

def self.currency_specific_sales_prices_for(product_or_product_number)
  id = product_or_product_number.product_number if product_or_product_number.respond_to? :product_number
  id ||= product_or_product_number

  id = Economic::BaseRepo.id_to_url_formatted_id(id)
  end_point = [superclass.endpoint_url, id, "pricing", "currency-specific-sales-prices"].join("/")
  response = send_request(method: :get, url: URI.escape(end_point))
  entry_hash = JSON.parse(response.body)
  pricings = []

  entry_hash["collection"].each do |pricing|
    pricings.push Pricing.new(pricing)
  end
  pricings
end