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.
Files changed (93) hide show
  1. data/Gemfile +2 -17
  2. data/Gemfile.lock +35 -27
  3. data/README.md +23 -1
  4. data/Rakefile +18 -5
  5. data/VERSION +1 -1
  6. data/bin/flexmls_api +8 -0
  7. data/lib/flexmls_api.rb +2 -0
  8. data/lib/flexmls_api/authentication.rb +5 -6
  9. data/lib/flexmls_api/authentication/api_auth.rb +4 -2
  10. data/lib/flexmls_api/authentication/oauth2.rb +51 -99
  11. data/lib/flexmls_api/authentication/oauth2_impl/grant_type_base.rb +85 -0
  12. data/lib/flexmls_api/authentication/oauth2_impl/grant_type_code.rb +48 -0
  13. data/lib/flexmls_api/authentication/oauth2_impl/grant_type_password.rb +45 -0
  14. data/lib/flexmls_api/authentication/oauth2_impl/grant_type_refresh.rb +36 -0
  15. data/lib/flexmls_api/authentication/oauth2_impl/middleware.rb +39 -0
  16. data/lib/flexmls_api/cli.rb +132 -0
  17. data/lib/flexmls_api/cli/api_auth.rb +8 -0
  18. data/lib/flexmls_api/cli/oauth2.rb +43 -0
  19. data/lib/flexmls_api/cli/setup.rb +44 -0
  20. data/lib/flexmls_api/configuration.rb +6 -6
  21. data/lib/flexmls_api/faraday.rb +11 -21
  22. data/lib/flexmls_api/models.rb +3 -0
  23. data/lib/flexmls_api/models/account.rb +48 -5
  24. data/lib/flexmls_api/models/base.rb +27 -2
  25. data/lib/flexmls_api/models/contact.rb +28 -9
  26. data/lib/flexmls_api/models/listing_cart.rb +72 -0
  27. data/lib/flexmls_api/models/note.rb +0 -2
  28. data/lib/flexmls_api/models/saved_search.rb +16 -0
  29. data/lib/flexmls_api/models/shared_listing.rb +35 -0
  30. data/lib/flexmls_api/multi_client.rb +37 -0
  31. data/lib/flexmls_api/paginate.rb +5 -0
  32. data/lib/flexmls_api/request.rb +7 -3
  33. data/script/console +6 -0
  34. data/script/example.rb +27 -0
  35. data/spec/fixtures/accounts/all.json +160 -0
  36. data/spec/fixtures/accounts/my.json +74 -0
  37. data/spec/fixtures/accounts/my_portal.json +20 -0
  38. data/spec/fixtures/accounts/my_put.json +5 -0
  39. data/spec/fixtures/accounts/my_save.json +5 -0
  40. data/spec/fixtures/accounts/office.json +142 -0
  41. data/spec/fixtures/base.json +13 -0
  42. data/spec/fixtures/contact_my.json +19 -0
  43. data/spec/fixtures/contact_new.json +11 -0
  44. data/spec/fixtures/contact_new_empty.json +8 -0
  45. data/spec/fixtures/contact_new_notify.json +11 -0
  46. data/spec/fixtures/contact_tags.json +11 -0
  47. data/spec/fixtures/contacts.json +6 -3
  48. data/spec/fixtures/contacts_post.json +10 -0
  49. data/spec/fixtures/empty.json +3 -0
  50. data/spec/fixtures/errors/failure.json +5 -0
  51. data/spec/fixtures/listing_cart.json +19 -0
  52. data/spec/fixtures/listing_cart_add_listing.json +13 -0
  53. data/spec/fixtures/listing_cart_add_listing_post.json +5 -0
  54. data/spec/fixtures/listing_cart_empty.json +5 -0
  55. data/spec/fixtures/listing_cart_new.json +12 -0
  56. data/spec/fixtures/listing_cart_post.json +10 -0
  57. data/spec/fixtures/listing_cart_remove_listing.json +13 -0
  58. data/spec/fixtures/note_new.json +5 -0
  59. data/spec/fixtures/{oauth2_access.json → oauth2/access.json} +0 -0
  60. data/spec/fixtures/oauth2/access_with_old_refresh.json +5 -0
  61. data/spec/fixtures/oauth2/access_with_refresh.json +5 -0
  62. data/spec/fixtures/oauth2/authorization_code_body.json +7 -0
  63. data/spec/fixtures/oauth2/error.json +3 -0
  64. data/spec/fixtures/oauth2/password_body.json +7 -0
  65. data/spec/fixtures/oauth2/refresh_body.json +7 -0
  66. data/spec/fixtures/saved_search.json +17 -0
  67. data/spec/fixtures/shared_listing_new.json +9 -0
  68. data/spec/fixtures/shared_listing_post.json +10 -0
  69. data/spec/mock_helper.rb +123 -0
  70. data/spec/oauth2_helper.rb +69 -0
  71. data/spec/spec_helper.rb +1 -57
  72. data/spec/unit/flexmls_api/authentication/api_auth_spec.rb +1 -0
  73. data/spec/unit/flexmls_api/authentication/oauth2_impl/grant_type_base_spec.rb +10 -0
  74. data/spec/unit/flexmls_api/authentication/oauth2_spec.rb +74 -79
  75. data/spec/unit/flexmls_api/configuration_spec.rb +25 -4
  76. data/spec/unit/flexmls_api/models/account_spec.rb +152 -85
  77. data/spec/unit/flexmls_api/models/base_spec.rb +69 -25
  78. data/spec/unit/flexmls_api/models/contact_spec.rb +48 -34
  79. data/spec/unit/flexmls_api/models/document_spec.rb +1 -7
  80. data/spec/unit/flexmls_api/models/listing_cart_spec.rb +114 -0
  81. data/spec/unit/flexmls_api/models/listing_spec.rb +8 -56
  82. data/spec/unit/flexmls_api/models/note_spec.rb +8 -38
  83. data/spec/unit/flexmls_api/models/photo_spec.rb +1 -11
  84. data/spec/unit/flexmls_api/models/saved_search_spec.rb +34 -0
  85. data/spec/unit/flexmls_api/models/shared_listing_spec.rb +30 -0
  86. data/spec/unit/flexmls_api/models/standard_fields_spec.rb +50 -30
  87. data/spec/unit/flexmls_api/models/tour_of_home_spec.rb +1 -7
  88. data/spec/unit/flexmls_api/models/video_spec.rb +1 -10
  89. data/spec/unit/flexmls_api/models/virtual_tour_spec.rb +1 -7
  90. data/spec/unit/flexmls_api/multi_client_spec.rb +48 -0
  91. data/spec/unit/flexmls_api/request_spec.rb +42 -5
  92. metadata +239 -93
  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