spark_api 1.3.26 → 1.3.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmZlZWJkMzM5MDNjZjk3OTk1NTMxOGQwNmRiMTgyYjAyMmI5MjkwNg==
4
+ NDVkM2ZjNzEwMTE4ZDQ5ODE0MjY5NjUxZjNiMjEzNDViMjdhMmM3Mg==
5
5
  data.tar.gz: !binary |-
6
- NWUzZjlmOGJkOWYwZjgyMWQzODZjNGE5OTgyNzYxNjc5ZTk4MzRkOA==
6
+ ZTA0NGE5NWRmNmI1Mzc4Y2Y3NDRhMzBjMjQ2MzgzZWFhNDNhNWFmMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjM3MjdhOGMyZjUzMWE4NjY2MGE1MjBlNWQxYjQxZjM3YWNkYTAzMTlkMjUz
10
- NjNhYjRkNjAyNzgxMDZkNzM0OWE1Y2MxZGU2NjBhZDk4MWMzOTEwZTFlN2U4
11
- ZjExNjdlZTBhMDQxNTQ4ZGIxZTA2NWRjNDQxNzIzZjc5MTcyM2U=
9
+ YTVlMmNiZjVlNDcyYzBmMDBlY2RjNzY2MzMyY2Q3YTRhZWU2OTE3MmFkMzcz
10
+ MDk3YzZjNmE5MzBiNWRiOGFjY2QxYWJlZWJiZmJmMzg5NmVkZDkzOTI3OTQ1
11
+ OTZmYWI5NTFiYjNhZjliNzhmYTJiMjBmMDhhMzE3NDhjMzllMWI=
12
12
  data.tar.gz: !binary |-
13
- OWZkMzAwNmY1ZDQ1MGQ2MWFjZDg0NjU1MDdhNTUxZjE1NmY2NDVhZTE4YWE4
14
- YThmZjMwYjY2Y2YwMmI2NWY2ODMyOTZmMzI5ZWRmMGU5YTYzODZkMzJkNWQ2
15
- MWQxZDA4YWU5ZGYzYjdiMzA0ZjVlYjRmMDU0YmIyZDVkMGNhZTU=
13
+ NzM2ZmY1NTZhNzgxYjZhMTlmM2Y0Nzg1Y2Q2M2ZmZDVmZDBjM2M2YjMyNGJi
14
+ Nzg4Mjc0MWZlNDI3ODczMDY0NTdhYWRhZjlhM2JjMjg4NjJiMDM1MzJlYjI4
15
+ MDc0MGQxZmZhYmIwNzM4MjVhYTM4YzBhNzljMzA4NDQxZmQ1ZDA=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.26
1
+ 1.3.27
@@ -18,6 +18,7 @@ require 'spark_api/models/listing'
18
18
  require 'spark_api/models/listing_cart'
19
19
  require 'spark_api/models/market_statistics'
20
20
  require 'spark_api/models/message'
21
+ require 'spark_api/models/news_feed_meta'
21
22
  require 'spark_api/models/newsfeed'
22
23
  require 'spark_api/models/note'
23
24
  require 'spark_api/models/notification'
@@ -4,44 +4,15 @@ module SparkApi
4
4
 
5
5
  extend Finders
6
6
 
7
- self.element_name="idxlinks"
7
+ self.element_name = "idxlinks"
8
8
 
9
9
  LINK_TYPES = ["QuickSearch", "SavedSearch", "MyListings", "Roster"]
10
10
 
11
- #TODO Work all below into common base class
12
- def self.find(*arguments)
13
- scope = arguments.slice!(0)
14
- options = arguments.slice!(0) || {}
15
-
16
- case scope
17
- when :all then find_every(options)
18
- when :first then find_every(options).first
19
- when :last then find_every(options).last
20
- when :one then find_one(options)
21
- else find_single(scope, options)
22
- end
23
- end
24
-
25
- def self.first(*arguments)
26
- find(:first, *arguments)
27
- end
28
-
29
- def self.last(*arguments)
30
- find(:last, *arguments)
31
- end
32
-
33
11
  def self.default(options = {})
