real_page 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/.ci +139 -0
  3. data/.gitignore +3 -0
  4. data/.rakeTasks +7 -0
  5. data/.rspec +3 -0
  6. data/CHANGELOG.txt +12 -0
  7. data/CODEOWNERS +1 -0
  8. data/CODE_OF_CONDUCT.md +13 -0
  9. data/Gemfile +6 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +588 -0
  12. data/Rakefile +7 -0
  13. data/bin/console +15 -0
  14. data/bin/setup +7 -0
  15. data/config/multi_xml.rb +4 -0
  16. data/lib/real_page.rb +54 -0
  17. data/lib/real_page/attribute_parser.rb +48 -0
  18. data/lib/real_page/attribute_parser/base.rb +21 -0
  19. data/lib/real_page/attribute_parser/boolean.rb +25 -0
  20. data/lib/real_page/attribute_parser/date.rb +28 -0
  21. data/lib/real_page/attribute_parser/date_time.rb +23 -0
  22. data/lib/real_page/attribute_parser/decimal.rb +15 -0
  23. data/lib/real_page/attribute_parser/integer.rb +15 -0
  24. data/lib/real_page/attribute_parser/object.rb +13 -0
  25. data/lib/real_page/attribute_parser/string.rb +13 -0
  26. data/lib/real_page/document_parser.rb +6 -0
  27. data/lib/real_page/document_parser/base.rb +51 -0
  28. data/lib/real_page/document_parser/floor_plan_object.rb +30 -0
  29. data/lib/real_page/document_parser/guest_cards.rb +102 -0
  30. data/lib/real_page/document_parser/guest_cards/amenities.rb +34 -0
  31. data/lib/real_page/document_parser/guest_cards/prospects.rb +45 -0
  32. data/lib/real_page/document_parser/leases.rb +37 -0
  33. data/lib/real_page/document_parser/picklist.rb +38 -0
  34. data/lib/real_page/document_parser/rent_matrices.rb +39 -0
  35. data/lib/real_page/document_parser/rent_matrices/options.rb +31 -0
  36. data/lib/real_page/document_parser/rent_matrices/rows.rb +30 -0
  37. data/lib/real_page/document_parser/unit_object.rb +30 -0
  38. data/lib/real_page/error/bad_request.rb +18 -0
  39. data/lib/real_page/error/base.rb +9 -0
  40. data/lib/real_page/error/invalid_configuration.rb +9 -0
  41. data/lib/real_page/error/invalid_response.rb +9 -0
  42. data/lib/real_page/error/request_fault.rb +19 -0
  43. data/lib/real_page/error/request_fault/details.rb +17 -0
  44. data/lib/real_page/model/activity.rb +39 -0
  45. data/lib/real_page/model/address.rb +17 -0
  46. data/lib/real_page/model/amenity.rb +14 -0
  47. data/lib/real_page/model/appointment.rb +23 -0
  48. data/lib/real_page/model/base.rb +63 -0
  49. data/lib/real_page/model/base/attribute.rb +56 -0
  50. data/lib/real_page/model/base/attribute_store.rb +37 -0
  51. data/lib/real_page/model/floor_plan.rb +33 -0
  52. data/lib/real_page/model/follow_up.rb +34 -0
  53. data/lib/real_page/model/guest_card.rb +49 -0
  54. data/lib/real_page/model/lease.rb +36 -0
  55. data/lib/real_page/model/lease_action.rb +32 -0
  56. data/lib/real_page/model/phone_number.rb +13 -0
  57. data/lib/real_page/model/picklist_item.rb +10 -0
  58. data/lib/real_page/model/preferences.rb +25 -0
  59. data/lib/real_page/model/prospect.rb +35 -0
  60. data/lib/real_page/model/quote.rb +56 -0
  61. data/lib/real_page/model/rent_matrix.rb +16 -0
  62. data/lib/real_page/model/rent_matrix/concessions.rb +15 -0
  63. data/lib/real_page/model/rent_matrix/option.rb +19 -0
  64. data/lib/real_page/model/rent_matrix/row.rb +18 -0
  65. data/lib/real_page/model/screening.rb +22 -0
  66. data/lib/real_page/model/unit.rb +61 -0
  67. data/lib/real_page/model/unit_shown.rb +48 -0
  68. data/lib/real_page/parameter/list_criterion.rb +14 -0
  69. data/lib/real_page/request/base.rb +89 -0
  70. data/lib/real_page/request/get_floor_plan_list.rb +45 -0
  71. data/lib/real_page/request/get_leases_by_traffic_source.rb +59 -0
  72. data/lib/real_page/request/get_marketing_sources_by_property.rb +23 -0
  73. data/lib/real_page/request/get_rent_matrix.rb +57 -0
  74. data/lib/real_page/request/get_units_by_property.rb +39 -0
  75. data/lib/real_page/request/prospect_search.rb +50 -0
  76. data/lib/real_page/request_section.rb +6 -0
  77. data/lib/real_page/request_section/auth.rb +31 -0
  78. data/lib/real_page/request_section/get_rent_matrix.rb +32 -0
  79. data/lib/real_page/request_section/list_criteria.rb +29 -0
  80. data/lib/real_page/request_section/parameter.rb +31 -0
  81. data/lib/real_page/request_section/prospect_search_criterion.rb +24 -0
  82. data/lib/real_page/utils.rb +6 -0
  83. data/lib/real_page/utils/array_fetcher.rb +35 -0
  84. data/lib/real_page/utils/configuration_validator.rb +20 -0
  85. data/lib/real_page/utils/request_fetcher.rb +30 -0
  86. data/lib/real_page/utils/request_generator.rb +52 -0
  87. data/lib/real_page/utils/snowflake_event_tracker.rb +107 -0
  88. data/lib/real_page/validator.rb +6 -0
  89. data/lib/real_page/validator/move_in_report.rb +65 -0
  90. data/lib/real_page/validator/prospects_data.rb +93 -0
  91. data/lib/real_page/validator/request_errors.rb +97 -0
  92. data/lib/real_page/validator/request_fault.rb +97 -0
  93. data/lib/real_page/version.rb +3 -0
  94. data/real_page.gemspec +32 -0
  95. metadata +291 -0
