moxiworks_platform 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 689f505c9ecc6607ad7ab591e0316042465881ca
4
- data.tar.gz: e3f2f5b7728595c908c0975cc4f562ab9fab6418
3
+ metadata.gz: 412995e90bdd8e998839e4d0b8cdb22bea1f4fd3
4
+ data.tar.gz: 677d8ee627b1f471d57c4bcfc68b7af14a141859
5
5
  SHA512:
6
- metadata.gz: d3d89b9b1fad8dd3ebef013180732127dc5167c371814b91527f28fa1549dded642b4c7118bbd378748a5e9bd8dc7ff9771376fd64f61426c9e944112460cecf
7
- data.tar.gz: 8a42949103d936c28a219892ae262be8fcb0934a9e2dd46a045ebba18b2da7f2cc122a22847ba8a33513e7c3e0f6dd9b4b9e3e8e2e493ad846fffee11b28cf64
6
+ metadata.gz: f983e9bfb9da33f7df933fedc90f16391b01ac222f39bb20b1bfa5b1d98464bc376f06044a97a977a83cdebca832a68fa6fa3cd28c6da6920fc626ebb4507d7c
7
+ data.tar.gz: 9dc26db95954e27a9a5193ea7a82c11eed449ebff7ed162f04131e050085791c75754caa3a012941d66e2e49678113073a25e052719a820ae772dc4f02be1684
@@ -11,7 +11,7 @@ require 'moxiworks_platform/action_log'
11
11
  require 'moxiworks_platform/task'
12
12
  require 'moxiworks_platform/email_campaign'
13
13
  require 'moxiworks_platform/company'
14
-
14
+ require 'moxiworks_platform/listing'
15
15
 
16
16
 
17
17
  module MoxiworksPlatform
@@ -11,6 +11,11 @@ module MoxiworksPlatform
11
11
  # @return [String] the Moxi Works Platform ID of the agent
12
12
  attr_accessor :moxi_works_agent_id
13
13
 
14
+ # @!attribute moxi_works_office_id
15
+ #
16
+ # @return [String] the UUID of the office which the Agent is associated
17
+ attr_accessor :moxi_works_office_id
18
+
14
19
  # @!attribute address_street
15
20
  #
16
21
  # @return [String] the agent's address, street and number
@@ -116,11 +121,16 @@ module MoxiworksPlatform
116
121
  # @return [String] url to a thumb size image of the agent
117
122
  attr_accessor :profile_thumb_url
118
123
 
124
+ # @!attribute title
125
+ #
126
+ # @return [String] any business related titles associated with the agent
127
+ attr_accessor :title
128
+
119
129
  # Find an Agent on the Moxi Works Platform
120
130
  # @param [Hash] opts named parameter Hash
121
131
  # @option opts [String] :moxi_works_agent_id *REQUIRED* The Moxi Works Agent ID for the agent to which this contact is to be associated
122
132
  #
123
- # @return [MoxiworksPlatform::Contact]
133
+ # @return [MoxiworksPlatform::Agent]
124
134
  #
125
135
  # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
126
136
  # named parameters aren't included
@@ -178,7 +188,7 @@ module MoxiworksPlatform
178
188
  opts[opt].nil? or opts[opt].to_s.empty?
179
189
  end
180
190
  results = []
181
- json = { 'page_number': 1, 'total_pages': 0, 'tasks':[]}
191
+ json = { 'page_number': 1, 'total_pages': 0, 'agents':[]}
182
192
  RestClient::Request.execute(method: :get,
183
193
  url: url,
184
194
  payload: opts, headers: self.headers) do |response|