34
12
  response = connection.get("/#{self.element_name}/default", options).first
35
13
  response.nil? ? nil : new(response)
36
14
  end
37
15
 
38
- private
39
-
40
- def self.find_single(scope, options)
41
- resp = SparkApi.client.get("/idxlinks/#{scope}", options)
42
- new(resp.first)
43
- end
44
-
45
16
  end
46
17
  end
47
18
  end
@@ -0,0 +1,40 @@
1
+ module SparkApi
2
+ module Models
3
+ class NewsFeedMeta < Base
4
+
5
+ attr_accessor :data
6
+
7
+ self.element_name = "newsfeeds/meta"
8
+
9
+ def initialize
10
+ super
11
+ @data = connection.get(self.path).first
12
+ end
13
+
14
+ def minimum_core_fields
15
+ @data['Subscriptions']['SavedSearches']['MinimumCoreFields']
16
+ end
17
+
18
+ def core_field_names
19
+ fields = @data['Subscriptions']['SavedSearches']['CoreSearchFields']
20
+
21
+ @data['Subscriptions']['SavedSearches']['CoreStandardFields'].each do |field|
22
+ fields << field[1]['Label']
23
+ end
24
+
25
+ fields
26
+ end
27
+
28
+ def core_fields
29
+ fields = @data['Subscriptions']['SavedSearches']['CoreSearchFields']
30
+
31
+ @data['Subscriptions']['SavedSearches']['CoreStandardFields'].each do |field|
32
+ fields << field.first
33
+ end
34
+
35
+ fields
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -8,11 +8,6 @@ module SparkApi
8
8
 
9
9
  attr_accessor :newsfeeds
10
10
 
11
- # Newsfeed restriction criteria for saved searches:
12
- # http://alpha.sparkplatform.com/docs/api_services/newsfeed/restrictions#criteria
13
- QUALIFYING_FIELDS_FOR_NEWSFEED = %w(BathsTotal BedsTotal City CountyOrParish ListPrice Location MlsStatus
14
- PostalCode PropertyType RoomsTotal State)
15
-
16
11
  self.element_name="savedsearches"
17
12
 
18
13
  def initialize(attributes={})
@@ -82,11 +77,11 @@ module SparkApi
82
77
 
83
78
  number_of_filters = 0
84
79
 
85
- QUALIFYING_FIELDS_FOR_NEWSFEED.each do |field|
80
+ news_feed_meta.core_fields.each do |field|
86
81
  number_of_filters += 1 if self.Filter.include? field
87
82
  end
88
83
 
89
- number_of_filters >= 3
84
+ number_of_filters >= news_feed_meta.minimum_core_fields
90
85
 
91
86
  end
92
87
 
@@ -124,6 +119,10 @@ module SparkApi
124
119
  end
125
120
  end
126
121
 
122
+ def news_feed_meta
123
+ @news_feed_meta ||= NewsFeedMeta.new
124
+ end
125
+
127
126
  end
128
127
 
129
128
  end
