Class: CampaignMonitor::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/campaign_monitor/result.rb

Overview

Encapsulates the response received from the CampaignMonitor webservice.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Result) initialize(response)



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

- (Object) code (readonly)

Returns the value of attribute code



4
5
6
# File 'lib/campaign_monitor/result.rb', line 4

def code
  @code
end

- (Object) message (readonly)

Returns the value of attribute message



4
5
6
# File 'lib/campaign_monitor/result.rb', line 4

def message
  @message
end

- (Object) raw (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

- (Object) content



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

- (Boolean) failed? Also known as: failure?



16
17
18
# File 'lib/campaign_monitor/result.rb', line 16

def failed?
  not success?
end

- (Boolean) success? Also known as: succeeded?



12
13
14
# File 'lib/campaign_monitor/result.rb', line 12

def success?
  code == 0
end