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

#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

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end

#rawObject (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

#contentObject



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?

Returns:

  • (Boolean)


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

def failed?
  not success?
end

#success?Boolean Also known as: succeeded?

Returns:

  • (Boolean)


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

def success?
  code == 0
end