class MusicTodayApiWrapper::Services::ShippingServices
Public Class Methods
new()
click to toggle source
# File lib/services/shipping_services.rb, line 7 def initialize @common_response = RestClients::CommonResponse.new @common_response.data[:shipping_options] = [] @rest_client = RestClient.new end
Public Instance Methods
options(address, items)
click to toggle source
# File lib/services/shipping_services.rb, line 13 def options(address, items) hash_items = [] items.each { |item| hash_items << item.as_hash } params = { storeId: @rest_client.catalog_number, address: address.as_hash, lineItems: hash_items } @common_response.work do response = @rest_client.shipping_options(params) return response unless response.success? response .data[:shipping_options] .each { |option| shipping_option_mapper(option) } end end
Private Instance Methods
shipping_option_mapper(option)
click to toggle source
# File lib/services/shipping_services.rb, line 32 def shipping_option_mapper(option) @common_response.data[:shipping_options] << Resources::Purchase::ShippingOption.from_hash(option) end