class T2Airtime::Account
Public Class Methods
currency()
click to toggle source
# File lib/t2_airtime/serializer.rb, line 75 def self.currency account = serialize(get.data) Rails.cache.fetch('accounts/currency', expires_in: 24.hours) do # cache the result for 1 day account[:attributes][:currency] end end
get()
click to toggle source
# File lib/t2_airtime/serializer.rb, line 69 def self.get Rails.cache.fetch('accounts', expires_in: 1.hour) do T2Airtime::API.api.account_info end end
info()
click to toggle source
# File lib/t2_airtime/serializer.rb, line 82 def self.info get.success? ? serialize(get.data, get.headers[:date]) : [] end
serialize(data, ts = Time.zone.now.to_s)
click to toggle source
# File lib/t2_airtime/serializer.rb, line 86 def self.serialize(data, ts = Time.zone.now.to_s) { type: 'accounts', id: T2Airtime::API.api.user, attributes: { type: data[:type], name: data[:name], currency: data[:currency], balance: Float(data[:balance]), wallet: Float(data[:wallet]), fetchedAt: T2Airtime::Util.format_time(ts) } } end