Class: T2Airtime::Reply
- Inherits:
-
Object
- Object
- T2Airtime::Reply
- Defined in:
- lib/t2_airtime/reply.rb
Instance Method Summary collapse
- #auth_key ⇒ Object
- #data ⇒ Object
- #error_code ⇒ Object
- #error_message ⇒ Object
- #headers ⇒ Object
- #information ⇒ Object
-
#initialize(reply) ⇒ Reply
constructor
A new instance of Reply.
- #message ⇒ Object
- #raw ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
- #url ⇒ Object
Constructor Details
#initialize(reply) ⇒ Reply
Returns a new instance of Reply
4 |
# File 'lib/t2_airtime/reply.rb', line 4 def initialize(reply) @response = Hash(reply) end |
Instance Method Details
#auth_key ⇒ Object
32 |
# File 'lib/t2_airtime/reply.rb', line 32 def auth_key() data[:authentication_key] end |
#data ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/t2_airtime/reply.rb', line 6 def data hash = {} @response[:body].lines.each do |line| key, value = line.strip.split "=" hash[key.to_sym] = (key == "error_code") ? Integer(value) : value end; hash end |
#error_code ⇒ Object
24 |
# File 'lib/t2_airtime/reply.rb', line 24 def error_code() data[:error_code] end |
#error_message ⇒ Object
26 |
# File 'lib/t2_airtime/reply.rb', line 26 def () data[:error_txt] end |
#headers ⇒ Object
34 |
# File 'lib/t2_airtime/reply.rb', line 34 def headers() @response[:response_headers] end |
#information ⇒ Object
14 15 16 17 18 |
# File 'lib/t2_airtime/reply.rb', line 14 def information data.reject do |key, value| [:authentication_key, :error_code, :error_txt].include?(key) end end |
#message ⇒ Object
30 |
# File 'lib/t2_airtime/reply.rb', line 30 def () information[:info_txt] end |
#raw ⇒ Object
36 |
# File 'lib/t2_airtime/reply.rb', line 36 def raw() @response[:body] end |
#status ⇒ Object
22 |
# File 'lib/t2_airtime/reply.rb', line 22 def status() @response[:status] end |
#success? ⇒ Boolean
20 |
# File 'lib/t2_airtime/reply.rb', line 20 def success?() status == 200 && error_code == 0 end |
#url ⇒ Object
28 |
# File 'lib/t2_airtime/reply.rb', line 28 def url() "#{@response[:url]}" end |