@@ -0,0 +1,131 @@
1
+ {
2
+ "D": {
3
+ "Results": [
4
+ {
5
+ "Events": ["New", "PriceChange", "Sold", "OpenHouse", "Pending", "BackOnMarket", "Extension", "StatusChange", "Recommended", "Shared", "Seeded"],
6
+ "Subscriptions": {
7
+ "SavedSearches": {
8
+ "CoreStandardFields": {
9
+ "MlsStatus": {
10
+ "ResourceUri": "/v1/standardfields/MlsStatus",
11
+ "MlsVisible": ["A", "I", "J", "K", "N"],
12
+ "Searchable": true,
13
+ "HasList": true,
14
+ "MaxListSize": 7,
15
+ "Type": "Character",
16
+ "MultiSelect": false,
17
+ "FieldCategory": "Main",
18
+ "Label": "Status"
19
+ },
20
+ "PropertyType": {
21
+ "ResourceUri": "/v1/standardfields/PropertyType",
22
+ "MlsVisible": ["A", "I", "J", "K", "N"],
23
+ "Searchable": true,
24
+ "HasList": false,
25
+ "MaxListSize": 0,
26
+ "Type": "Character",
27
+ "MultiSelect": false,
28
+ "FieldCategory": "Main",
29
+ "Label": "Property Type"
30
+ },
31
+ "PostalCode": {
32
+ "ResourceUri": "/v1/standardfields/PostalCode",
33
+ "MlsVisible": ["A", "I", "J", "K", "N"],
34
+ "Searchable": true,
35
+ "HasList": false,
36
+ "MaxListSize": 0,
37
+ "Type": "Character",
38
+ "MultiSelect": false,
39
+ "FieldCategory": "Main",
40
+ "Label": "Postal Code"
41
+ },
42
+ "ListPrice": {
43
+ "ResourceUri": "/v1/standardfields/ListPrice",
44
+ "MlsVisible": ["A", "I", "J", "K"],
45
+ "Searchable": true,
46
+ "HasList": false,
47
+ "MaxListSize": 0,
48
+ "Type": "Decimal",
49
+ "MultiSelect": false,
50
+ "Currency": true,
51
+ "FieldCategory": "Main",
52
+ "Label": "List Price"
53
+ },
54
+ "BedsTotal": {
55
+ "ResourceUri": "/v1/standardfields/BedsTotal",
56
+ "MlsVisible": ["A", "K", "N"],
57
+ "Searchable": true,
58
+ "HasList": false,
59
+ "MaxListSize": 0,
60
+ "Type": "Integer",
61
+ "MultiSelect": false,
62
+ "FieldCategory": "Main",
63
+ "Label": "Total Bedrooms"
64
+ },
65
+ "YearBuilt": {
66
+ "ResourceUri": "/v1/standardfields/YearBuilt",
67
+ "MlsVisible": ["A", "I", "K", "N"],
68
+ "Searchable": true,
69
+ "HasList": false,
70
+ "MaxListSize": 0,
71
+ "Type": "Integer",
72
+ "MultiSelect": false,
73
+ "FieldCategory": "Main",
74
+ "Label": "Year Built"
75
+ },
76
+ "BuildingAreaTotal": {
77
+ "ResourceUri": "/v1/standardfields/BuildingAreaTotal",
78
+ "MlsVisible": ["A", "I", "K", "N"],
79
+ "Searchable": true,
80
+ "HasList": false,
81
+ "MaxListSize": 0,
82
+ "Type": "Decimal",
83
+ "MultiSelect": false,
84
+ "FieldCategory": "Main",
85
+ "Label": "Total SqFt."
86
+ },
87
+ "PropertySubType": {
88
+ "ResourceUri": "/v1/standardfields/PropertySubType",
89
+ "MlsVisible": ["A", "I", "J", "K", "N"],
90
+ "Searchable": true,
91
+ "HasList": true,
92
+ "MaxListSize": 9,
93
+ "Type": "Character",
94
+ "MultiSelect": false,
95
+ "FieldCategory": "Main",
96
+ "Label": "Sub Type"
97
+ },
98
+ "SubdivisionName": {
99
+ "ResourceUri": "/v1/standardfields/SubdivisionName",
100
+ "MlsVisible": ["A", "I", "J", "K", "N"],
101
+ "Searchable": true,
102
+ "HasList": false,
103
+ "MaxListSize": 0,
104
+ "Type": "Character",
105
+ "MultiSelect": false,
106
+ "FieldCategory": "Main",
107
+ "Label": "Subdivision"
108
+ },
109
+ "MLSAreaMinor": {
110
+ "ResourceUri": "/v1/standardfields/MLSAreaMinor",
111
+ "MlsVisible": ["A", "I", "J", "K", "N"],
112
+ "Searchable": true,
113
+ "HasList": true,
114
+ "MaxListSize": 51,
115
+ "Type": "Character",
116
+ "MultiSelect": false,
117
+ "FieldCategory": "Main",
118
+ "Label": "Map Area"
119
+ }
120
+ },
121
+ "CoreSearchFields": [
122
+ "Location"
123
+ ],
124
+ "MinimumCoreFields": 3
125
+ }
126
+ }
127
+ }
128
+ ],
129
+ "Success": true
130
+ }
131
+ }
@@ -54,6 +54,7 @@ RSpec.configure do |config|
54
54
  config.alias_example_to :on_post_it, :method => 'POST'
