Sha256: 93014f4263a4fb7f34ee6b1be6caee8d4f7c804db71d8242874a5ad23eeb7f11
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
module T2Airtime class Country def self.all serialize_reply(T2Airtime::API.api.country_list) end def self.serialize_reply(reply) names = reply[:country].split(",") ids = reply[:countryid].split(",") ids.each_with_index.map{|id, n| { name: names[n], aid: Integer(id) }} end end class Operator def self.all countries = T2Airtime::Country.all countries.flat_map{|country| serialize_reply(T2Airtime::API.api.operator_list(country[:aid]))} end def self.serialize_reply(reply) names = reply[:operator].split(",") ids = reply[:operatorid].split(",") ids.each_with_index.map{|id, n| { country: reply[:country], country_aid: Integer(reply[:countryid]), name: names[n], aid: Integer(id) }} end end class Product def self.all operators = T2Airtime::Operator.all operators.flat_map{|operator| serialize_reply(T2Airtime::API.api.product_list(operator[:aid]))} end def self.serialize_reply(reply) currency = reply[:destination_currency] retail_prices = reply[:retail_price_list].split(",") wholesale_prices = reply[:wholesale_price_list].split(",") ids = reply[:product_list].split(",") ids.each_with_index.map{|id, n| { country: reply[:country], country_aid: Integer(reply[:countryid]), operator: reply[:operator], operator_aid: Integer(reply[:operatorid]), name: "#{id}#{currency}", currency: currency, retail_price: retail_prices[n], wholesale_price: wholesale_prices[n], aid: Integer(id) }} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
t2_airtime-0.1.2 | lib/t2_airtime/rest.rb |