Class: Amsi::Validator::Base
- Inherits:
-
Object
- Object
- Amsi::Validator::Base
- Defined in:
- lib/amsi/validator/base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #import_resident_id(params) ⇒ Object
- #is_present?(value) ⇒ Boolean
- #pms_prospect_request_params(params) ⇒ Object
- #pms_resident_request_params(params) ⇒ Object
- #send_pms_prospect_event(lease:, params:, error_message: nil) ⇒ Object
- #send_pms_resident_event(lease:, params:, error_message: nil) ⇒ Object
Instance Method Details
#import_resident_id(params) ⇒ Object
82 83 84 |
# File 'lib/amsi/validator/base.rb', line 82 def import_resident_id(params) "#{params[:import_id] || ''}-#{SecureRandom.alphanumeric(15)}" end |
#is_present?(value) ⇒ Boolean
86 87 88 89 90 91 92 93 94 |
# File 'lib/amsi/validator/base.rb', line 86 def is_present?(value) if value.is_a?(String) !value.strip.empty? elsif value.is_a?(Hash) || value.is_a?(Array) !(value.empty? || value.nil?) else !value.nil? end end |
#pms_prospect_request_params(params) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/amsi/validator/base.rb', line 69 def pms_prospect_request_params(params) { app_name: params[:app_name] || '', billing_config_id: params[:billing_config]&.id, property_id: params[:billing_config]&.property_id, remote_id: params[:remote_id], import_id: params[:import_id], pmc_id: params[:pmc_id], import_resident_id: import_resident_id(params), prospect_id: nil } end |
#pms_resident_request_params(params) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/amsi/validator/base.rb', line 37 def pms_resident_request_params(params) { app_name: params[:app_name] || '', start_date: params[:start_date]&.to_time, end_date: params[:end_date]&.to_time, prospect_id: nil, pmc_id: params[:pmc_id], remote_id: params[:remote_id], traffic_source_id: nil, import_id: params[:import_id], billing_config_id: params[:billing_config]&.id, property_id: params[:billing_config]&.property_id } end |
#send_pms_prospect_event(lease:, params:, error_message: nil) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/amsi/validator/base.rb', line 52 def send_pms_prospect_event(lease:, params:, error_message: nil) lease.occupants.each do |occupant| Utils::SnowflakeEventTracker.track_pms_prospect_event( remote_lease_id: nil, request_params: pms_prospect_request_params(params), first_name_present: is_present?(occupant.first_name), last_name_present: is_present?(occupant.last_name), email_present: is_present?(occupant.email), phone_present: is_present?(occupant.phone_1) || is_present?(occupant.phone_2), contact_date: nil, contact_source: lease.lead_source_code, remote_prospect_id: nil, error: ) end end |
#send_pms_resident_event(lease:, params:, error_message: nil) ⇒ Object
8 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 |
# File 'lib/amsi/validator/base.rb', line 8 def send_pms_resident_event(lease:, params:, error_message: nil) remote_lease_id, lease_to, lease_from = [nil] * 3 if lease unit_name = lease.unit_id move_in_date = lease.move_in_date else unit_name = '' move_in_date = nil end lease.occupants.each_with_index do |occupant, index| Utils::SnowflakeEventTracker.track_pms_resident_event( remote_lease_id: remote_lease_id, import_resident_id: import_resident_id(params), resident_type: index == 0 ? 'PRIMARY' : 'ROOMMATE', request_params: pms_resident_request_params(params), move_in_date: move_in_date&.to_time, lease_to: lease_to, lease_from: lease_from, first_name_present: is_present?(occupant.first_name), last_name_present: is_present?(occupant.last_name), email_present: is_present?(occupant.email), phones_count: [occupant.phone_1, occupant.phone_2].compact.count, unit_name: unit_name, resident_id: occupant.resident_id, error: ) end end |