Skip to content

Commit b8efffb

Browse files
authored
Merge pull request #147 from ryanhertz/rules
added Rule model
2 parents ee861d4 + 46c5321 commit b8efffb

File tree

6 files changed

+76
-1
lines changed

6 files changed

+76
-1
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v1.4.22
2+
- added Rule model
3+
14
v1.4.21
25
- added IncompleteListing model
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.21
1+
1.4.22

lib/spark_api/models.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
require 'spark_api/models/portal_listing_cart'
3535
require 'spark_api/models/property_types'
3636
require 'spark_api/models/rental_calendar'
37+
require 'spark_api/models/rule'
3738
require 'spark_api/models/saved_search'
3839
require 'spark_api/models/search_template/quick_search'
3940
require 'spark_api/models/shared_link'

lib/spark_api/models/rule.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module SparkApi
2+
module Models
3+
class Rule < Base
4+
5+
self.element_name="listings/rules"
6+
7+
def self.for_property_type(property_type, args={})
8+
collect(connection.get("/listings/rules/propertytypes/#{property_type}", args))
9+
end
10+
11+
end
12+
end
13+
end
14+

spec/fixtures/rules/get.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"D": {
3+
"Success": true,
4+
"Results": [
5+
{
6+
"Id": 25,
7+
"ResourceUri": "/v1/listings/rules/25",
8+
"PropertyType": "A",
9+
"Domain": "StandardFields",
10+
"Group": null,
11+
"Field": "BathsTotal",
12+
"Order": 1,
13+
"Action": "SET_REQUIRED",
14+
"Expression": "StandardStatus = 'Active'",
15+
"ModificationTimestamp": "2018-05-07T19:03:07Z",
16+
"CreatedTimestamp": "2017-12-20T19:00:30Z",
17+
"ApprovalStatus": "Published",
18+
"Editable": true,
19+
"Status": "Fatal"
20+
},
21+
{
22+
"Id": 370,
23+
"ResourceUri": "/v1/listings/rules/370",
24+
"PropertyType": "A",
25+
"Domain": "StandardFields",
26+
"Group": null,
27+
"Field": "City",
28+
"Order": 1,
29+
"Action": "SET_REQUIRED",
30+
"Expression": ".FALSE.",
31+
"ModificationTimestamp": "2018-05-01T15:26:47Z",
32+
"CreatedTimestamp": "2018-01-24T16:01:14Z",
33+
"ApprovalStatus": "Published",
34+
"Editable": true,
35+
"Status": "Fatal"
36+
}
37+
]
38+
}
39+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require './spec/spec_helper'
2+
3+
describe Rule do
4+
5+
describe 'for_property_type' do
6+
7+
on_get_it "should get documents for a listing" do
8+
stub_auth_request
9+
stub_api_get('/listings/rules/propertytypes/A','rules/get.json')
10+
11+
rules = Rule.for_property_type('A')
12+
rules.should be_an(Array)
13+
rules.length.should == 2
14+
end
15+
16+
end
17+
18+
end

0 commit comments

Comments
 (0)