55
55
  config.alias_example_to :on_delete_it, :method => 'DELETE'
56
56
  config.before(:all) { reset_config }
57
+ config.color_enabled = true
57
58
  end
58
59
 
59
60
  def jruby?
@@ -0,0 +1,35 @@
1
+ require './spec/spec_helper'
2
+
3
+
4
+ describe NewsFeedMeta do
5
+
6
+ let(:news_feed_meta) { NewsFeedMeta.new }
7
+
8
+ before(:each) do
9
+ stub_auth_request
10
+ stub_api_get("/newsfeeds/meta", "newsfeeds/meta.json")
11
+ end
12
+
13
+ describe 'minimum_core_fields' do
14
+ it 'returns the minimum number of required fields' do
15
+ expect(news_feed_meta.minimum_core_fields).to eq 3
16
+ end
17
+ end
18
+
19
+ describe 'core_field_names' do
20
+ it 'returns an array including both the CoreSearchFields and the CoreStandardFields' do
21
+ field_array = ["Location", "Status", "Property Type", "Postal Code", "List Price", "Total Bedrooms",
22
+ "Year Built", "Total SqFt.", "Sub Type", "Subdivision", "Map Area"]
23
+ expect(news_feed_meta.core_field_names).to eq field_array
24
+ end
25
+ end
26
+
27
+ describe 'core_fields' do
28
+ it 'returns an array including both the CoreSearchFields and the CoreStandardFields' do
29
+ field_array = ["Location", "MlsStatus", "PropertyType", "PostalCode", "ListPrice", "BedsTotal",
30
+ "YearBuilt", "BuildingAreaTotal", "PropertySubType", "SubdivisionName", "MLSAreaMinor"]
31
+ expect(news_feed_meta.core_fields).to eq field_array
32
+ end
33
+ end
34
+
35
+ end
@@ -178,12 +178,16 @@ describe SavedSearch do
178
178
 
179
179
  describe "can_have_newsfeed?" do
180
180
 
181
+ before do
182
+ stub_api_get("/newsfeeds/meta", "newsfeeds/meta.json")
183
+ end
184
+
181
185
  it "should return false without at least three filter parameters" do
182
186
  stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json')
183
187
  resource = subject.class.find(id)
184
188
  resource.stub(:has_active_newsfeed?) { false }
185
189
  resource.stub(:has_inactive_newsfeed?) { false }
186
- resource.Filter = "City Eq 'Moorhead' And MlsStatus Eq 'Active'"
190
+ resource.Filter = "MlsStatus Eq 'Active' And PropertyType Eq 'A'"
187
191
  resource.can_have_newsfeed?.should == false
188
192
  end
189
193
 
@@ -192,6 +196,7 @@ describe SavedSearch do
192
196
  resource = subject.class.find(id)
193
197
  resource.stub(:has_active_newsfeed?) { false }
194
198
  resource.stub(:has_inactive_newsfeed?) { false }
199
+ resource.Filter = "MlsStatus Eq 'Active' And PropertyType Eq 'A' And ListPrice Eq 1000000"
195
200
  resource.can_have_newsfeed?.should == true
196
201
  end
197
202
 
@@ -243,11 +248,5 @@ describe SavedSearch do
243
248
  resource.newsfeeds.should be_an(Array)
244
249
  end
245
250
  end
