Class: Markety::Response::SyncLeadResponse

Inherits:
GenericResponse show all
Defined in:
lib/markety/response/sync_lead_response.rb

Overview

Response class for SyncLead commands

Instance Attribute Summary collapse

Attributes inherited from GenericResponse

#error_message

Instance Method Summary collapse

Methods inherited from GenericResponse

#success?, #to_hash, #to_xml

Constructor Details

#initialize(response) ⇒ SyncLeadResponse

Returns a new instance of SyncLeadResponse.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/markety/response/sync_lead_response.rb', line 16

def initialize(response)
  super(:sync_response,response)
  h = self.to_hash

  if self.success?
    sync_status = h[:success_sync_lead][:result][:sync_status]
    @lead_id = sync_status[:lead_id]
    @update_type = sync_status[:status].downcase.to_sym
    @updated_lead = ::Markety::Lead.from_hash(h[:success_sync_lead][:result][:lead_record])
  else
    # overwrite super's crap error message with useful one
    @error_message = h[:fault][:detail][:service_exception][:message]
  end
end

Instance Attribute Details

#lead_idObject (readonly)

the ID of the created or updated Lead (or nil if unsuccessful)



14
15
16
# File 'lib/markety/response/sync_lead_response.rb', line 14

def lead_id
  @lead_id
end

#update_typeObject (readonly)

:created or :updated (or nil if unsuccessful)



10
11
12
# File 'lib/markety/response/sync_lead_response.rb', line 10

def update_type
  @update_type
end

#updated_leadObject (readonly)

the updated or created Lead (or nil if unsuccessful)



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

def updated_lead
  @updated_lead
end