amsi 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.ci +7 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +7 -0
  5. data/.rubocop_todo.yml +340 -0
  6. data/CHANGELOG.txt +1 -0
  7. data/Gemfile +8 -1
  8. data/README.md +1 -1
  9. data/Rakefile +1 -1
  10. data/lib/amsi/attribute_parser/base.rb +3 -2
  11. data/lib/amsi/attribute_parser/boolean.rb +1 -0
  12. data/lib/amsi/attribute_parser/date.rb +2 -1
  13. data/lib/amsi/attribute_parser/date_time.rb +7 -1
  14. data/lib/amsi/attribute_parser.rb +5 -3
  15. data/lib/amsi/document_parser/base.rb +4 -3
  16. data/lib/amsi/document_parser/get_moveins.rb +2 -0
  17. data/lib/amsi/document_parser/leases.rb +3 -1
  18. data/lib/amsi/document_parser/properties.rb +4 -0
  19. data/lib/amsi/model/address.rb +10 -10
  20. data/lib/amsi/model/base/attribute.rb +1 -3
  21. data/lib/amsi/model/base.rb +3 -2
  22. data/lib/amsi/model/guest_card.rb +1 -1
  23. data/lib/amsi/model/guest_card_result.rb +6 -6
  24. data/lib/amsi/model/lease.rb +31 -33
  25. data/lib/amsi/model/leasing_agent.rb +8 -8
  26. data/lib/amsi/model/manager.rb +8 -8
  27. data/lib/amsi/model/marketing_source.rb +8 -8
  28. data/lib/amsi/model/occupant.rb +21 -21
  29. data/lib/amsi/model/property.rb +19 -19
  30. data/lib/amsi/model/unit_type.rb +27 -27
  31. data/lib/amsi/parameter/prospect.rb +2 -3
  32. data/lib/amsi/request/add_guest_card.rb +1 -4
  33. data/lib/amsi/request/get_property_residents.rb +1 -1
  34. data/lib/amsi/request_section/add_guest_card.rb +6 -7
  35. data/lib/amsi/request_section/property_list_filter.rb +5 -5
  36. data/lib/amsi/utils/snowflake_event_tracker.rb +18 -27
  37. data/lib/amsi/validator/base.rb +2 -2
  38. data/lib/amsi/validator/prospect_event_validator.rb +2 -5
  39. data/lib/amsi/validator/request_errors.rb +2 -1
  40. data/lib/amsi/validator/request_fault.rb +4 -0
  41. data/lib/amsi/validator/resident_event_validator.rb +2 -5
  42. data/lib/amsi/version.rb +1 -1
  43. data/lib/amsi.rb +1 -1
  44. metadata +4 -2
@@ -49,11 +49,12 @@ module Amsi
49
49
  #
50
50
  # @param attrs [Hash<String, Object>] the response hash from AMSI.
51
51
  # Attribute keys are case insensitive.
52
- def initialize(attrs = {})
52
+ def initialize(attrs = {}, timezone = nil)
53
53
  attrs.each do |attr, value|
54
54
  attribute = self.class.attribute_store.find(attr)
55
55
  next unless attribute
56
- parser = AttributeParser.new(value: value, type: attribute.type)
56
+
57
+ parser = AttributeParser.new(value: value, type: attribute.type, timezone: timezone)
57
58
  instance_variable_set("@#{attribute.name}", parser.parse)
58
59
  end
59
60
  end
@@ -12,7 +12,7 @@ module Amsi
12
12
 
13
13
  date_time_attrs :create_date
14
14
 
15
- alias :id :guest_card_id
15
+ alias id guest_card_id
16
16
  end
17
17
  end
18
18
  end
@@ -8,15 +8,15 @@ module Amsi
8
8
  SUCCESS = 'SUCCESS'.freeze
9
9
  end
10
10
 
11
- string_attrs *%i[
12
- guest_card_id
13
- property_id
14
- status
15
- ]
11
+ string_attrs(*%i[
12
+ guest_card_id
13
+ property_id
14
+ status
15
+ ])
16
16
 
