Class: Amsi::Utils::SnowflakeEventTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/amsi/utils/snowflake_event_tracker.rb

Constant Summary collapse

IMPORT_PMS_RESIDENT_EVENT =
'import_pms_resident'
IMPORT_PMS_PROSPECT_EVENT =
'import_pms_prospect'

Class Method Summary collapse

Class Method Details

.track_pms_prospect_event(request_params:, first_name_present:, last_name_present:, email_present:, phone_present:, remote_lease_id: nil, contact_date: nil, contact_source: nil, remote_prospect_id: nil, error: nil) ⇒ Object



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
92
93
94
95
96
97
98
99
100
101
# File 'lib/amsi/utils/snowflake_event_tracker.rb', line 61

def self.track_pms_prospect_event(
  request_params:, first_name_present:, last_name_present:, email_present:, phone_present:, remote_lease_id: nil,
  contact_date: nil,
  contact_source: nil,
  remote_prospect_id: nil,
  error: nil
)
  EventTracker.track_process_events(name: IMPORT_PMS_PROSPECT_EVENT) do |events|
    events.add_imported_event(
      EventTracker::ResourceFactory.build_pms_prospect(
        billing_import: EventTracker::BillingImportFactory.build_billing_import(
          property_id: request_params[:property_id],
          billing_config_id: request_params[:billing_config_id],
          remote_id: request_params[:remote_id],
          pms_type: 'amsi',
          import_id: request_params[:import_id],
          pmc_id: request_params[:pmc_id],
          service: request_params[:app_name]
        ),
        remote_lease_id: remote_lease_id,
        import_resident_id: request_params[:import_resident_id] || '',
        resident_type: 'PRIMARY',
        api_name: 'GetPropertyResidents',
        request_params: EventTracker::ResourceFactory::PmsProspect.build_request_params(
          pmc_id: request_params[:pmc_id],
          remote_id: request_params[:remote_id],
          prospect_id: request_params[:prospect_id],
          first_name_present: first_name_present,
          last_name_present: last_name_present,
          email_present: email_present,
          phone_present: phone_present
        ),
        contact_date: contact_date,
        contact_source: contact_source,
        remote_prospect_id: remote_prospect_id,
        move_in_report_type: 'amsi_api',
        error: error
      )
    )
  end
end

.track_pms_resident_event(import_resident_id:, resident_type:, request_params:, unit_name:, remote_lease_id: nil, move_in_date: nil, lease_to: nil, lease_from: nil, first_name_present: false, last_name_present: false, email_present: false, phones_count: 0, resident_id: nil, error: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/amsi/utils/snowflake_event_tracker.rb', line 9

def self.track_pms_resident_event(
  import_resident_id:, resident_type:, request_params:, unit_name:, remote_lease_id: nil,
  move_in_date: nil,
  lease_to: nil,
  lease_from: nil,
  first_name_present: false,
  last_name_present: false,
  email_present: false,
  phones_count: 0,
  resident_id: nil,
  error: nil
)
  EventTracker.track_process_events(name: IMPORT_PMS_RESIDENT_EVENT) do |events|
    events.add_imported_event(
      EventTracker::ResourceFactory.build_pms_resident(
        billing_import: EventTracker::BillingImportFactory.build_billing_import(
          property_id: request_params[:property_id],
          billing_config_id: request_params[:billing_config_id],
          remote_id: request_params[:remote_id],
          pms_type: 'amsi',
          import_id: request_params[:import_id],
          pmc_id: request_params[:pmc_id],
          service: request_params[:app_name]
        ),
        remote_lease_id: remote_lease_id,
        import_resident_id: import_resident_id,
        resident_type: resident_type,
        api_name: 'GetPropertyResidents',
        request_params: EventTracker::ResourceFactory::PmsResident.build_request_params(
          start_date: request_params[:start_date].nil? ? nil : request_params[:start_date].to_time,
          end_date: request_params[:end_date].nil? ? nil : request_params[:end_date].to_time,
          prospect_id: nil,
          pmc_id: request_params[:pmc_id],
          remote_id: request_params[:remote_id],
          traffic_source_id: nil
        ),
        move_in_date: move_in_date,
        lease_to: lease_to,
        lease_from: lease_from,
        first_name_present: first_name_present,
        last_name_present: last_name_present,
        email_present: email_present,
        phones_count: phones_count,
        unit_name: unit_name,
        resident_id: resident_id,
        move_in_report_type: 'amsi_api',
        error: error
      )
    )
  end
end