Class: CampaignMonitor::Result
- Inherits:
-
Object
- Object
- CampaignMonitor::Result
- Defined in:
- lib/campaign_monitor/result.rb
Overview
Encapsulates the response received from the CampaignMonitor webservice.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #content ⇒ Object
- #failed? ⇒ Boolean (also: #failure?)
-
#initialize(response) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean (also: #succeeded?)
Constructor Details
#initialize(response) ⇒ Result
Returns a new instance of Result.
6 7 8 9 10 |
# File 'lib/campaign_monitor/result.rb', line 6 def initialize(response) @message = response["Message"] @code = response["Code"].to_i @raw = response end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/campaign_monitor/result.rb', line 4 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/campaign_monitor/result.rb', line 4 def @message end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
4 5 6 |
# File 'lib/campaign_monitor/result.rb', line 4 def raw @raw end |
Instance Method Details
#content ⇒ Object
20 21 22 23 24 25 |
# File 'lib/campaign_monitor/result.rb', line 20 def content # if we're a string (likely from SOAP) return raw if raw.is_a?(String) # if we're a hash raw["__content__"] end |
#failed? ⇒ Boolean Also known as: failure?
16 17 18 |
# File 'lib/campaign_monitor/result.rb', line 16 def failed? not success? end |
#success? ⇒ Boolean Also known as: succeeded?
12 13 14 |
# File 'lib/campaign_monitor/result.rb', line 12 def success? code == 0 end |