17
17
  integer_attrs :contact_seq_no
18
18
 
19
- alias_method :contact_sequence_number, :contact_seq_no
19
+ alias contact_sequence_number contact_seq_no
20
20
 
21
21
  def success?
22
22
  status == Status::SUCCESS
@@ -15,44 +15,42 @@ module Amsi
15
15
  CANCELLED = 'X'.freeze
16
16
  end
17
17
 
18
- date_attrs *%i[
19
- application_date
20
- lease_begin_date
21
- lease_end_date
22
- lease_sign_date
23
- move_in_date
24
- ]
25
-
26
- string_attrs *%i[
27
- bldg_id
28
- external_reference_id
29
- occu_status_code
30
- occu_status_code_description
31
- property_id
32
- resi_id
33
- unit_id
34
- lease_marketing_source
35
- guest_card_no
36
- ]
18
+ date_attrs(*%i[
19
+ application_date
20
+ lease_begin_date
21
+ lease_end_date
22
+ lease_sign_date
23
+ move_in_date
24
+ ])
25
+
26
+ string_attrs(*%i[
27
+ bldg_id
28
+ external_reference_id
29
+ occu_status_code
30
+ occu_status_code_description
31
+ property_id
32
+ resi_id
33
+ unit_id
34
+ lease_marketing_source
35
+ guest_card_no
36
+ ])
37
37
 
38
38
  decimal_attrs :rent_amount
39
39
 
40
40
  date_time_attrs :guest_first_contact_date
41
41
 
42
- alias_method :begin_date, :lease_begin_date
43
- alias_method :end_date, :lease_end_date
44
- alias_method :sign_date, :lease_sign_date
45
- alias_method :lead_id, :guest_card_no
46
- alias_method :lead_date, :guest_first_contact_date
47
- alias_method :lead_source_code, :lease_marketing_source
48
- alias_method :building_id, :bldg_id
49
- alias_method :resident_id, :resi_id
50
- alias_method :occupant_status_code, :occu_status_code
51
- alias_method :occupant_status_code_description,
52
- :occu_status_code_description
53
-
54
- attr_accessor :occupants
55
- attr_accessor :guest_card
42
+ alias begin_date lease_begin_date
43
+ alias end_date lease_end_date
44
+ alias sign_date lease_sign_date
45
+ alias lead_id guest_card_no
46
+ alias lead_date guest_first_contact_date
47
+ alias lead_source_code lease_marketing_source
48
+ alias building_id bldg_id
49
+ alias resident_id resi_id
50
+ alias occupant_status_code occu_status_code
51
+ alias occupant_status_code_description occu_status_code_description
52
+
53
+ attr_accessor :occupants, :guest_card
56
54
  attr_writer :matched_guest_cards
57
55
 
58
56
  def matched_guest_cards
@@ -3,15 +3,15 @@ require_relative 'base'
3
3
  module Amsi
4
4
  module Model
5
5
  class LeasingAgent < Base
6
- string_attrs *%i[
7
- agent_active_flag
8
- agent_code
9
- agent_name
10
- property_id
11
- ]
6
+ string_attrs(*%i[
7
+ agent_active_flag
8
+ agent_code
9
+ agent_name
10
+ property_id
11
+ ])
12
12
 
13
- alias_method :code, :agent_code
14
- alias_method :name, :agent_name
13
+ alias code agent_code
14
+ alias name agent_name
15
15
 
16
16
  def active?
17
17
  agent_active_flag == 'Y'
@@ -3,14 +3,14 @@ require_relative 'base'
3
3
  module Amsi
4
4
  module Model
5
5
  class Manager < Base
6
- string_attrs *%i[
7
- fax
8
- first_name
9
- last_name
10
- middle_name
11
- phone
12
- salutation
13
- ]
6
+ string_attrs(*%i[
7
+ fax
8
+ first_name
9
+ last_name
10
+ middle_name
11
+ phone
12
+ salutation
13
+ ])
14
14
  end
