spark_api 1.3.28 → 1.4.0

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
- MDM4YWU2MmViMjdlY2JmYTMyM2I3M2I0MWRmNTMwYTM5N2Q1M2NhOQ==
4
+ MDdhMWQ2ZjA4NTI5NzZhNmIwNTZmZGM2MzgxZjM2MDI2NjIzN2RiZQ==
5
5
  data.tar.gz: !binary |-
6
- MzZkZTM3YmJiOGZjZWU1ZDJjN2FlNGE2OTdjZTI4M2M4YTA5MWNhNw==
6
+ ZGU5OTFlNzRlY2Q5YzBkYjczOTBhOGFkZTJjYzhlNDQyOTM0ZDMwYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzA5NDdmMjExNWQyMzhiMzM2ZTkxMTYxN2VjMzljYTZmZWE1YzdiNDk4NzVl
10
- ZGU3NmQ1MDY2NjU3OGZjYjhjY2ZmMWI5YjljN2Y0NGZlNjE4NTViYTE0ZTM5
11
- NWQwZTM2NmYyY2EyYmM0OWI1YjA4MDBlZmVmZDQzOTEyOGE0MGU=
9
+ MDg3YzY1OWFjNDI3OGQzOTQyMmQ1YmJjNjI0OWU5Y2Q0MzdhM2UzOTNjMzk0
10
+ MTA3OWJkYTIwOGYxMzk0YzQ3MGUzNWVjYzBiZjVlOTBhMGJjZDNiMTg0NTE3
11
+ NGFhMDNjZjc0MjVhMjVmYmI3NzQ2M2YxNzAyNzFhYTU0MmFlMzg=
12
12
  data.tar.gz: !binary |-
13
- NDdhMjU4MGRlNjdlZTZjODJhNDYxYTFiNGE1ZmE1ODg2OTMyNWU4ZDBlNWZm
14
- NGQ2ZGQ3MGQ4OGExMzUzMmIyZTVhMTIzYzIyMDQ3MTM5YTRhZTY3MGRlYjg5
15
- OGY5ZGU4Mzk0ZWUwNjg2OGE4ZWIyZjE2MDE2NTZmNDBhMjdjZjM=
13
+ N2Y3NGNkZGVjZjhlNzA2Y2FmYmVmNGUyNDhlZjlmZmVkY2Y0OWJmMzQ2MWJm
14
+ NDVjYzFlNWJlMGQwZjUxYTIwNjJhYjYzMzgzOGJiMzMwZWQzOTUwNzA4ODhl
15
+ NjllNjc4YzI4MGE3MDBlYjVlOThkNTEwOTM0YjA1Zjc5ZWZjYjE=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.28
1
+ 1.4.0
@@ -2,23 +2,16 @@ module SparkApi
2
2
  module Models
3
3
  class NewsFeedMeta < Base
4
4
 
5
- attr_accessor :data
6
-
7
5
  self.element_name = "newsfeeds/meta"
8
6
 
9
- def initialize
10
- super
11
- @data = connection.get(self.path).first
12
- end
13
-
14
7
  def minimum_core_fields
15
- @data['Subscriptions']['SavedSearches']['MinimumCoreFields']
8
+ data['Subscriptions']['SavedSearches']['MinimumCoreFields']
16
9
  end
17
10
 
18
11
  def core_field_names
19
- fields = @data['Subscriptions']['SavedSearches']['CoreSearchFields']
12
+ fields = data['Subscriptions']['SavedSearches']['CoreSearchFields']
20
13
 
21
- @data['Subscriptions']['SavedSearches']['CoreStandardFields'].each do |field|
14
+ data['Subscriptions']['SavedSearches']['CoreStandardFields'].each do |field|
22
15
  fields << field[1]['Label']
23
16
  end
24
17
 
@@ -26,15 +19,21 @@ module SparkApi
26
19
  end
27
20
 
28
21
  def core_fields
29
- fields = @data['Subscriptions']['SavedSearches']['CoreSearchFields']
22
+ fields = data['Subscriptions']['SavedSearches']['CoreSearchFields']
30
23
 
