require 'securerandom' require 'event_tracker' require 'real_page/utils' module RealPage module Utils class SnowflakeEventTracker IMPORT_PMS_RESIDENT_EVENT = 'import_pms_resident' IMPORT_PMS_PROSPECT_EVENT = 'import_pms_prospect' def self.track_pms_resident_event( remote_lease_id: nil, import_resident_id:, resident_type:, api_name:, request_params:, move_in_date: nil, lease_to: nil, lease_from: nil, first_name_present: false, last_name_present: false, email_present: false, phones_count:, 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[:billing_config].property_id, billing_config_id: request_params[:billing_config].id, remote_id: request_params[:site_id], pms_type: 'real_page', import_id: request_params[:import_id], pmc_id: request_params[:pmc_id], service: RealPage.config.app_name ), remote_lease_id: remote_lease_id, import_resident_id: import_resident_id, resident_type: resident_type, api_name: api_name, request_params: EventTracker::ResourceFactory::PmsResident.build_request_params( start_date: (request_params[:start_date] || '').to_time, end_date: (request_params[:end_date] || '').to_time, prospect_id: request_params[:guest_card_id], pmc_id: request_params[:pmc_id], remote_id: request_params[:site_id], traffic_source_id: request_params[:traffic_source_id] ), 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, error: error ) ) end end def self.track_pms_prospect_event( remote_lease_id: nil, resident_type:, request_params:, 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[:billing_config].property_id, billing_config_id: request_params[:billing_config].id, remote_id: request_params[:site_id], pms_type: 'real_page', import_id: request_params[:import_id], pmc_id: request_params[:pmc_id], service: RealPage.config.app_name ), remote_lease_id: remote_lease_id, import_resident_id: request_params[:import_resident_id] || '', resident_type: resident_type, api_name: 'ProspectSearch', request_params: EventTracker::ResourceFactory::PmsProspect.build_request_params( pmc_id: request_params[:pmc_id], remote_id: request_params[:site_id], prospect_id: request_params[:guest_card_id] ), contact_date: contact_date, contact_source: contact_source, remote_prospect_id: remote_prospect_id, error: error ) ) end end end end end