Class: Entrata::Request::SendInactiveLeads

Inherits:
Base
  • Object
show all
Defined in:
lib/entrata/request/send_inactive_leads.rb

Overview

insert a lead that is assigned to Lea Lite and Log email communication to remove the lead from the assign agent/never contacted/contact needed queues

Instance Method Summary collapse

Methods inherited from Base

#initialize, #perform, #perform_with_curl

Constructor Details

This class inherits a constructor from Entrata::Request::Base

Instance Method Details

#after_initialize(customer:, lead_source_id:, leasing_agent_id:, preferences:, property_id:) ⇒ Object

Preferences are optional for inserting a lead into Entrata.



9
10
11
12
13
14
15
# File 'lib/entrata/request/send_inactive_leads.rb', line 9

def after_initialize(customer:, lead_source_id:, leasing_agent_id:, preferences:, property_id:)
  @customer = customer
  @lead_source_id = lead_source_id
  @leasing_agent_id = leasing_agent_id
  @preferences = preferences
  @property_id = property_id
end

#bodyObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/entrata/request/send_inactive_leads.rb', line 29

def body
  {
    auth: resource_auth,
    requestId: '15', # used in all requests for Lea(SA) product
    method: {
      name: resource_name,
      params: resource_params
    }
  }.to_json
end

#resource_authObject



17
18
19
# File 'lib/entrata/request/send_inactive_leads.rb', line 17

def resource_auth
  { type: 'basic' }
end

#resource_nameObject



21
22
23
# File 'lib/entrata/request/send_inactive_leads.rb', line 21

def resource_name
  'sendLeads'
end

#resource_paramsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/entrata/request/send_inactive_leads.rb', line 40

def resource_params
  # all dates and times used in the API are assumed to be in Mountain Time (MST or MDT)
  five_minutes_ago = 5.minutes.ago.in_time_zone('America/Denver').strftime('%m/%d/%YT%H:%M:%S')
  {
    propertyId: property_id, # Entrata remote property ID
    doNotSendConfirmationEmail: '1', # Suppress email to renter - need to validate
    isWaitList: '0',
    prospects: {
      prospect: [
        {
          leasingAgentId: leasing_agent_id, # Lea Lite’s agent ID in the client system to be acquired during onboarding
          leadSource: {
            originatingLeadSourceId: lead_source_id # ApartmentList source ID to be acquired during onboarding
          },
          createdDate: five_minutes_ago, # Now - 5 minutes
          customers: { # Renter details
            customer: [
              {
                name: {
                  firstName: customer.first_name,
                  lastName: customer.last_name
                },
                phone: {
                  cellPhoneNumber: customer.phone
                },
                email: customer.email
              }
            ]
          },
          customerPreferences: {
            desiredMoveInDate: formatted_move_in_date,
            comment: preferences.comments,
            desiredNumBedrooms: preferences.beds
          },
          events: {
            event: [
              {
                type: 'EmailToProspect', # Event necessary to remove guest card from “Contact needed” tab
                date: five_minutes_ago, # Now - 5 minutes
                emailAddresses: {
                  from: '[email protected]', # irrelevant -  not displayed or used
                  to: customer.email # prospect email
                },
                emailBody: 'not applicable' # irrelevant - not displayed or used
              }
            ]
          }
        }
      ]
    }
  }
end

#resource_pathObject



25
26
27
# File 'lib/entrata/request/send_inactive_leads.rb', line 25

def resource_path
  '/api/leads'
end