31
- @data['Subscriptions']['SavedSearches']['CoreStandardFields'].each do |field|
24
+ data['Subscriptions']['SavedSearches']['CoreStandardFields'].each do |field|
32
25
  fields << field.first
33
26
  end
34
27
 
35
28
  fields
36
29
  end
37
30
 
31
+ private
32
+
33
+ def data
34
+ @data ||= connection.get(self.path).first
35
+ end
36
+
38
37
  end
39
38
  end
40
39
  end
@@ -6,15 +6,9 @@ module SparkApi
6
6
  include Concerns::Savable,
7
7
  Concerns::Destroyable
8
8
 
9
- attr_accessor :newsfeeds
10
9
 
11
10
  self.element_name="savedsearches"
12
11
 
13
- def initialize(attributes={})
14
- @newsfeeds = nil
15
- super(attributes)
16
- end
17
-
18
12
  def self.provided()
19
13
  Class.new(self).tap do |provided|
20
14
  provided.element_name = '/savedsearches'
@@ -67,22 +61,12 @@ module SparkApi
67
61
  end
68
62
 
69
63
  def newsfeeds
70
- Newsfeed.collect(connection.get("#{self.class.path}/#{@attributes["Id"]}",
71
- :_expand => "NewsFeeds").first["NewsFeeds"])
72
- end
73
-
74
- def can_have_newsfeed?
75
-
76
- return true if has_active_newsfeed? || has_inactive_newsfeed?
77
-
78
- number_of_filters = 0
79
-
80
- news_feed_meta.core_fields.each do |field|
81
- number_of_filters += 1 if self.Filter.include? field
82
- end
83
-
84
- number_of_filters >= news_feed_meta.minimum_core_fields
85
-
64
+ @newsfeeds ||= if attributes.key?("NewsFeeds")
65
+ Newsfeed.collect(attributes["NewsFeeds"])
66
+ else
67
+ Newsfeed.collect(connection.get("#{self.class.path}/#{@attributes["Id"]}",
68
+ :_expand => "NewsFeeds").first["NewsFeeds"])
69
+ end
86
70
  end
87
71
 
88
72
  def has_active_newsfeed?
@@ -119,10 +103,6 @@ module SparkApi
119
103
  end
120
104
  end
121
105
 
122
- def news_feed_meta
123
- @news_feed_meta ||= NewsFeedMeta.new
124
- end
125
-
126
106
  end
127
107
 
128
108
  end
@@ -176,32 +176,6 @@ describe SavedSearch do
176
176
  end
177
177
  end
178
178
 
179
- describe "can_have_newsfeed?" do
180
-
181
- before do
182
- stub_api_get("/newsfeeds/meta", "newsfeeds/meta.json")
183
- end
184
-
185
- it "should return false without at least three filter parameters" do
186
- stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json')
187
- resource = subject.class.find(id)
188
- resource.stub(:has_active_newsfeed?) { false }
189
- resource.stub(:has_inactive_newsfeed?) { false }
190
- resource.Filter = "MlsStatus Eq 'Active' And PropertyType Eq 'A'"
191
- resource.can_have_newsfeed?.should == false
192
- end
193
-
194
- it "should return true with three filter parameters" do
195
- stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json')
196
- resource = subject.class.find(id)
197
- resource.stub(:has_active_newsfeed?) { false }
198
- resource.stub(:has_inactive_newsfeed?) { false }
199
- resource.Filter = "MlsStatus Eq 'Active' And PropertyType Eq 'A' And ListPrice Eq 1000000"
200
- resource.can_have_newsfeed?.should == true
201
- end
202
-
203
- end
204
-
205
179
  describe "has_active_newsfeed?" do
206
180
  it "should return true if the search already has a newsfeed" do
207
181
  stub_api_get("/#{subject.class.element_name}/#{id}", 'saved_searches/get.json')
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.28
4
+ version: 1.4.0
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: 2016-04-01 00:00:00.000000000 Z
12
+ date: 2016-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday