112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/t2_airtime/serializer.rb', line 112
def self.serialize(data, qty=nil)
currency = data[:destination_currency]
retail_prices = data[:retail_price_list].split(",")
wholesale_prices = data[:wholesale_price_list].split(",")
ids = data[:product_list].split(",")
ids.take(qty.nil? ? ids.count : qty).each_with_index.map{|id, n| {
country: data[:country],
country_aid: Integer(data[:countryid]),
alpha3: T2Airtime::Country.alpha3(data[:country]),
operator: data[:operator],
operator_aid: Integer(data[:operatorid]),
operator_logo_url: T2Airtime::Util.operator_logo_url(data[:operatorid]),
name: "#{id}#{currency}",
currency: currency,
local_price: Float(id),
retail_price: Float(retail_prices[n]),
wholesale_price: Float(wholesale_prices[n]),
local_price_display: T2Airtime::Util.format_price(id, currency),
retail_price_display: T2Airtime::Util.format_price(retail_prices[n]),
wholesale_price_display: T2Airtime::Util.format_price(wholesale_prices[n]),
aid: Integer(id)
}}
end
|