Class: Entrata::Request::SendGeneralLeads

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

Overview

the general Entrata API that we have access to through the drive team. Used for adding leads through the general API that don’t go through the inactive/reactivate flow

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:, preferences:, property_id:) ⇒ Object

Preferences are optional for inserting a lead into Entrata.



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

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

#bodyObject



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

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



16
17
18
# File 'lib/entrata/request/send_general_leads.rb', line 16

def resource_auth
  { type: 'basic' }
end

#resource_nameObject



20
21
22
# File 'lib/entrata/request/send_general_leads.rb', line 20

def resource_name
  'sendLeads'
end

#resource_paramsObject



39
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
# File 'lib/entrata/request/send_general_leads.rb', line 39

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: [
        {
          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
          }
        }
      ]
    }
  }
end

#resource_pathObject



24
25
26
# File 'lib/entrata/request/send_general_leads.rb', line 24

def resource_path
  '/api/leads'
end