class Markety::Response::SyncLeadResponse

Response class for SyncLead commands

Attributes

lead_id[R]

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

update_type[R]

:created or :updated (or nil if unsuccessful)

updated_lead[R]

the updated or created Lead (or nil if unsuccessful)

Public Class Methods

new(response) click to toggle source
Calls superclass method Markety::Response::GenericResponse::new
# 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