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,97 @@
1
+ require 'real_page/validator'
2
+ require 'real_page/utils/snowflake_event_tracker'
3
+
4
+ module RealPage
5
+ module Validator
6
+ # Ensure there is no 'Fault' node in the response body
7
+ class RequestFault
8
+ # @param response [Hash<String, Object>] the XML response parsed into a
9
+ # Hash
10
+ def initialize(response, request_params = nil, request_name = nil)
11
+ @response = response
12
+ @request_params = request_params
13
+ @request_name = request_name
14
+ end
15
+
16
+ # @raise [RealPage::Error::RequestFault] if the response has a fault
17
+ def validate!
18
+ return unless error?
19
+ send_error_to_snowflake
20
+ raise Error::RequestFault.new(error_message, fault_code, details)
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :response, :request_params, :request_name
26
+
27
+ def fault
28
+ response['s:Envelope']['s:Body']['s:Fault']
29
+ end
30
+
31
+ def details
32
+ return unless fault['detail']
33
+ app_fault = fault['detail']['RPXApplicationFault']
34
+ Error::RequestFault::Details.new(
35
+ custom_message: app_fault['CustomMessage'],
36
+ exception_message: app_fault['ExceptionMessage'],
37
+ log_id: app_fault['LogId']
38
+ )
39
+ end
40
+
41
+ def error?
42
+ !fault.nil?
43
+ end
44
+
45
+ def fault_code
46
+ return unless fault
47
+ code = fault['faultcode']
48
+ code = code['__content__'] if code.is_a?(Hash)
49
+ code.strip
50
+ end
51
+
52
+ def error_message
53
+ fault['faultstring']['__content__'] if fault
54
+ end
55
+
56
+ def send_error_to_snowflake
57
+ case request_name
58
+ when 'GetLeasesByTrafficSource'
59
+ send_move_in_report_error_to_snowflake
60
+ when 'ProspectSearch'
61
+ send_prospect_search_error_to_snowflake
62
+ end
63
+ end
64
+
65
+ def send_move_in_report_error_to_snowflake
66
+ Utils::SnowflakeEventTracker.track_pms_resident_event(
67
+ resident_type: 'PRIMARY',
68
+ request_params: request_params,
69
+ phones_count: 0,
70
+ error: error_message
71
+ )
72
+ end
73
+
74
+ def send_prospect_search_error_to_snowflake
75
+ send_roommate_error_to_snowflake
76
+ send_prospect_error_to_snowflake
77
+ end
78
+
79
+ def send_roommate_error_to_snowflake
80
+ Utils::SnowflakeEventTracker.track_pms_resident_event(
81
+ resident_type: 'ROOMMATE',
82
+ request_params: request_params,
83
+ phones_count: 0,
84
+ error: error_message
85
+ )
86
+ end
87
+
88
+ def send_prospect_error_to_snowflake
89
+ Utils::SnowflakeEventTracker.track_pms_prospect_event(
90
+ resident_type: 'ROOMMATE',
91
+ request_params: request_params,
92
+ error: error_message
93
+ )
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,3 @@
1
+ module RealPage
2
+ VERSION = '2.3.0'
3
+ end
data/real_page.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'real_page/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'real_page'
8
+ spec.version = RealPage::VERSION
9
+ spec.authors = ['Tom Collier']
10
+ spec.email = ['collier@apartmentlist.com']
11
+
12
+ spec.summary = %q{A ruby client for RealPage Exchange}
13
+ spec.homepage = 'https://github.com/apartmentlist/real_page'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_runtime_dependency 'faraday', '~> 0.9'
21
+ spec.add_runtime_dependency 'multi_xml', '~> 0.5'
22
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6'
23
+ spec.add_runtime_dependency 'ox', '~> 2.3'
24
+ spec.add_runtime_dependency 'tzinfo', '~> 1.2'
25
+ spec.add_runtime_dependency 'activesupport', '~> 5.2'
26
+
27
+ spec.add_development_dependency 'bundler'
28
+ spec.add_development_dependency 'pry-byebug', '~> 3.3'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.4'
31
+ spec.add_development_dependency 'webmock', '~> 1.21'
32
+ end
metadata ADDED
@@ -0,0 +1,291 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: real_page
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Collier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_xml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ox
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: tzinfo
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '10.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '10.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.4'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.4'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.21'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.21'
167
+ description:
168
+ email:
169
+ - collier@apartmentlist.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".ci"
175
+ - ".gitignore"
176
+ - ".rakeTasks"
177
+ - ".rspec"
178
+ - CHANGELOG.txt
179
+ - CODEOWNERS
180
+ - CODE_OF_CONDUCT.md
181
+ - Gemfile
182
+ - LICENSE.txt
183
+ - README.md
184
+ - Rakefile
185
+ - bin/console
186
+ - bin/setup
187
+ - config/multi_xml.rb
188
+ - lib/real_page.rb
189
+ - lib/real_page/attribute_parser.rb
190
+ - lib/real_page/attribute_parser/base.rb
191
+ - lib/real_page/attribute_parser/boolean.rb
192
+ - lib/real_page/attribute_parser/date.rb
193
+ - lib/real_page/attribute_parser/date_time.rb
194
+ - lib/real_page/attribute_parser/decimal.rb
195
+ - lib/real_page/attribute_parser/integer.rb
196
+ - lib/real_page/attribute_parser/object.rb
197
+ - lib/real_page/attribute_parser/string.rb
198
+ - lib/real_page/document_parser.rb
199
+ - lib/real_page/document_parser/base.rb
200
+ - lib/real_page/document_parser/floor_plan_object.rb
201
+ - lib/real_page/document_parser/guest_cards.rb
202
+ - lib/real_page/document_parser/guest_cards/amenities.rb
203
+ - lib/real_page/document_parser/guest_cards/prospects.rb
204
+ - lib/real_page/document_parser/leases.rb
205
+ - lib/real_page/document_parser/picklist.rb
206
+ - lib/real_page/document_parser/rent_matrices.rb
207
+ - lib/real_page/document_parser/rent_matrices/options.rb
208
+ - lib/real_page/document_parser/rent_matrices/rows.rb
209
+ - lib/real_page/document_parser/unit_object.rb
210
+ - lib/real_page/error/bad_request.rb
211
+ - lib/real_page/error/base.rb
212
+ - lib/real_page/error/invalid_configuration.rb
213
+ - lib/real_page/error/invalid_response.rb
214
+ - lib/real_page/error/request_fault.rb
215
+ - lib/real_page/error/request_fault/details.rb
216
+ - lib/real_page/model/activity.rb
217
+ - lib/real_page/model/address.rb
218
+ - lib/real_page/model/amenity.rb
219
+ - lib/real_page/model/appointment.rb
220
+ - lib/real_page/model/base.rb
221
+ - lib/real_page/model/base/attribute.rb
222
+ - lib/real_page/model/base/attribute_store.rb
223
+ - lib/real_page/model/floor_plan.rb
224
+ - lib/real_page/model/follow_up.rb
225
+ - lib/real_page/model/guest_card.rb
226
+ - lib/real_page/model/lease.rb
227
+ - lib/real_page/model/lease_action.rb
228
+ - lib/real_page/model/phone_number.rb
229
+ - lib/real_page/model/picklist_item.rb
230
+ - lib/real_page/model/preferences.rb
231
+ - lib/real_page/model/prospect.rb
232
+ - lib/real_page/model/quote.rb
233
+ - lib/real_page/model/rent_matrix.rb
234
+ - lib/real_page/model/rent_matrix/concessions.rb
235
+ - lib/real_page/model/rent_matrix/option.rb
236
+ - lib/real_page/model/rent_matrix/row.rb
237
+ - lib/real_page/model/screening.rb
238
+ - lib/real_page/model/unit.rb
239
+ - lib/real_page/model/unit_shown.rb
240
+ - lib/real_page/parameter/list_criterion.rb
241
+ - lib/real_page/request/base.rb
242
+ - lib/real_page/request/get_floor_plan_list.rb
243
+ - lib/real_page/request/get_leases_by_traffic_source.rb
244
+ - lib/real_page/request/get_marketing_sources_by_property.rb
245
+ - lib/real_page/request/get_rent_matrix.rb
246
+ - lib/real_page/request/get_units_by_property.rb
247
+ - lib/real_page/request/prospect_search.rb
248
+ - lib/real_page/request_section.rb
249
+ - lib/real_page/request_section/auth.rb
250
+ - lib/real_page/request_section/get_rent_matrix.rb
251
+ - lib/real_page/request_section/list_criteria.rb
252
+ - lib/real_page/request_section/parameter.rb
253
+ - lib/real_page/request_section/prospect_search_criterion.rb
254
+ - lib/real_page/utils.rb
255
+ - lib/real_page/utils/array_fetcher.rb
256
+ - lib/real_page/utils/configuration_validator.rb
257
+ - lib/real_page/utils/request_fetcher.rb
258
+ - lib/real_page/utils/request_generator.rb
259
+ - lib/real_page/utils/snowflake_event_tracker.rb
260
+ - lib/real_page/validator.rb
261
+ - lib/real_page/validator/move_in_report.rb
262
+ - lib/real_page/validator/prospects_data.rb
263
+ - lib/real_page/validator/request_errors.rb
264
+ - lib/real_page/validator/request_fault.rb
265
+ - lib/real_page/version.rb
266
+ - real_page.gemspec
267
+ homepage: https://github.com/apartmentlist/real_page
268
+ licenses:
269
+ - MIT
270
+ metadata: {}
271
+ post_install_message:
272
+ rdoc_options: []
273
+ require_paths:
274
+ - lib
275
+ required_ruby_version: !ruby/object:Gem::Requirement
276
+ requirements:
277
+ - - ">="
278
+ - !ruby/object:Gem::Version
279
+ version: '0'
280
+ required_rubygems_version: !ruby/object:Gem::Requirement
281
+ requirements:
282
+ - - ">="
283
+ - !ruby/object:Gem::Version
284
+ version: '0'
285
+ requirements: []
286
+ rubyforge_project:
287
+ rubygems_version: 2.7.6.2
288
+ signing_key:
289
+ specification_version: 4
290
+ summary: A ruby client for RealPage Exchange
291
+ test_files: []