flexmls_api 0.4.5 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -17
- data/Gemfile.lock +35 -27
- data/README.md +23 -1
- data/Rakefile +18 -5
- data/VERSION +1 -1
- data/bin/flexmls_api +8 -0
- data/lib/flexmls_api.rb +2 -0
- data/lib/flexmls_api/authentication.rb +5 -6
- data/lib/flexmls_api/authentication/api_auth.rb +4 -2
- data/lib/flexmls_api/authentication/oauth2.rb +51 -99
- data/lib/flexmls_api/authentication/oauth2_impl/grant_type_base.rb +85 -0
- data/lib/flexmls_api/authentication/oauth2_impl/grant_type_code.rb +48 -0
- data/lib/flexmls_api/authentication/oauth2_impl/grant_type_password.rb +45 -0
- data/lib/flexmls_api/authentication/oauth2_impl/grant_type_refresh.rb +36 -0
- data/lib/flexmls_api/authentication/oauth2_impl/middleware.rb +39 -0
- data/lib/flexmls_api/cli.rb +132 -0
- data/lib/flexmls_api/cli/api_auth.rb +8 -0
- data/lib/flexmls_api/cli/oauth2.rb +43 -0
- data/lib/flexmls_api/cli/setup.rb +44 -0
- data/lib/flexmls_api/configuration.rb +6 -6
- data/lib/flexmls_api/faraday.rb +11 -21
- data/lib/flexmls_api/models.rb +3 -0
- data/lib/flexmls_api/models/account.rb +48 -5
- data/lib/flexmls_api/models/base.rb +27 -2
- data/lib/flexmls_api/models/contact.rb +28 -9
- data/lib/flexmls_api/models/listing_cart.rb +72 -0
- data/lib/flexmls_api/models/note.rb +0 -2
- data/lib/flexmls_api/models/saved_search.rb +16 -0
- data/lib/flexmls_api/models/shared_listing.rb +35 -0
- data/lib/flexmls_api/multi_client.rb +37 -0
- data/lib/flexmls_api/paginate.rb +5 -0
- data/lib/flexmls_api/request.rb +7 -3
- data/script/console +6 -0
- data/script/example.rb +27 -0
- data/spec/fixtures/accounts/all.json +160 -0
- data/spec/fixtures/accounts/my.json +74 -0
- data/spec/fixtures/accounts/my_portal.json +20 -0
- data/spec/fixtures/accounts/my_put.json +5 -0
- data/spec/fixtures/accounts/my_save.json +5 -0
- data/spec/fixtures/accounts/office.json +142 -0
- data/spec/fixtures/base.json +13 -0
- data/spec/fixtures/contact_my.json +19 -0
- data/spec/fixtures/contact_new.json +11 -0
- data/spec/fixtures/contact_new_empty.json +8 -0
- data/spec/fixtures/contact_new_notify.json +11 -0
- data/spec/fixtures/contact_tags.json +11 -0
- data/spec/fixtures/contacts.json +6 -3
- data/spec/fixtures/contacts_post.json +10 -0
- data/spec/fixtures/empty.json +3 -0
- data/spec/fixtures/errors/failure.json +5 -0
- data/spec/fixtures/listing_cart.json +19 -0
- data/spec/fixtures/listing_cart_add_listing.json +13 -0
- data/spec/fixtures/listing_cart_add_listing_post.json +5 -0
- data/spec/fixtures/listing_cart_empty.json +5 -0
- data/spec/fixtures/listing_cart_new.json +12 -0
- data/spec/fixtures/listing_cart_post.json +10 -0
- data/spec/fixtures/listing_cart_remove_listing.json +13 -0
- data/spec/fixtures/note_new.json +5 -0
- data/spec/fixtures/{oauth2_access.json → oauth2/access.json} +0 -0
- data/spec/fixtures/oauth2/access_with_old_refresh.json +5 -0
- data/spec/fixtures/oauth2/access_with_refresh.json +5 -0
- data/spec/fixtures/oauth2/authorization_code_body.json +7 -0
- data/spec/fixtures/oauth2/error.json +3 -0
- data/spec/fixtures/oauth2/password_body.json +7 -0
- data/spec/fixtures/oauth2/refresh_body.json +7 -0
- data/spec/fixtures/saved_search.json +17 -0
- data/spec/fixtures/shared_listing_new.json +9 -0
- data/spec/fixtures/shared_listing_post.json +10 -0
- data/spec/mock_helper.rb +123 -0
- data/spec/oauth2_helper.rb +69 -0
- data/spec/spec_helper.rb +1 -57
- data/spec/unit/flexmls_api/authentication/api_auth_spec.rb +1 -0
- data/spec/unit/flexmls_api/authentication/oauth2_impl/grant_type_base_spec.rb +10 -0
- data/spec/unit/flexmls_api/authentication/oauth2_spec.rb +74 -79
- data/spec/unit/flexmls_api/configuration_spec.rb +25 -4
- data/spec/unit/flexmls_api/models/account_spec.rb +152 -85
- data/spec/unit/flexmls_api/models/base_spec.rb +69 -25
- data/spec/unit/flexmls_api/models/contact_spec.rb +48 -34
- data/spec/unit/flexmls_api/models/document_spec.rb +1 -7
- data/spec/unit/flexmls_api/models/listing_cart_spec.rb +114 -0
- data/spec/unit/flexmls_api/models/listing_spec.rb +8 -56
- data/spec/unit/flexmls_api/models/note_spec.rb +8 -38
- data/spec/unit/flexmls_api/models/photo_spec.rb +1 -11
- data/spec/unit/flexmls_api/models/saved_search_spec.rb +34 -0
- data/spec/unit/flexmls_api/models/shared_listing_spec.rb +30 -0
- data/spec/unit/flexmls_api/models/standard_fields_spec.rb +50 -30
- data/spec/unit/flexmls_api/models/tour_of_home_spec.rb +1 -7
- data/spec/unit/flexmls_api/models/video_spec.rb +1 -10
- data/spec/unit/flexmls_api/models/virtual_tour_spec.rb +1 -7
- data/spec/unit/flexmls_api/multi_client_spec.rb +48 -0
- data/spec/unit/flexmls_api/request_spec.rb +42 -5
- metadata +239 -93
- data/spec/unit/flexmls_api/standard_fields_spec.rb +0 -86
@@ -1,86 +0,0 @@
|
|
1
|
-
require './spec/spec_helper'
|
2
|
-
|
3
|
-
describe StandardFields do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
stub_auth_request
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
it "should respond to get" do
|
11
|
-
StandardFields.should respond_to(:get)
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
it "should find and expand all" do
|
16
|
-
StandardFields.should respond_to(:find_and_expand_all)
|
17
|
-
|
18
|
-
# stub request to standardFields
|
19
|
-
stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/standardfields").
|
20
|
-
with(:query => {
|
21
|
-
:ApiSig => "e8c27a6d4b96ed4267776581917bc9ef",
|
22
|
-
:AuthToken => "c401736bf3d3f754f07c04e460e09573",
|
23
|
-
:ApiUser => "foobar"
|
24
|
-
}).
|
25
|
-
to_return(:body => fixture('standardfields.json'))
|
26
|
-
|
27
|
-
# stub request for City
|
28
|
-
stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/standardfields/City").
|
29
|
-
with(:query => {
|
30
|
-
:ApiSig => "447045bf65019ed960ee16ba64311e7f",
|
31
|
-
:AuthToken => "c401736bf3d3f754f07c04e460e09573",
|
32
|
-
:ApiUser => "foobar"
|
33
|
-
}).
|
34
|
-
to_return(:body => fixture('standardfields_city.json'))
|
35
|
-
|
36
|
-
# stub request for StateOrProvince
|
37
|
-
stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/standardfields/StateOrProvince").
|
38
|
-
with(:query => {
|
39
|
-
:ApiSig => "2828f29a5c68978cb29e6048d0f82a31",
|
40
|
-
:AuthToken => "c401736bf3d3f754f07c04e460e09573",
|
41
|
-
:ApiUser => "foobar"
|
42
|
-
}).
|
43
|
-
to_return(:body => fixture('standardfields_stateorprovince.json'))
|
44
|
-
|
45
|
-
# request
|
46
|
-
fields = StandardFields.find_and_expand_all(["City","StateOrProvince"])
|
47
|
-
|
48
|
-
# keys are present
|
49
|
-
fields.should have_key("City")
|
50
|
-
fields.should have_key("StateOrProvince")
|
51
|
-
fields.should_not have_key("SubdivisionName")
|
52
|
-
|
53
|
-
# FieldList
|
54
|
-
fields["City"]["FieldList"].length.should eq(235)
|
55
|
-
fields["StateOrProvince"]["FieldList"].length.should eq(5)
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
it "should find nearby fields" do
|
61
|
-
StandardFields.should respond_to(:find_nearby)
|
62
|
-
|
63
|
-
# stub request
|
64
|
-
stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/standardfields/nearby/A").
|
65
|
-
with(:query => {
|
66
|
-
:ApiSig => "0601ee6e972659098318721a3c0ecb00",
|
67
|
-
:AuthToken => "c401736bf3d3f754f07c04e460e09573",
|
68
|
-
:ApiUser => "foobar",
|
69
|
-
:Lat => "50",
|
70
|
-
:Lon => "-92",
|
71
|
-
:_expand => "1"
|
72
|
-
}).
|
73
|
-
to_return(:body => fixture('standardfields_nearby.json'))
|
74
|
-
|
75
|
-
# request
|
76
|
-
fields = StandardFields.find_nearby(["A"], {:Lat => 50, :Lon => -92})
|
77
|
-
|
78
|
-
# validate response
|
79
|
-
fields["D"]["Success"].should eq(true)
|
80
|
-
fields["D"]["Results"].first.should have_key("City")
|
81
|
-
fields["D"]["Results"].first.should have_key("PostalCode")
|
82
|
-
fields["D"]["Results"].first.should have_key("StateOrProvince")
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|