15
15
  end
16
16
  end
@@ -3,15 +3,15 @@ require_relative 'base'
3
3
  module Amsi
4
4
  module Model
5
5
  class MarketingSource < Base
6
- string_attrs *%i[
7
- property_id
8
- source_code
9
- source_desc
10
- source_active_flag
11
- ]
6
+ string_attrs(*%i[
7
+ property_id
8
+ source_code
9
+ source_desc
10
+ source_active_flag
11
+ ])
12
12
 
13
- alias_method :code, :source_code
14
- alias_method :description, :source_desc
13
+ alias code source_code
14
+ alias description source_desc
15
15
 
16
16
  def active?
17
17
  source_active_flag == 'Y'
@@ -3,30 +3,30 @@ require_relative 'base'
3
3
  module Amsi
4
4
  module Model
5
5
  class Occupant < Base
6
- string_attrs *%i[
7
- bldg_id
8
- email
9
- external_reference_id
10
- occu_first_name
11
- occu_last_name
12
- occu_seq_no
13
- phone_1_no
14
- phone_2_no
15
- property_id
16
- resi_id
17
- responsible_flag
18
- unit_id
19
- ]
6
+ string_attrs(*%i[
7
+ bldg_id
8
+ email
9
+ external_reference_id
10
+ occu_first_name
11
+ occu_last_name
12
+ occu_seq_no
13
+ phone_1_no
14
+ phone_2_no
15
+ property_id
16
+ resi_id
17
+ responsible_flag
18
+ unit_id
19
+ ])
20
20
 
21
21
  decimal_attrs :rent_amount
22
22
 
23
- alias_method :building_id, :bldg_id
24
- alias_method :resident_id, :resi_id
25
- alias_method :sequence_number, :occu_seq_no
26
- alias_method :first_name, :occu_first_name
27
- alias_method :last_name, :occu_last_name
28
- alias_method :phone_1, :phone_1_no
29
- alias_method :phone_2, :phone_2_no
23
+ alias building_id bldg_id
24
+ alias resident_id resi_id
25
+ alias sequence_number occu_seq_no
26
+ alias first_name occu_first_name
27
+ alias last_name occu_last_name
28
+ alias phone_1 phone_1_no
29
+ alias phone_2 phone_2_no
30
30
  end
31
31
  end
32
32
  end
@@ -5,27 +5,27 @@ module Amsi
5
5
  class Property < Base
6
6
  date_attrs :live_date
7
7
 
8
- string_attrs *%i[
9
- property_id
10
- property_name_1
11
- property_name_2
12
- property_addr_email
13
- live_flag
14
- ]
8
+ string_attrs(*%i[
9
+ property_id
10
+ property_name_1
11
+ property_name_2
12
+ property_addr_email
13
+ live_flag
14
+ ])
15
15
 
16
- attr_accessor *%i[
17
- address
18
- leasing_agents
19
- manager
20
- marketing_sources
21
- remit_to_address
22
- unit_types
23
- ]
16
+ attr_accessor(*%i[
17
+ address
18
+ leasing_agents
19
+ manager
20
+ marketing_sources
21
+ remit_to_address
22
+ unit_types
23
+ ])
24
24
 
25
- alias_method :email, :property_addr_email
26
- alias_method :id, :property_id
27
- alias_method :name, :property_name_1
28
- alias_method :name_2, :property_name_2
25
+ alias email property_addr_email
26
+ alias id property_id
27
+ alias name property_name_1
28
+ alias name_2 property_name_2
29
29
 
30
30
  def live?
31
31
  live_flag == 'Y'
@@ -3,36 +3,36 @@ require_relative 'base'
3
3
  module Amsi
4
4
  module Model
5
5
  class UnitType < Base
