spark_api 1.4.9 → 1.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/lib/spark_api/models.rb +2 -0
- data/lib/spark_api/models/base.rb +5 -0
- data/lib/spark_api/models/email_link.rb +21 -0
- data/lib/spark_api/models/newsfeed.rb +5 -1
- data/lib/spark_api/models/notification.rb +3 -0
- data/lib/spark_api/models/saved_search.rb +4 -1
- data/lib/spark_api/models/shared_link.rb +53 -0
- data/spec/fixtures/sharedlinks/success.json +10 -0
- data/spec/unit/spark_api/models/base_spec.rb +1 -0
- data/spec/unit/spark_api/models/email_link_spec.rb +19 -0
- data/spec/unit/spark_api/models/newsfeed_spec.rb +0 -2
- data/spec/unit/spark_api/models/saved_search_spec.rb +14 -0
- data/spec/unit/spark_api/models/shared_link_spec.rb +108 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTFjNDIzMzZlZTliYWQ5ZmFhZTI0YzgxOTIzZGM4NjczMDExZjI2Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzlkZTQ2YjlkNjBhMDExMTU2ZDA5NWQxOWE5NDRjMTAwNDFkZjQ4Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDExMTM5MWMxNzA0MGFlMTdkNzVjYjdhZmJjOTcxYjRmMjc1ZGExNjkxOTcw
|
10
|
+
MDdiNjAwZjY2N2MwNDY2ZjMxYjcyZWM2Y2NkNmU3MzI1Yjk2YWFlY2UxMWM2
|
11
|
+
ZjA4ZmY2OWJkMjQzMmRkYWRmZGE2ZTEyZDA1MGNjZGIzNDFmMGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDFmNjk3ZTY5NTQ5Y2FkNDFkZDAwYTk4Y2I4ZTNhODI0NTZhOGY4ZmYzYjA1
|
14
|
+
ZWYwYzU3OWZmZjY4OWJiNzJhYWJlZjRiY2Q0OTlhNTFhZWJmOGZjYmY1NmVi
|
15
|
+
OWQ4MmQ5ZWFhZGY0YTg5NzlmZTIxNWY1Y2U3ODY2ZGNhNzQ3ZTI=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.10
|
data/lib/spark_api/models.rb
CHANGED
@@ -15,6 +15,7 @@ require 'spark_api/models/contact'
|
|
15
15
|
require 'spark_api/models/comment'
|
16
16
|
require 'spark_api/models/custom_fields'
|
17
17
|
require 'spark_api/models/document'
|
18
|
+
require 'spark_api/models/email_link'
|
18
19
|
require 'spark_api/models/fields'
|
19
20
|
require 'spark_api/models/idx'
|
20
21
|
require 'spark_api/models/idx_link'
|
@@ -34,6 +35,7 @@ require 'spark_api/models/property_types'
|
|
34
35
|
require 'spark_api/models/rental_calendar'
|
35
36
|
require 'spark_api/models/saved_search'
|
36
37
|
require 'spark_api/models/search_template/quick_search'
|
38
|
+
require 'spark_api/models/shared_link'
|
37
39
|
require 'spark_api/models/shared_listing'
|
38
40
|
require 'spark_api/models/sort'
|
39
41
|
require 'spark_api/models/standard_fields'
|
@@ -9,6 +9,11 @@ module SparkApi
|
|
9
9
|
|
10
10
|
attr_accessor :attributes, :errors, :parent
|
11
11
|
|
12
|
+
# More familiar accessor for our Spark API Id method
|
13
|
+
def id
|
14
|
+
self.Id
|
15
|
+
end
|
16
|
+
|
12
17
|
# Name of the resource as related to the path name
|
13
18
|
def self.element_name
|
14
19
|
# TODO I'd love to pull in active model at this point to provide default naming
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SparkApi
|
2
|
+
module Models
|
3
|
+
class EmailLink < Base
|
4
|
+
|
5
|
+
extend Finders
|
6
|
+
|
7
|
+
self.prefix = "/flexmls/"
|
8
|
+
self.element_name = "emaillinks"
|
9
|
+
|
10
|
+
attr_accessor :template, :sort_id
|
11
|
+
|
12
|
+
def filter
|
13
|
+
"EmailLink Eq '#{id}'"
|
14
|
+
end
|
15
|
+
|
16
|
+
def listing_search_role
|
17
|
+
:public
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -6,7 +6,6 @@ module SparkApi
|
|
6
6
|
include Concerns::Savable,
|
7
7
|
Concerns::Destroyable
|
8
8
|
|
9
|
-
|
10
9
|
self.element_name="savedsearches"
|
11
10
|
|
12
11
|
def self.provided()
|
@@ -89,6 +88,10 @@ module SparkApi
|
|
89
88
|
end
|
90
89
|
end
|
91
90
|
|
91
|
+
def listing_search_role
|
92
|
+
:public if path =~ /contact/
|
93
|
+
end
|
94
|
+
|
92
95
|
private
|
93
96
|
|
94
97
|
def resource_pluralized; "SavedSearches" end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module SparkApi
|
2
|
+
module Models
|
3
|
+
class SharedLink < Base
|
4
|
+
extend Finders
|
5
|
+
|
6
|
+
attr_accessor :sort_id
|
7
|
+
attr_writer :name
|
8
|
+
|
9
|
+
self.element_name = "sharedlinks"
|
10
|
+
|
11
|
+
def self.create(data)
|
12
|
+
SharedLink.new SparkApi.client.post("#{path}/#{resource_type(data)}", data).first
|
13
|
+
rescue SparkApi::BadResourceRequest
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def name
|
18
|
+
if @name
|
19
|
+
@name
|
20
|
+
elsif respond_to?(:ListingCart) && self.ListingCart.respond_to?(:Name)
|
21
|
+
self.ListingCart.Name
|
22
|
+
elsif respond_to?(:SavedSearch) && self.SavedSearch.respond_to?(:Name)
|
23
|
+
self.SavedSearch.Name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def template
|
28
|
+
if respond_to?(:SavedSearch) && self.SavedSearch.respond_to?(:template)
|
29
|
+
self.SavedSearch.template
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def filter
|
34
|
+
"SharedLink Eq '#{id}'"
|
35
|
+
end
|
36
|
+
|
37
|
+
def listing_search_role
|
38
|
+
self.Mode.downcase.to_sym
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def self.resource_type(data)
|
44
|
+
case data.keys[0].to_sym
|
45
|
+
when :ListingIds; "listings"
|
46
|
+
when :SearchId; "search"
|
47
|
+
when :CartId; "cart"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe EmailLink do
|
4
|
+
it_behaves_like 'search_container'
|
5
|
+
|
6
|
+
let(:email_link) { EmailLink.new(Id: 5) }
|
7
|
+
|
8
|
+
describe 'filter' do
|
9
|
+
it 'returns a filter for the email link' do
|
10
|
+
expect(email_link.filter).to eq "EmailLink Eq '#{email_link.id}'"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'listing_search_role' do
|
15
|
+
it 'returns a symbol' do
|
16
|
+
expect(EmailLink.new().listing_search_role).to eq(:public)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -222,5 +222,19 @@ describe SavedSearch do
|
|
222
222
|
resource.newsfeeds.should be_an(Array)
|
223
223
|
end
|
224
224
|
end
|
225
|
+
|
226
|
+
describe "listing_search_role" do
|
227
|
+
it "specifics public when accessed on behalf of a contact" do
|
228
|
+
contact = Contact.new({"Id" => "5"})
|
229
|
+
search = SavedSearch.new({"Id" => "2"*26})
|
230
|
+
search.parent = contact
|
231
|
+
expect(search.listing_search_role).to eq(:public)
|
232
|
+
end
|
233
|
+
|
234
|
+
it "is nil when not accessed on behalf of a contact" do
|
235
|
+
search = SavedSearch.new({"Id" => "2"*26})
|
236
|
+
expect(search.listing_search_role).to be_nil
|
237
|
+
end
|
238
|
+
end
|
225
239
|
|
226
240
|
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SharedLink do
|
4
|
+
|
5
|
+
let(:shared_link) { SharedLink.new(Id: 5) }
|
6
|
+
|
7
|
+
it_behaves_like 'search_container'
|
8
|
+
|
9
|
+
it "returns the right path" do
|
10
|
+
expect(shared_link.path).to eq("/sharedlinks")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "create" do
|
14
|
+
before(:each) do
|
15
|
+
stub_auth_request
|
16
|
+
end
|
17
|
+
|
18
|
+
it "creates a shared link for listings" do
|
19
|
+
data = { ListingIds: ["5", "6"] }
|
20
|
+
stub_api_post("/sharedlinks/listings", data, 'sharedlinks/success.json')
|
21
|
+
expect(SharedLink.create(data)).to be_a(SharedLink)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "works with string keys" do
|
25
|
+
data = { "ListingIds" => ["5", "6"] }
|
26
|
+
stub_api_post("/sharedlinks/listings", data, 'sharedlinks/success.json')
|
27
|
+
expect(SharedLink.create(data)).to be_a(SharedLink)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "creates a shared link for searches" do
|
31
|
+
data = { SearchId: "5" }
|
32
|
+
stub_api_post("/sharedlinks/search", data, 'sharedlinks/success.json')
|
33
|
+
expect(SharedLink.create(data)).to be_a(SharedLink)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "creates a shared link for collections" do
|
37
|
+
data = { CartId: "5" }
|
38
|
+
stub_api_post("/sharedlinks/cart", data, 'sharedlinks/success.json')
|
39
|
+
expect(SharedLink.create(data)).to be_a(SharedLink)
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "errors" do
|
43
|
+
|
44
|
+
it "returns false if there is an error" do
|
45
|
+
data = { ListingIds: ["5", "6"] }
|
46
|
+
allow(SparkApi).to receive(:client) { raise SparkApi::BadResourceRequest }
|
47
|
+
expect(SharedLink.create(data)).to be false
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'name' do
|
55
|
+
|
56
|
+
it 'returns the name of the referenced listing cart' do
|
57
|
+
listing_cart = ListingCart.new(Name: 'the name for the listing cart')
|
58
|
+
shared_link.ListingCart = listing_cart
|
59
|
+
expect(shared_link.name).to eq listing_cart.Name
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'returns the name of the referenced saved search' do
|
63
|
+
saved_search = SavedSearch.new({"Id" => "5"*26, "Name" => "My Search"})
|
64
|
+
shared_link.SavedSearch = saved_search
|
65
|
+
expect(shared_link.name).to eq saved_search.Name
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns nil if there is no listing cart or saved search' do
|
69
|
+
shared_link.SavedSearch = nil
|
70
|
+
shared_link.ListingCart = nil
|
71
|
+
expect(shared_link.name).to be_nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'can be set to override the default name' do
|
75
|
+
shared_link.name = "my custom name"
|
76
|
+
expect(shared_link.name).to eq "my custom name"
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'template' do
|
82
|
+
|
83
|
+
it 'returns the template from the saved search' do
|
84
|
+
saved_search = SavedSearch.new({"Id" => "5"*26})
|
85
|
+
template = QuickSearch.new({"Id" => "8"*26})
|
86
|
+
allow(saved_search).to receive(:template).and_return(template)
|
87
|
+
shared_link.SavedSearch = saved_search
|
88
|
+
expect(shared_link.template).to eq saved_search.template
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'returns nil if the shared link is not for a saved search' do
|
92
|
+
expect(shared_link.template).to eq nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe 'filter' do
|
97
|
+
it 'returns the filter' do
|
98
|
+
expect(shared_link.filter).to eq "SharedLink Eq '#{shared_link.id}'"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'listing_search_role' do
|
103
|
+
it 'returns a symbol' do
|
104
|
+
expect(SharedLink.new({"Mode" => "Idx"}).listing_search_role).to eq(:idx)
|
105
|
+
expect(SharedLink.new({"Mode" => "Public"}).listing_search_role).to eq(:public)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
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.4.
|
4
|
+
version: 1.4.10
|
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: 2017-01-
|
12
|
+
date: 2017-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -332,6 +332,7 @@ files:
|
|
332
332
|
- lib/spark_api/models/defaultable.rb
|
333
333
|
- lib/spark_api/models/dirty.rb
|
334
334
|
- lib/spark_api/models/document.rb
|
335
|
+
- lib/spark_api/models/email_link.rb
|
335
336
|
- lib/spark_api/models/fields.rb
|
336
337
|
- lib/spark_api/models/finders.rb
|
337
338
|
- lib/spark_api/models/idx.rb
|
@@ -352,6 +353,7 @@ files:
|
|
352
353
|
- lib/spark_api/models/rental_calendar.rb
|
353
354
|
- lib/spark_api/models/saved_search.rb
|
354
355
|
- lib/spark_api/models/search_template/quick_search.rb
|
356
|
+
- lib/spark_api/models/shared_link.rb
|
355
357
|
- lib/spark_api/models/shared_listing.rb
|
356
358
|
- lib/spark_api/models/sort.rb
|
357
359
|
- lib/spark_api/models/standard_fields.rb
|
@@ -503,6 +505,7 @@ files:
|
|
503
505
|
- spec/fixtures/saved_searches/without_newsfeed.json
|
504
506
|
- spec/fixtures/search_templates/quick_searches/get.json
|
505
507
|
- spec/fixtures/session.json
|
508
|
+
- spec/fixtures/sharedlinks/success.json
|
506
509
|
- spec/fixtures/sorts/get.json
|
507
510
|
- spec/fixtures/standardfields/city.json
|
508
511
|
- spec/fixtures/standardfields/nearby.json
|
@@ -532,6 +535,7 @@ files:
|
|
532
535
|
- spec/unit/spark_api/models/defaultable_spec.rb
|
533
536
|
- spec/unit/spark_api/models/dirty_spec.rb
|
534
537
|
- spec/unit/spark_api/models/document_spec.rb
|
538
|
+
- spec/unit/spark_api/models/email_link_spec.rb
|
535
539
|
- spec/unit/spark_api/models/fields_spec.rb
|
536
540
|
- spec/unit/spark_api/models/finders_spec.rb
|
537
541
|
- spec/unit/spark_api/models/listing_cart_spec.rb
|
@@ -548,6 +552,7 @@ files:
|
|
548
552
|
- spec/unit/spark_api/models/rental_calendar_spec.rb
|
549
553
|
- spec/unit/spark_api/models/saved_search_spec.rb
|
550
554
|
- spec/unit/spark_api/models/search_template/quick_search_spec.rb
|
555
|
+
- spec/unit/spark_api/models/shared_link_spec.rb
|
551
556
|
- spec/unit/spark_api/models/shared_listing_spec.rb
|
552
557
|
- spec/unit/spark_api/models/sort_spec.rb
|
553
558
|
- spec/unit/spark_api/models/standard_fields_spec.rb
|
@@ -668,6 +673,7 @@ test_files:
|
|
668
673
|
- spec/fixtures/saved_searches/without_newsfeed.json
|
669
674
|
- spec/fixtures/saved_searches/get.json
|
670
675
|
- spec/fixtures/saved_searches/with_inactive_newsfeed.json
|
676
|
+
- spec/fixtures/sharedlinks/success.json
|
671
677
|
- spec/fixtures/messages/post.json
|
672
678
|
- spec/fixtures/messages/new_with_recipients.json
|
673
679
|
- spec/fixtures/messages/new.json
|
@@ -752,10 +758,12 @@ test_files:
|
|
752
758
|
- spec/unit/spark_api/models/account_spec.rb
|
753
759
|
- spec/unit/spark_api/models/listing_spec.rb
|
754
760
|
- spec/unit/spark_api/models/video_spec.rb
|
761
|
+
- spec/unit/spark_api/models/shared_link_spec.rb
|
755
762
|
- spec/unit/spark_api/models/account_report_spec.rb
|
756
763
|
- spec/unit/spark_api/models/sort_spec.rb
|
757
764
|
- spec/unit/spark_api/models/saved_search_spec.rb
|
758
765
|
- spec/unit/spark_api/models/contact_spec.rb
|
766
|
+
- spec/unit/spark_api/models/email_link_spec.rb
|
759
767
|
- spec/unit/spark_api/models/portal_spec.rb
|
760
768
|
- spec/unit/spark_api/models/message_spec.rb
|
761
769
|
- spec/unit/spark_api/models/constraint_spec.rb
|