require 'event_tracker' module Amsi module Utils class SnowflakeEventTracker IMPORT_PMS_RESIDENT_EVENT = 'import_pms_resident' IMPORT_PMS_PROSPECT_EVENT = 'import_pms_prospect' 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 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 end end end