Class: Markety::Response::GenericResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/markety/response/generic_response.rb

Overview

Parent class for all response types.

SOAP requests sent by Markety result in either a Savon::Response or a Savon::SOAPFault. This class hides those boring details from you, unless you want to use its methods to see them.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd_type, response) ⇒ GenericResponse

  • cmd_type - a symbol

  • response - a Savon::Response or a Savon::SOAPFault



16
17
18
19
20
# File 'lib/markety/response/generic_response.rb', line 16

def initialize(cmd_type,response)
  @response = response
  @success = response.is_a? Savon::Response
  @error_message = @success ? nil : response.to_s
end

Instance Attribute Details

#error_messageObject (readonly)

if the response is a Savon::SOAPFault, this is its error message



12
13
14
# File 'lib/markety/response/generic_response.rb', line 12

def error_message
  @error_message
end

Instance Method Details

#success?Boolean

True if Marketo’s response indicates that the SOAP request was successful.

Note: This is not the same as the a result from a Marketo command itself! To see the command’s result, consult the command-specific Response class.

Returns:

  • (Boolean)


28
29
30
# File 'lib/markety/response/generic_response.rb', line 28

def success?
  @success
end

#to_hashObject

The underlying Savon::Response or Savon::SOAPFault‘s content as a hash



40
41
42
# File 'lib/markety/response/generic_response.rb', line 40

def to_hash
  @response.to_hash
end

#to_xmlObject

Return the xml from the underlying Savon::Response or Savon::SOAPFault



34
35
36
# File 'lib/markety/response/generic_response.rb', line 34

def to_xml
  @success ? @response.to_xml : @response.http.raw_body
end