Skip to content

Commit f116be9

Browse files
committed
made newsfeeds savable and updated saved search newsfeed helpers
1 parent 484df5a commit f116be9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/spark_api/models/newsfeed.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ module Models
33
class Newsfeed < Base
44

55
extend Finders
6+
include Concerns::Savable
67

78
self.element_name = 'newsfeeds'
8-
9+
910
end
1011
end
1112
end

lib/spark_api/models/saved_search.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def can_have_newsfeed?
8181

8282
return false if is_provided_search?
8383

84+
# Newsfeed restriction criteria for saved searches:
85+
# http://alpha.sparkplatform.com/docs/api_services/newsfeed/restrictions#criteria
8486
standard_fields = %w(BathsTotal BedsTotal City CountyOrParish ListPrice Location MlsStatus PostalCode PropertyType RoomsTotal State)
8587

8688
number_of_filters = 0
@@ -93,7 +95,7 @@ def can_have_newsfeed?
9395

9496
end
9597

96-
def has_newsfeed?
98+
def has_active_newsfeed?
9799
if self.respond_to? "NewsFeedSubscriptionSummary"
98100
self.NewsFeedSubscriptionSummary['ActiveSubscription']
99101
else
@@ -102,6 +104,15 @@ def has_newsfeed?
102104
end
103105
end
104106

107+
def has_inactive_newsfeed?
108+
if self.respond_to? "NewsFeedSubscriptionSummary"
109+
!self.NewsFeedSubscriptionSummary['ActiveSubscription']
110+
else
111+
saved_search = SavedSearch.find( self.Id, {"_expand" => "NewsFeedSubscriptionSummary"})
112+
!saved_search.NewsFeedSubscriptionSummary['ActiveSubscription']
113+
end
114+
end
115+
105116
private
106117

107118
def resource_pluralized; "SavedSearches" end

0 commit comments

Comments
 (0)