6
- decimal_attrs *%i[
7
- baths
8
- market_rent
9
- sec_min
10
- standard_renew
11
- mtm_renew
12
- other_renew
13
- ]
6
+ decimal_attrs(*%i[
7
+ baths
8
+ market_rent
9
+ sec_min
10
+ standard_renew
11
+ mtm_renew
12
+ other_renew
13
+ ])
14
14
 
15
- integer_attrs *%i[
16
- bedrooms
17
- rooms
18
- sqftg
19
- unit_type_count
20
- ]
15
+ integer_attrs(*%i[
16
+ bedrooms
17
+ rooms
18
+ sqftg
19
+ unit_type_count
20
+ ])
21
21
 
22
- string_attrs *%i[
23
- property_id
24
- unit_subtype
25
- unit_type
26
- unit_type_desc
27
- ]
22
+ string_attrs(*%i[
23
+ property_id
24
+ unit_subtype
25
+ unit_type
26
+ unit_type_desc
27
+ ])
28
28
 
29
- alias_method :count, :unit_type_count
30
- alias_method :description, :unit_type_desc
31
- alias_method :minimum_security_deposit, :sec_min
32
- alias_method :month_to_month_renew, :mtm_renew
33
- alias_method :sqft, :sqftg
34
- alias_method :subtype, :unit_subtype
35
- alias_method :type, :unit_type
29
+ alias count unit_type_count
30
+ alias description unit_type_desc
31
+ alias minimum_security_deposit sec_min
32
+ alias month_to_month_renew mtm_renew
33
+ alias sqft sqftg
34
+ alias subtype unit_subtype
35
+ alias type unit_type
36
36
  end
37
37
  end
38
38
  end
@@ -4,10 +4,9 @@ module Amsi
4
4
  attr_reader :daytime_phone, :email, :first_name, :last_name
5
5
 
6
6
  def initialize(
7
- daytime_phone: nil,
7
+ last_name:, daytime_phone: nil,
8
8
  email: nil,
9
- first_name: nil,
10
- last_name:
9
+ first_name: nil
11
10
  )
12
11
  @daytime_phone = daytime_phone
13
12
  @email = email
@@ -16,16 +16,13 @@ module Amsi
16
16
  # @see request/base.rb for additional params required by every request.
17
17
  class AddGuestCard < Base
18
18
  def after_initialize(
19
- appointment_date: nil,
19
+ contact_type:, property_id:, prospect:, appointment_date: nil,
20
20
  comments: nil,
21
21
  contact_datetime: nil,
22
- contact_type:,
23
22
  date_needed: nil,
24
23
  initial_source_id: nil,
25
24
  lease_term_desired: nil,
26
25
  leasing_agent_id: nil,
27
- property_id:,
28
- prospect:,
29
26
  qualified: nil,
30
27
  requirements: nil,
31
28
  unit_subtype: nil,
@@ -16,7 +16,7 @@ module Amsi
16
16
  # Valid values in: Amsi::Model::Lease::Status
17
17
  # @see request/base.rb for additional params required by every request.
18
18
  class GetPropertyResidents < Base
19
- def after_initialize(property_id:, lease_status:, include_marketing_source: false, params:)
19
+ def after_initialize(property_id:, lease_status:, params:, include_marketing_source: false)
20
20
  @property_id = property_id
21
21
  @lease_status = lease_status
22
22
  @include_marketing_source = include_marketing_source
@@ -7,16 +7,13 @@ module Amsi
7
7
  private_constant :DATE_FORMAT
8
8
 
9
9
  def initialize(
10
- appointment_date: nil,
10
+ contact_type:, property_id:, prospect:, appointment_date: nil,
11
11
  comments: nil,
12
12
  contact_datetime: nil,
13
- contact_type:,
14
13
  date_needed: nil,
15
14
  initial_source_id: nil,
16
15
  lease_term_desired: nil,
17
16
  leasing_agent_id: nil,
18
- property_id:,
19
- prospect:,
20
17
  requirements: nil,
21
18
  qualified: nil,
22
19
  unit_subtype: nil,
@@ -81,9 +78,11 @@ module Amsi
81
78
  edex.unitsubtype(unit_subtype) if unit_subtype
82
79
  edex.leasingagentid(leasing_agent_id) if leasing_agent_id
83
80
  edex.requirements(requirements) if requirements
84
- edex.comments do |comments_xml|
85
- comments_xml.comment_(comments, date: format_date(Date.today))
86
- end if comments
81
+ if comments
82
+ edex.comments do |comments_xml|
83
+ comments_xml.comment_(comments, date: format_date(Date.today))
84
+ end
85
+ end
87
86
  end
88
87
  end.doc.root
89
88
  end
@@ -3,11 +3,11 @@ module Amsi
3
3
  # Generate the property list filter elements of an AMSI request
4
4
  class PropertyListFilter
5
5
  def initialize(
6
- include_leasing_agents: false,
7
- include_marketing_sources: false,
8
- include_unit_types: false,
9
- property_id: nil
10
- )
6
+ include_leasing_agents: false,
7
+ include_marketing_sources: false,
8
+ include_unit_types: false,
9
+ property_id: nil
10
+ )
11
11
  @include_leasing_agents = include_leasing_agents
12
12
  @include_marketing_sources = include_marketing_sources
13
13
  @include_unit_types = include_unit_types
@@ -7,21 +7,17 @@ module Amsi
7
7
  IMPORT_PMS_PROSPECT_EVENT = 'import_pms_prospect'
8
8
 
9
9
  def self.track_pms_resident_event(
10
- remote_lease_id: nil,
11
- import_resident_id:,
12
- resident_type:,
13
- request_params:,
14
- move_in_date: nil,
15
- lease_to: nil,
16
- lease_from: nil,
17
- first_name_present: false,
18
- last_name_present: false,
19
- email_present: false,
20
- phones_count: 0,
21
- unit_name:,
22
- resident_id: nil,
23
- error: nil
24
- )
10
+ import_resident_id:, resident_type:, request_params:, unit_name:, remote_lease_id: nil,
11
+ move_in_date: nil,
12
+ lease_to: nil,
13
+ lease_from: nil,
14
+ first_name_present: false,
15
+ last_name_present: false,
16
+ email_present: false,
17
+ phones_count: 0,
18
+ resident_id: nil,
19
+ error: nil
20
+ )
25
21
  EventTracker.track_process_events(name: IMPORT_PMS_RESIDENT_EVENT) do |events|