@@ -0,0 +1,383 @@
1
+ module MoxiworksPlatform
2
+ # = Moxi Works Platform Listing
3
+ class Listing < MoxiworksPlatform::Resource
4
+
5
+ # @!attribute moxi_works_listing_id
6
+ # moxi_works_listing_id is the Moxi Works Platform ID of the listing
7
+ #
8
+ # this must be set for any Moxi Works Platform transaction
9
+ #
10
+ # @return [String] the Moxi Works Platform ID of the listing
11
+ attr_accessor :moxi_works_listing_id
12
+
13
+ # @!attribute lot_size_acres
14
+ #
15
+ # @return [float] the property acreage of the listing
16
+ attr_accessor :lot_size_acres
17
+
18
+ # @!attribute address
19
+ #
20
+ # @return [String] street address of property
21
+ attr_accessor :address
22
+
23
+ # @!attribute address2
24
+ #
25
+ # @return [String] a second line for street address if needed
26
+ attr_accessor :address2
27
+
28
+ # @!attribute city
29
+ #
30
+ # @return [String] city of property address
31
+ attr_accessor :city
32
+
33
+ # @!attribute state
34
+ #
35
+ # @return [String] state of property address
36
+ attr_accessor :state_or_province
37
+
38
+ # @!attribute postal_code
39
+ #
40
+ # @return [String] zip code of property address
41
+ attr_accessor :postal_code
42
+
43
+ # @!attribute county_or_parish
44
+ #
45
+ # @return [String] county of property address
46
+ attr_accessor :county_or_parish
47
+
48
+ # @!attribute latitude
49
+ #
50
+ # @return [String] latitude of the property
51
+ attr_accessor :latitude
52
+
53
+ # @!attribute longitude
54
+ #
55
+ # @return [String] longitude of the property
56
+ attr_accessor :longitude
57
+
58
+ # @!attribute bathrooms_full
59
+ #
60
+ # @return [Integer|nil] number full bathrooms | nil if no data available
61
+ attr_accessor :bathrooms_full
62
+
63
+ # @!attribute bathrooms_half
64
+ #
65
+ # @return [Integer|nil] number half bathrooms | nil if no data available
66
+ attr_accessor :bathrooms_half
67
+
68
+ # @!attribute bathrooms_one_quarter
69
+ #
70
+ # @return [Integer|nil] number quarter bathrooms | nil if no data available
71
+ attr_accessor :bathrooms_one_quarter
72
+
73
+ # @!attribute bathrooms_partial
74
+ #
75
+ # @return [Integer|nil] number partial bathrooms | nil if no data available
76
+ attr_accessor :bathrooms_partial
77
+
78
+ # @!attribute bathrooms_total_integer
79
+ #
80
+ # @return [Integer|nil] number partial bathrooms | nil if no data available
81
+ attr_accessor :bathrooms_total_integer
82
+
83
+ # @!attribute bathrooms_three_quarter
84
+ #
85
+ # @return [Integer|nil] number three-quarter bathrooms | nil if no data available
86
+ attr_accessor :bathrooms_three_quarter
87
+
88
+ # @!attribute bathrooms_total
89
+ #
90
+ # @return [Integer|nil] number bathrooms | nil if no data available
91
+ attr_accessor :bathrooms_total
92
+
93
+ # @!attribute bedrooms
94
+ #
95
+ # @return [Integer] number of bedrooms
96
+ attr_accessor :bedrooms_total
97
+
98
+ # @!attribute public_remarks
99
+ #
100
+ # @return [String] agent generated comments regarding the property
101
+ attr_accessor :public_remarks
102
+
103
+ # @!attribute modification_timestamp
104
+ #
105
+ # @return [String] string representing date in format 'MM/DD/YYYY'
106
+ attr_accessor :modification_timestamp
107
+
108
+ # @!attribute internet_address_display_yn
109
+ #
110
+ # @return [Boolean] whether to display the address publicly
111
+ attr_accessor :internet_address_display_yn
112
+
113
+ # @!attribute days_on_market
114
+ #
115
+ # @return [Integer] days listing has been on market
116
+ attr_accessor :days_on_market
117
+
118
+ # @!attribute listing_contract_date
119
+ #
120
+ # @return [String] string representing date in format 'MM/DD/YYYY'
121
+ attr_accessor :listing_contract_date
122
+
123
+ # @!attribute created_date
124
+ #
125
+ # @return [String] string representing date in format 'MM/DD/YYYY'
126
+ attr_accessor :created_date
127
+
128
+ # @!attribute elementary_school
129
+ #
130
+ # @return [String] elementary school for the property
131
+ attr_accessor :elementary_school
132
+
133
+ # @!attribute garage_spaces
134
+ #
135
+ # @return [Integer] garage spaces for the property
136
+ attr_accessor :garage_spaces
137
+
138
+ # @!attribute waterfront_yn
139
+ #
140
+ # @return [Boolean] whether the property has waterfront acreage
141
+ attr_accessor :waterfront_yn
142
+
143
+ # @!attribute high_school
144
+ #
145
+ # @return [String] High school for property
146
+ attr_accessor :high_school
147
+
148
+ # @!attribute association_fee
149
+ #
150
+ # @return [Integer] HOA fees for property
151
+ attr_accessor :association_fee
152
+
153
+ # @!attribute list_office_name
154
+ #
155
+ # @return [String] name office responsible for listing
156
+ attr_accessor :list_office_name
157
+
158
+ # @!attribute list_price
159
+ #
160
+ # @return [Integer] listed price
161
+ attr_accessor :list_price
162
+
163
+ # @!attribute listing_id
164
+ #
165
+ # @return [String] the mls number associated with the listing
166
+ attr_accessor :listing_id
167
+
168
+ # @!attribute list_agent_full_name
169
+ #
170
+ # @return [String] name of listing agent
171
+ attr_accessor :list_agent_full_name
172
+
173
+ # @!attribute lot_size_square_feet
174
+ #
175
+ # @return [Integer] square footage of lot
176
+ attr_accessor :lot_size_square_feet
177
+
178
+ # @!attribute middle_or_junior_school
179
+ #
180
+ # @return [String] Middle school for property
181
+ attr_accessor :middle_or_junior_school
182
+
183
+ # @!attribute list_office_aor
184
+ #
185
+ # @return [String] MLS the listing is listed with
186
+ attr_accessor :list_office_aor
187
+
188
+ # @!attribute internet_entire_listing_display_yn
189
+ #
190
+ # @return [Boolean] whether to display listing on internet
191
+ attr_accessor :internet_entire_listing_display_yn
192
+
193
+ # @!attribute on_market
194
+ #
195
+ # @return [Boolean] whether the listing is on market
196
+ attr_accessor :on_market
197
+
198
+ # @!attribute pool_yn
199
+ #
200
+ # @return [Boolean] whether there is a pool
201
+ attr_accessor :pool_yn
202
+
203
+ # @!attribute property_type
204
+ #
205
+ # @return [String] type of property, could be 'Rental' 'Residential' 'Condo-Coop' 'Townhouse' 'Land' 'Multifamily'
206
+ attr_accessor :property_type
207
+
208
+ # @!attribute tax_annual_amount
209
+ #
210
+ # @return [Integer] Annual property tax for the property
211
+ attr_accessor :tax_annual_amount
212
+
213
+ # @!attribute tax_year
214
+ #
215
+ # @return [Integer] assessment year that property_tax reflects
216
+ attr_accessor :tax_year
217
+
218
+ # @!attribute single_story
219
+ #
220
+ # @return [Boolean] whether the building is single story
221
+ attr_accessor :single_story
222
+
223
+ # @!attribute living_area
224
+ #
225
+ # @return [Integer] square footage of the building
226
+ attr_accessor :living_area
227
+
228
+ # @!attribute title
229
+ #
230
+ # @return [String] a short description of the property
231
+ attr_accessor :title
232
+
233
+ # @!attribute view_yn
234
+ #
235
+ # @return [Boolean] whether the property has a view
236
+ attr_accessor :view_yn
237
+
238
+ # @!attribute year_built
239
+ #
240
+ # @return [Integer] year the building was built
241
+ attr_accessor :year_built
242
+
243
+ # @!attribute listing_images
244
+ #
245
+ # @return [Array] array of image Hashes in the format
246
+ # {
247
+ # image_thumb_url: [String] url to thumbail size image (smallest),
248
+ # image_small_url: [String] url to small size image (small),
249
+ # image_full_url: [String] url to full size image (medium),
250
+ # image_gallery_url: [String] url to gallery size image (large),
251
+ # image_raw_url: [String] url to raw image (largest)
252
+ # }
253
+ attr_accessor :listing_images
254
+
255
+
256
+
257
+ # Find a listing on the Moxi Works Platform
258
+ # @param [Hash] opts named parameter Hash
259
+ # @option opts [String] :moxi_works_listing_id *REQUIRED* The Moxi Works Listing ID for the listing
260
+ # @option opts [String] :moxi_works_company_id *REQUIRED* The Moxi Works Company ID For the search (use Company.search to determine available moxi_works_company_id)
261
+ #
262
+ # @return [MoxiworksPlatform::Listing]
263
+ #
264
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
265
+ # named parameters aren't included
266
+ #
267
+ def self.find(opts={})
268
+ url = "#{MoxiworksPlatform::Config.url}/api/listings/#{opts[:moxi_works_listing_id]}"
269
+ self.send_request(:get, opts, url)
270
+ end
271
+
272
+ def self.send_request(method, opts={}, url=nil)
273
+ url ||= "#{MoxiworksPlatform::Config.url}/api/listings"
274
+ required_opts = [:moxi_works_listing_id, :moxi_works_company_id]
275
+ raise ::MoxiworksPlatform::Exception::ArgumentError,
276
+ 'arguments must be passed as named parameters' unless opts.is_a? Hash
277
+ required_opts.each do |opt|
278
+ raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
279
+ opts[opt].nil? or opts[opt].to_s.empty?
280
+ end
281
+
282
+ RestClient::Request.execute(method: method,
283
+ url: url,
284
+ payload: opts, headers: self.headers) do |response|
285
+ puts response if MoxiworksPlatform::Config.debug
286
+ self.check_for_error_in_response(response)
287
+ json = JSON.parse(response)
288
+ json = self.underscore_attribute_names json
289
+ return false if not json['status'].nil? and json['status'] =='fail'
290
+ self.new(json) unless json.nil? or json.empty?
291
+ end
292
+ end
293
+
294
+ # Search For Listings in Moxi Works Platform
295
+ # @param [Hash] opts named parameter Hash
296
+ # @option opts [String] :moxi_works_company_id *REQUIRED* The Moxi Works Company ID For the search (use Company.search to determine available moxi_works_company_id)
297
+ # @option opts [Integer] :updated_since *REQUIRED* Unix timestamp; Only Listings updated after this date will be returned
298
+ # @option opts [String] :moxi_works_agent_id The Moxi Works Agent ID For the search (use Agent.search to determine available moxi_works_agent_id)
299
+ #
300
+ #
301
+ # optional Search parameters
302
+ #
303
+ # @option opts [Integer] :page_number the page of results to return
304
+ #
305
+ # @return [Hash] with the format:
306
+ # {
307
+ # page_number: [Integer],
308
+ # total_pages: [Integer],
309
+ # listings: [Array] containing MoxiworkPlatform::Listing objects
310
+ # }
311
+ #
312
+ #
313
+ # @raise ::MoxiworksPlatform::Exception::ArgumentError if required
314
+ # named parameters aren't included
315
+ #
316
+ # @example
317
+ # results = MoxiworksPlatform::Listing.search(
318
+ # moxi_works_company_id: 'the_company',
319
+ # updated_since: Time.now.to_i - 1296000,
320
+ # moxi_works_agent_id: 'abc123'
321
+ # )
322
+ #
323
+ # @block |Array|
324
+ # if you pass a block with the logic you want to perform on all listings,
325
+ # you can have all listings processed in a single call
326
+ #
327
+ # @example
328
+ # MoxiworksPlatform::Listing.search(
329
+ # moxi_works_company_id: 'the_company',
330
+ # updated_since: Time.now.to_i - 131297832) { |page_of_listings| puts page_of_listings.count }
331
+ #
332
+ def self.search(opts={}, &block)
333
+ url ||= "#{MoxiworksPlatform::Config.url}/api/listings"
334
+ required_opts = [:moxi_works_company_id, :updated_since]
335
+ required_opts.each do |opt|
336
+ raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if
337
+ opts[opt].nil? or opts[opt].to_s.empty?
338
+ end
339
+ results = []
340
+ json = {'listings': [], 'last_page': true}
341
+ RestClient::Request.execute(method: :get,
342
+ url: url,
343
+ payload: opts, headers: self.headers) do |response|
344
+ puts response if MoxiworksPlatform::Config.debug
345
+ self.check_for_error_in_response(response)
346
+ json = JSON.parse(response)
347
+ json = self.underscore_attribute_names json
348
+ json['listings'].each do |r|
349
+ results << MoxiworksPlatform::Listing.new(r) unless r.nil? or r.empty?
350
+ end
351
+ json['listings'] = results
352
+ end
353
+ if block_given?
354
+ yield(json['listings'])
355
+ unless json['final_page']
356
+ last_listing = json['listings'].last
357
+ last_listing_id = (last_listing.nil?) ? nil : last_listing.moxi_works_listing_id
358
+ MoxiworksPlatform::Listing.search(opts.merge(last_moxi_works_listing_id: last_listing_id), &block) if last_listing_id
359
+ end
360
+ end
361
+ json
362
+ end
363
+
364
+ def self.underscore_attribute_names(hash)
365
+ hash.keys.each do |key|
366
+ hash[key] = self.underscore_attribute_names hash[key] if hash[key].is_a? Hash
367
+ if hash[key].is_a? Array
368
+ array = hash[key]
369
+ new_array = []
370
+ array.each do |member|
371
+ new_array << self.underscore_attribute_names(member)
372
+ end
373
+ hash[key] = new_array
374
+ end
375
+ underscored = Resource.underscore(key)
376
+ hash[underscored] = hash.delete(key)
377
+ end
378
+ hash
379
+ end
380
+
381
+
382
+ end
383
+ end
@@ -158,6 +158,14 @@ module MoxiworksPlatform
158
158
  []
159
159
  end
160
160
 
161
+ def self.underscore(attr)
162
+ attr.gsub(/::/, '/').
163
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
164
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
165
+ tr("-", "_").
166
+ downcase
167
+ end
168
+
161
169
  end
162
170
 
163
171
  end
@@ -1,3 +1,3 @@
1
1
  module MoxiworksPlatform
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moxiworks_platform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tres Wong-Godfrey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-13 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,6 +93,7 @@ files:
93
93
  - lib/moxiworks_platform/event.rb
94
94
  - lib/moxiworks_platform/exception.rb
95
95
  - lib/moxiworks_platform/group.rb
96
+ - lib/moxiworks_platform/listing.rb
96
97
  - lib/moxiworks_platform/resource.rb
97
98
  - lib/moxiworks_platform/task.rb
98
99
  - lib/moxiworks_platform/version.rb