@@ -0,0 +1,59 @@
1
+ require 'real_page/document_parser/leases'
2
+ require 'real_page/request_section/parameter'
3
+
4
+ require_relative 'base'
5
+
6
+ module RealPage
7
+ module Request
8
+ # Retrieve current resident leases for a given traffic source that begin
9
+ # within the specified date range.
10
+ #
11
+ # Required intializer parameters:
12
+ #
13
+ # @param pmc_id [String] the unique identifier for the property management
14
+ # company in RealPage
15
+ # @param site_id [String] the unique identifier for the property in RealPage
16
+ # @param traffic_source_id [String] the identifier for the
17
+ # marketing/traffic source used to query leases
18
+ # @param start_date [Date] the start of the date range for the query
19
+ # @param end_date [Date] the end of the date range for the query
20
+ class GetLeasesByTrafficSource < Base
21
+ private
22
+
23
+ attr_reader :traffic_source_id, :start_date, :end_date, :request_params
24
+
25
+ def after_initialize(params)
26
+ %i[traffic_source_id start_date end_date].each do |required_param|
27
+ unless params[required_param]
28
+ raise ArgumentError, "Params must include :#{required_param}"
29
+ end
30
+ end
31
+ @traffic_source_id = params[:traffic_source_id]
32
+ @start_date = params[:start_date]
33
+ @end_date = params[:end_date]
34
+ @request_params = params
35
+ end
36
+
37
+ def parser
38
+ DocumentParser::Leases.new(
39
+ request_params: request_params,
40
+ request_name: request_name
41
+ )
42
+ end
43
+
44
+ def request_name
45
+ self.class.name.split('::').last
46
+ end
47
+
48
+ def sections
49
+ [
50
+ RequestSection::Parameter.new(
51
+ traffic_source_id: traffic_source_id,
52
+ start_date: start_date,
53
+ end_date: end_date
54
+ )
55
+ ]
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,23 @@
1
+ require 'real_page/document_parser/picklist'
2
+
3
+ require_relative 'base'
4
+
5
+ module RealPage
6
+ module Request
7
+ # Retrieve marketing sources information for a specific property. Marketing
8
+ # sources are also referred to as traffic sources throughout RealPage.
9
+ #
10
+ # Required intializer parameters:
11
+ #
12
+ # @param pmc_id [String] the unique identifier for the property management
13
+ # company in RealPage
14
+ # @param site_id [String] the unique identifier for the property in RealPage
15
+ class GetMarketingSourcesByProperty < Base
16
+ private
17
+
18
+ def parser
19
+ DocumentParser::Picklist.new(soap_action)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,57 @@
1
+ require 'real_page/document_parser/rent_matrices'
2
+ require 'real_page/request_section/get_rent_matrix'
3
+
4
+ require_relative 'base'
5
+
6
+ module RealPage
7
+ module Request
8
+ # Retrieve pricing data for units in a property.
9
+ #
10
+ # Required intializer parameters:
11
+ #
12
+ # @param least_term [Integer] Proposed lease term duration, in months
13
+ # @param need_by_date [Date] Proposed date when prospect would move in to
14
+ # any apartment
15
+ # @param pmc_id [String] the unique identifier for the property management
16
+ # company in RealPage
17
+ # @param site_id [String] the unique identifier for the property in RealPage
18
+ # @param unit_ids [Array<Integer|String>] Array of integer Unit ID numbers
19
+ # as acquired from GetUnitsByProperty
20
+ # @param viewing_quote_only [true|false] Identifies whether the user is
21
+ # viewing or creating new quote
22
+ class GetRentMatrix < Base
23
+ private
24
+
25
+ attr_reader :lease_term, :need_by_date, :unit_ids, :viewing_quote_only
26
+
27
+ def after_initialize(params)
28
+ %i[
29
+ lease_term
30
+ need_by_date
31
+ unit_ids
32
+ viewing_quote_only
33
+ ].each do |required_param|
34
+ unless params[required_param]
35
+ raise ArgumentError, "Params must include :#{required_param}"
36
+ end
37
+ instance_variable_set("@#{required_param}", params[required_param])
38
+ end
39
+ end
40
+
41
+ def sections
42
+ [
43
+ RequestSection::GetRentMatrix.new(
44
+ lease_term: lease_term,
45
+ need_by_date: need_by_date,
46
+ unit_ids: unit_ids,
47
+ viewing_quote_only: viewing_quote_only
48
+ )
49
+ ]
50
+ end
51
+
52
+ def parser
53
+ DocumentParser::RentMatrices.new
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,39 @@
1
+ require 'real_page/document_parser/unit_object'
2
+ require 'real_page/request_section/list_criteria'
3
+
4
+ require_relative 'base'
5
+
6
+ module RealPage
7
+ module Request
8
+ # Retrieve marketing sources information for a specific property. Marketing
9
+ # sources are also referred to as traffic sources throughout RealPage.
10
+ #
11
+ # Required intializer parameters:
12
+ #
13
+ # @param pmc_id [String] the unique identifier for the property management
14
+ # company in RealPage
15
+ # @param site_id [String] the unique identifier for the property in RealPage
16
+ #
17
+ # Optional initializer parameters:
18
+ #
19
+ # @param list_criteria [Array<RealPage::Parameter::ListCriterion>] the query
20
+ # criteria
21
+ class GetUnitsByProperty < Base
22
+ private
23
+
24
+ attr_reader :list_criteria
25
+
26
+ def after_initialize(params)
27
+ @list_criteria = params[:list_criteria] || []
28
+ end
29
+
30
+ def sections
31
+ [RequestSection::ListCriteria.new(list_criteria: list_criteria)]
32
+ end
33
+
34
+ def parser
35
+ DocumentParser::UnitObject.new
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,50 @@
1
+ require 'real_page/document_parser/guest_cards'
2
+ require 'real_page/request_section/prospect_search_criterion'
3
+
4
+ require_relative 'base'
5
+
6
+ module RealPage
7
+ module Request
8
+ # Retrieve information about a known Prospect
9
+ #
10
+ # Required initializer parameters:
11
+ #
12
+ # @param pmc_id [String] the unique identifier for the property management
13
+ # company in RealPage
14
+ # @param site_id [String] the unique identifier for the property in RealPage
15
+ # @guest_card_id [String] the unique identifier for the guest_card in
16
+ # RealPage
17
+ class ProspectSearch < Base
18
+ private
19
+
20
+ attr_reader :guest_card_id, :request_params
21
+
22
+ def after_initialize(params)
23
+ @guest_card_id = params[:guest_card_id]
24
+ unless guest_card_id
25
+ raise ArgumentError, 'Params must include :guest_card_id'
26
+ end
27
+ @request_params = params
28
+ end
29
+
30
+ def parser
31
+ DocumentParser::GuestCards.new(
32
+ request_params: request_params,
33
+ request_name: request_name
34
+ )
35
+ end
36
+
37
+ def request_name
38
+ self.class.name.split('::').last
39
+ end
40
+
41
+ def sections
42
+ [
43
+ RequestSection::ProspectSearchCriterion.new(
44
+ guest_card_id: guest_card_id
45
+ )
46
+ ]
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,6 @@
1
+ module RealPage
2
+ module RequestSection
3
+ end
4
+
5
+ private_constant :RequestSection
6
+ end
@@ -0,0 +1,31 @@
1
+ require 'real_page/request_section'
2
+
3
+ module RealPage
4
+ module RequestSection
5
+ # Generate the auth section of a RealPage request
6
+ class Auth
7
+ SYSTEM = 'OneSite'.freeze
8
+ private_constant :SYSTEM
9
+
10
+ def initialize(pmc_id:, site_id:)
11
+ @pmc_id = pmc_id
12
+ @site_id = site_id
13
+ end
14
+
15
+ def generate(xml_builder)
16
+ xml_builder.auth do
17
+ xml_builder.pmcid pmc_id
18
+ xml_builder.siteid site_id
19
+ xml_builder.username RealPage.config.username
20
+ xml_builder.password RealPage.config.password
21
+ xml_builder.licensekey RealPage.config.license_key
22
+ xml_builder.system SYSTEM
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ attr_reader :pmc_id, :site_id
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ require 'real_page/request_section'
2
+
3
+ module RealPage
4
+ module RequestSection
5
+ # Generate the list criteria section of a RealPage request
6
+ class GetRentMatrix
7
+ def initialize(lease_term:, need_by_date:, unit_ids:, viewing_quote_only:)
8
+ @lease_term = lease_term
9
+ @need_by_date = need_by_date
10
+ @unit_ids = unit_ids
11
+ @viewing_quote_only = viewing_quote_only
12
+ end
13
+
14
+ def generate(xml_builder)
15
+ xml_builder.getrentmatrix do
16
+ xml_builder.NeededByDate need_by_date
17
+ xml_builder.LeaseTerm lease_term
18
+ xml_builder.unitids do
19
+ unit_ids.each do |unit_id|
20
+ xml_builder.int unit_id
21
+ end
22
+ end
23
+ xml_builder.viewingQuoteOnly viewing_quote_only ? 1 : 0
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :lease_term, :need_by_date, :unit_ids, :viewing_quote_only
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,29 @@
1
+ require 'real_page/request_section'
2
+
3
+ module RealPage
4
+ module RequestSection
5
+ # Generate the list criteria section of a RealPage request
6
+ class ListCriteria
7
+ def initialize(list_criteria:)
8
+ @list_criteria = list_criteria
9
+ end
10
+
11
+ def generate(xml_builder)
12
+ xml_builder.listCriteria do
13
+ list_criteria.each do |criterion|
14
+ xml_builder.ListCriterion do
15
+ xml_builder.name criterion.name
16
+ xml_builder.singlevalue criterion.single_value
17
+ xml_builder.minvalue criterion.min_value if criterion.min_value
18
+ xml_builder.maxvalue criterion.max_value if criterion.max_value
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :list_criteria
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ require 'real_page/request_section'
2
+
3
+ module RealPage
4
+ module RequestSection
5
+ # Generate the parameter section of a RealPage request
6
+ class Parameter
7
+ def initialize(start_date:, end_date:, traffic_source_id:)
8
+ @start_date = start_date
9
+ @end_date = end_date
10
+ @traffic_source_id = traffic_source_id
11
+ end
12
+
13
+ def generate(xml_builder)
14
+ xml_builder.parameter do
15
+ xml_builder.startdate format_date(start_date)
16
+ xml_builder.enddate format_date(end_date)
17
+ # As documented, this node name is a typo
18
+ xml_builder.trafficesourceid traffic_source_id
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :start_date, :end_date, :traffic_source_id
25
+
26
+ def format_date(date)
27
+ date.strftime('%Y-%m-%d')
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ require 'real_page/request_section'
2
+
3
+ module RealPage
4
+ module RequestSection
5
+ # Generate the prospectSearchCriterion section of a RealPage request
6
+ class ProspectSearchCriterion
7
+ def initialize(guest_card_id:)
8
+ @guest_card_id = guest_card_id
9
+ end
10
+
11
+ def generate(xml_builder)
12
+ xml_builder.prospectSearchCriterion do
13
+ xml_builder.ProspectSearchCriterion do
14
+ xml_builder.guestcardid guest_card_id
15
+ end
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :guest_card_id
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ module RealPage
2
+ module Utils
3
+ end
4
+
5
+ private_constant :Utils
6
+ end
@@ -0,0 +1,35 @@
1
+ require 'real_page/utils'
2
+
3
+ module RealPage
4
+ module Utils
5
+ # Fetch an array from a hash that was generated by parsing XML using
6
+ # MultiXml. If you provide a model to instantiate, an instance will be
7
+ # initialized with each data element.
8
+ class ArrayFetcher
9
+ def initialize(hash:, key:, model: nil)
10
+ @hash = hash
11
+ @key = key
12
+ @model = model
13
+ end
14
+
15
+ # @return [Array] take the MultiXml hash and return a proper array
16
+ def fetch
17
+ return [] if empty?
18
+ value = hash[key]
19
+ value = [value] unless value.is_a?(Array)
20
+ return value unless model
21
+ value.map { |v| model.new(v) }
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :hash, :key, :model
27
+
28
+ def empty?
29
+ return true if hash.nil?
30
+ return true if hash.is_a?(String) && hash.strip! == ''
31
+ hash.empty?
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,20 @@
1
+ require 'real_page/utils'
2
+
3
+ module RealPage
4
+ module Utils
5
+ class ConfigurationValidator
6
+ REQUIRED_KEYS = %i[username password license_key web_service_url].freeze
7
+ private_constant :REQUIRED_KEYS
8
+
9
+ def validate!
10
+ missing_keys = REQUIRED_KEYS.select do |key|
11
+ RealPage.config.send(key).nil?
12
+ end
13
+ unless missing_keys.empty?
14
+ raise Error::InvalidConfiguration,
15
+ "Missing configuration for #{missing_keys.join(', ')}"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end