246
-
247
- describe "QUALIFYING_FIELDS_FOR_NEWSFEED" do
248
- it "should return an array" do
249
- subject.class::QUALIFYING_FIELDS_FOR_NEWSFEED.should be_an(Array)
250
- end
251
- end
252
251
 
253
252
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spark_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.26
4
+ version: 1.3.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Hornseth
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-06 00:00:00.000000000 Z
12
+ date: 2016-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -177,20 +177,6 @@ dependencies:
177
177
  - - ~>
178
178
  - !ruby/object:Gem::Version
179
179
  version: 1.7.0
180
- - !ruby/object:Gem::Dependency
181
- name: rcov
182
- requirement: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - ~>
185
- - !ruby/object:Gem::Version
186
- version: 0.9.9
187
- type: :development
188
- prerelease: false
189
- version_requirements: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - ~>
192
- - !ruby/object:Gem::Version
193
- version: 0.9.9
194
180
  - !ruby/object:Gem::Dependency
195
181
  name: rb-readline
196
182
  requirement: !ruby/object:Gem::Requirement
@@ -308,6 +294,7 @@ files:
308
294
  - lib/spark_api/models/listing_cart.rb
309
295
  - lib/spark_api/models/market_statistics.rb
310
296
  - lib/spark_api/models/message.rb
297
+ - lib/spark_api/models/news_feed_meta.rb
311
298
  - lib/spark_api/models/newsfeed.rb
312
299
  - lib/spark_api/models/note.rb
313
300
  - lib/spark_api/models/notification.rb
@@ -431,6 +418,7 @@ files:
431
418
  - spec/fixtures/messages/post.json
432
419
  - spec/fixtures/newsfeeds/get.json
433
420
  - spec/fixtures/newsfeeds/inactive.json
421
+ - spec/fixtures/newsfeeds/meta.json
434
422
  - spec/fixtures/no_results.json
435
423
  - spec/fixtures/notes/add.json
436
424
  - spec/fixtures/notes/agent_shared.json
@@ -500,6 +488,7 @@ files:
500
488
  - spec/unit/spark_api/models/listing_cart_spec.rb
501
489
  - spec/unit/spark_api/models/listing_spec.rb
502
490
  - spec/unit/spark_api/models/message_spec.rb
491
+ - spec/unit/spark_api/models/news_feed_meta_spec.rb
503
492
  - spec/unit/spark_api/models/newsfeed_spec.rb
504
493
  - spec/unit/spark_api/models/note_spec.rb
505
494
  - spec/unit/spark_api/models/notification_spec.rb
@@ -545,7 +534,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
545
534
  version: '1.8'
546
535
  requirements: []
547
536
  rubyforge_project: spark_api
548
- rubygems_version: 2.2.1
537
+ rubygems_version: 2.2.5
549
538
  signing_key:
550
539
  specification_version: 4
551
540
  summary: A library for interacting with the Spark web services.
@@ -611,6 +600,7 @@ test_files:
611
600
  - spec/fixtures/errors/failure_with_msg.json
612
601
  - spec/fixtures/errors/failure.json
613
602
  - spec/fixtures/errors/failure_with_constraint.json
603
+ - spec/fixtures/newsfeeds/meta.json
614
604
  - spec/fixtures/newsfeeds/inactive.json
615
605
  - spec/fixtures/newsfeeds/get.json
616
606
  - spec/fixtures/property_types/property_types.json
@@ -696,6 +686,7 @@ test_files:
696
686
  - spec/unit/spark_api/authentication/base_auth_spec.rb
697
687
  - spec/unit/spark_api/configuration_spec.rb
698
688
  - spec/unit/spark_api/request_spec.rb
689
+ - spec/unit/spark_api/models/news_feed_meta_spec.rb
699
690
  - spec/unit/spark_api/models/open_house_spec.rb
700
691
  - spec/unit/spark_api/models/document_spec.rb
701
692
  - spec/unit/spark_api/models/system_info_spec.rb