Class: PennySMSMuncher::PennySMS::Response
- Inherits:
-
Object
- Object
- PennySMSMuncher::PennySMS::Response
- Defined in:
- lib/penny_sms.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #fault ⇒ Object
- #fault_code ⇒ Object
- #fault_name ⇒ Object
-
#initialize(raw) ⇒ Response
constructor
A new instance of Response.
- #set_status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(raw) ⇒ Response
Returns a new instance of Response.
42 43 44 45 46 47 |
# File 'lib/penny_sms.rb', line 42 def initialize(raw) self.raw = raw self.data = XML::Parser.string(raw.body).parse # JSON? self.set_status self end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
40 41 42 |
# File 'lib/penny_sms.rb', line 40 def data @data end |
#raw ⇒ Object
Returns the value of attribute raw.
40 41 42 |
# File 'lib/penny_sms.rb', line 40 def raw @raw end |
#status ⇒ Object
Returns the value of attribute status.
40 41 42 |
# File 'lib/penny_sms.rb', line 40 def status @status end |
Instance Method Details
#fault ⇒ Object
69 70 71 72 |
# File 'lib/penny_sms.rb', line 69 def fault return unless data && !data.find('//fault').empty? data.find('//fault//member')[0] end |
#fault_code ⇒ Object
61 62 63 |
# File 'lib/penny_sms.rb', line 61 def fault_code fault.find('//i4').first.content if fault end |
#fault_name ⇒ Object
65 66 67 |
# File 'lib/penny_sms.rb', line 65 def fault_name fault.find('//string').first.content if fault end |
#set_status ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/penny_sms.rb', line 53 def set_status if fault self.status = 'error' else self.status = data.find('//params//string').first.content end end |
#success? ⇒ Boolean
49 50 51 |
# File 'lib/penny_sms.rb', line 49 def success? !fault_code end |