Method: Markety::Response::SyncLeadResponse#initialize

Defined in:
lib/markety/response/sync_lead_response.rb

#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