26
22
  events.add_imported_event(
27
23
  EventTracker::ResourceFactory.build_pms_resident(
@@ -63,17 +59,12 @@ module Amsi
63
59
  end
64
60
 
65
61
  def self.track_pms_prospect_event(
66
- remote_lease_id: nil,
67
- request_params:,
68
- first_name_present:,
69
- last_name_present:,
70
- email_present:,
71
- phone_present:,
72
- contact_date: nil,
73
- contact_source: nil,
74
- remote_prospect_id: nil,
75
- error: nil
76
- )
62
+ request_params:, first_name_present:, last_name_present:, email_present:, phone_present:, remote_lease_id: nil,
63
+ contact_date: nil,
64
+ contact_source: nil,
65
+ remote_prospect_id: nil,
66
+ error: nil
67
+ )
77
68
  EventTracker.track_process_events(name: IMPORT_PMS_PROSPECT_EVENT) do |events|
78
69
  events.add_imported_event(
79
70
  EventTracker::ResourceFactory.build_pms_prospect(
@@ -97,7 +88,7 @@ module Amsi
97
88
  first_name_present: first_name_present,
98
89
  last_name_present: last_name_present,
99
90
  email_present: email_present,
100
- phone_present: phone_present,
91
+ phone_present: phone_present
101
92
  ),
102
93
  contact_date: contact_date,
103
94
  contact_source: contact_source,
@@ -6,7 +6,7 @@ module Amsi
6
6
  module Validator
7
7
  class Base
8
8
  def send_pms_resident_event(lease:, params:, error_message: nil)
9
- remote_lease_id, lease_to, lease_from = [ nil ] * 3
9
+ remote_lease_id, lease_to, lease_from = [nil] * 3
10
10
  if lease
11
11
  unit_name = lease.unit_id
12
12
  move_in_date = lease.move_in_date
@@ -18,7 +18,7 @@ module Amsi
18
18
  Utils::SnowflakeEventTracker.track_pms_resident_event(
19
19
  remote_lease_id: remote_lease_id,
20
20
  import_resident_id: import_resident_id(params),
21
- resident_type: index == 0 ? 'PRIMARY': 'ROOMMATE',
21
+ resident_type: index == 0 ? 'PRIMARY' : 'ROOMMATE',
22
22
  request_params: pms_resident_request_params(params),
23
23
  move_in_date: move_in_date&.to_time,
24
24
  lease_to: lease_to,
@@ -4,12 +4,9 @@ require_relative 'base'
4
4
  module Amsi
5
5
  module Validator
6
6
  class ProspectEventValidator < Base
7
+ def initialize(response = nil); end
7
8
 
8
- def initialize(response = nil)
9
- end
10
-
11
- def validate!
12
- end
9
+ def validate!; end
13
10
 
14
11
  # Send parased response's individual prospect data to Snowflake via event tracker
15
12
  def send_event(lease, params)
@@ -26,7 +26,8 @@ module Amsi
26
26
  # node in the contents
27
27
  def validate!
28
28
  return unless error?
29
- raise Amsi::Error::BadRequest.new([error])
29
+
30
+ raise Amsi::Error::BadRequest, [error]
30
31
  end
31
32
 
32
33
  private
@@ -14,6 +14,7 @@ module Amsi
14
14
  # @raise [Amsi::Error::RequestFault] if the response has a fault
15
15
  def validate!
16
16
  return unless error?
17
+
17
18
  raise Error::RequestFault.new(error_message, fault_code, details)
18
19
  end
19
20
 
@@ -27,6 +28,7 @@ module Amsi
27
28
 
28
29
  def details
29
30
  return unless fault['detail']
31
+
30
32
  app_fault = fault['detail'].values.first
31
33
  FaultDetails.new(
32
34
  app_fault['CustomMessage'],
@@ -41,6 +43,7 @@ module Amsi
41
43
 
42
44
  def fault_code
43
45
  return unless fault
46
+
44
47
  code = fault['faultcode']
45
48
  code = code['__content__'] if code.is_a?(Hash)
46
49
  code.strip
@@ -48,6 +51,7 @@ module Amsi
48
51
 
49
52
  def error_message
50
53
  return unless fault
54
+
51
55
  fault_string = fault['faultstring']
52
56
  fault_string = fault_string['__content__'] if fault_string.is_a?(Hash)
53
57
  fault_string.strip
@@ -4,12 +4,9 @@ require_relative 'base'
4
4
  module Amsi
5
5
  module Validator
6
6
  class ResidentEventValidator < Base
7
+ def initialize(response = nil); end
7
8
 
8
- def initialize(response = nil)
9
- end
10
-
11
- def validate!
12
- end
9
+ def validate!; end
13
10
 
14
11
  # Send parased response's individual resident data to Snowflake via event tracker
15
12
  def send_event(lease, params)
data/lib/amsi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Amsi
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
data/lib/amsi.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative '../config/multi_xml.rb'
1
+ require_relative '../config/multi_xml'
2
2
 
3
3
  require 'amsi/error/bad_request'
4
4
  require 'amsi/error/invalid_response'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amsi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Richard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-14 00:00:00.000000000 Z
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -174,6 +174,8 @@ files:
174
174
  - ".ci"
175
175
  - ".gitignore"
176
176
  - ".rspec"
177
+ - ".rubocop.yml"
178
+ - ".rubocop_todo.yml"
177
179
  - CHANGELOG.txt
178
180
  - CODEOWNERS
179
181
  - Gemfile