class MusicTodayApiWrapper::Services::ProductServices
Public Class Methods
new()
click to toggle source
# File lib/services/product_services.rb, line 7 def initialize @common_response = MusicTodayApiWrapper::RestClients::CommonResponse.new @rest_client = MusicTodayApiWrapper::RestClient.new end
Public Instance Methods
all_products(per_page = 1000, page_number = nil)
click to toggle source
# File lib/services/product_services.rb, line 13 def all_products(per_page = 1000, page_number = nil) results = @rest_client.all_products(per_page, page_number) return results unless results.success? @common_response.data[:products] = [] @common_response.work do results.data[:products].each { |product| product_mapper(product) } end end
find_product(id)
click to toggle source
# File lib/services/product_services.rb, line 23 def find_product(id) results = @rest_client.find_product(id) return results unless results.success? @common_response.work do @common_response.data[:product] = MusicTodayApiWrapper::Resources::Product .from_hash(results.data[:product]) end end
Private Instance Methods
product_mapper(product)
click to toggle source
# File lib/services/product_services.rb, line 36 def product_mapper(product) product_obj = MusicTodayApiWrapper::Resources::Product.from_hash(product) @common_response.data[:products] << product_obj end