Class: Yardi::Validator::ResidentEventing
- Defined in:
- lib/yardi/validator/resident_eventing.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(action:, parsed_response:, params:) ⇒ ResidentEventing
constructor
Send parased response’s individual resident data to Snowflake via event tracker.
- #send_all_events(resident) ⇒ Object
- #validate! ⇒ Object
Methods inherited from Base
#import_resident_id, #parse_date, #pms_prospect_request_params, #pms_resident_request_params, #remote_id, #send_pms_prospect_event, #send_pms_resident_event
Constructor Details
#initialize(action:, parsed_response:, params:) ⇒ ResidentEventing
Send parased response’s individual resident data to Snowflake via event tracker
10 11 12 13 14 |
# File 'lib/yardi/validator/resident_eventing.rb', line 10 def initialize(action:, parsed_response:, params:) @action = action @response = parsed_response @params = params end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/yardi/validator/resident_eventing.rb', line 7 def action @action end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/yardi/validator/resident_eventing.rb', line 7 def params @params end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
7 8 9 |
# File 'lib/yardi/validator/resident_eventing.rb', line 7 def response @response end |
Instance Method Details
#send_all_events(resident) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yardi/validator/resident_eventing.rb', line 32 def send_all_events(resident) resident['import_resident_id'] = import_resident_id(params) send_pms_resident_event(lease: resident, resident_type: 'PRIMARY', params: params) roommate_nodes = resident.dig('OtherOccupants', 'OtherOccupant') unless roommate_nodes.nil? [roommate_nodes].flatten.map do |roommate| roommate['import_resident_id'] = import_resident_id(params) send_pms_resident_event(lease: roommate, resident_type: 'ROOMMATE', params: params) end end end |
#validate! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/yardi/validator/resident_eventing.rb', line 18 def validate! return if response.nil? body = if response['soap:Envelope'] response['soap:Envelope']['soap:Body'] else response['Envelope']['Body'] end result_node = body["#{action}Response"]["#{action}Result"] path = %w[MITS_ResidentData PropertyResidents Residents Resident] results = [result_node.dig(*path)].flatten.compact results.map { |resident| send_all_events(resident) } end |