Class: Markety::Response::GenericResponse
- Inherits:
-
Object
- Object
- Markety::Response::GenericResponse
- 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.
Direct Known Subclasses
GetCustomObjectResponse, GetLeadResponse, ListOperationResponse, SyncCustomObjectResponse, SyncLeadResponse, SyncMultipleLeadsResponse
Instance Attribute Summary collapse
-
#error_message ⇒ Object
readonly
if the response is a
Savon::SOAPFault
, this is its error message.
Instance Method Summary collapse
-
#initialize(cmd_type, response) ⇒ GenericResponse
constructor
-
cmd_type
- a symbol *response
- aSavon::Response
or aSavon::SOAPFault
.
-
-
#success? ⇒ Boolean
True if Marketo’s response indicates that the SOAP request was successful.
-
#to_hash ⇒ Object
The underlying
Savon::Response
orSavon::SOAPFault
‘s content as a hash. -
#to_xml ⇒ Object
Return the xml from the underlying
Savon::Response
orSavon::SOAPFault
.
Constructor Details
#initialize(cmd_type, response) ⇒ GenericResponse
-
cmd_type
- a symbol -
response
- aSavon::Response
or aSavon::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_message ⇒ Object (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 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.
28 29 30 |
# File 'lib/markety/response/generic_response.rb', line 28 def success? @success end |
#to_hash ⇒ Object
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_xml ⇒ Object
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 |