spark_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. data/History.txt +139 -0
  2. data/LICENSE +14 -0
  3. data/README.md +153 -0
  4. data/Rakefile +18 -0
  5. data/VERSION +1 -0
  6. data/bin/spark_api +8 -0
  7. data/bin/spark_api~ +8 -0
  8. data/lib/spark_api.rb +46 -0
  9. data/lib/spark_api/authentication.rb +55 -0
  10. data/lib/spark_api/authentication/api_auth.rb +104 -0
  11. data/lib/spark_api/authentication/api_auth.rb~ +104 -0
  12. data/lib/spark_api/authentication/base_auth.rb +47 -0
  13. data/lib/spark_api/authentication/base_auth.rb~ +47 -0
  14. data/lib/spark_api/authentication/oauth2.rb +198 -0
  15. data/lib/spark_api/authentication/oauth2.rb~ +199 -0
  16. data/lib/spark_api/authentication/oauth2_impl/grant_type_base.rb +87 -0
  17. data/lib/spark_api/authentication/oauth2_impl/grant_type_base.rb~ +87 -0
  18. data/lib/spark_api/authentication/oauth2_impl/grant_type_code.rb +48 -0
  19. data/lib/spark_api/authentication/oauth2_impl/grant_type_code.rb~ +49 -0
  20. data/lib/spark_api/authentication/oauth2_impl/grant_type_password.rb +44 -0
  21. data/lib/spark_api/authentication/oauth2_impl/grant_type_password.rb~ +45 -0
  22. data/lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb +35 -0
  23. data/lib/spark_api/authentication/oauth2_impl/grant_type_refresh.rb~ +36 -0
  24. data/lib/spark_api/authentication/oauth2_impl/middleware.rb +38 -0
  25. data/lib/spark_api/authentication/oauth2_impl/middleware.rb~ +39 -0
  26. data/lib/spark_api/authentication/oauth2_impl/password_provider.rb +24 -0
  27. data/lib/spark_api/authentication/oauth2_impl/password_provider.rb~ +25 -0
  28. data/lib/spark_api/cli.rb +158 -0
  29. data/lib/spark_api/cli.rb~ +158 -0
  30. data/lib/spark_api/cli/api_auth.rb +8 -0
  31. data/lib/spark_api/cli/api_auth.rb~ +8 -0
  32. data/lib/spark_api/cli/oauth2.rb +14 -0
  33. data/lib/spark_api/cli/oauth2.rb~ +14 -0
  34. data/lib/spark_api/cli/setup.rb +47 -0
  35. data/lib/spark_api/cli/setup.rb~ +47 -0
  36. data/lib/spark_api/client.rb +27 -0
  37. data/lib/spark_api/configuration.rb +54 -0
  38. data/lib/spark_api/configuration.rb~ +54 -0
  39. data/lib/spark_api/configuration/yaml.rb +101 -0
  40. data/lib/spark_api/configuration/yaml.rb~ +101 -0
  41. data/lib/spark_api/connection.rb +42 -0
  42. data/lib/spark_api/faraday.rb +64 -0
  43. data/lib/spark_api/faraday.rb~ +64 -0
  44. data/lib/spark_api/models.rb +33 -0
  45. data/lib/spark_api/models.rb~ +33 -0
  46. data/lib/spark_api/models/account.rb +115 -0
  47. data/lib/spark_api/models/account.rb~ +115 -0
  48. data/lib/spark_api/models/base.rb +118 -0
  49. data/lib/spark_api/models/base.rb~ +118 -0
  50. data/lib/spark_api/models/connect_prefs.rb +10 -0
  51. data/lib/spark_api/models/connect_prefs.rb~ +10 -0
  52. data/lib/spark_api/models/constraint.rb +16 -0
  53. data/lib/spark_api/models/constraint.rb~ +16 -0
  54. data/lib/spark_api/models/contact.rb +49 -0
  55. data/lib/spark_api/models/contact.rb~ +49 -0
  56. data/lib/spark_api/models/custom_fields.rb +12 -0
  57. data/lib/spark_api/models/custom_fields.rb~ +12 -0
  58. data/lib/spark_api/models/document.rb +11 -0
  59. data/lib/spark_api/models/document.rb~ +11 -0
  60. data/lib/spark_api/models/finders.rb +45 -0
  61. data/lib/spark_api/models/finders.rb~ +45 -0
  62. data/lib/spark_api/models/idx_link.rb +47 -0
  63. data/lib/spark_api/models/idx_link.rb~ +47 -0
  64. data/lib/spark_api/models/listing.rb +197 -0
  65. data/lib/spark_api/models/listing.rb~ +197 -0
  66. data/lib/spark_api/models/listing_cart.rb +72 -0
  67. data/lib/spark_api/models/listing_cart.rb~ +72 -0
  68. data/lib/spark_api/models/market_statistics.rb +33 -0
  69. data/lib/spark_api/models/market_statistics.rb~ +33 -0
  70. data/lib/spark_api/models/message.rb +21 -0
  71. data/lib/spark_api/models/message.rb~ +21 -0
  72. data/lib/spark_api/models/note.rb +41 -0
  73. data/lib/spark_api/models/note.rb~ +41 -0
  74. data/lib/spark_api/models/notification.rb +42 -0
  75. data/lib/spark_api/models/notification.rb~ +42 -0
  76. data/lib/spark_api/models/open_house.rb +24 -0
  77. data/lib/spark_api/models/open_house.rb~ +24 -0
  78. data/lib/spark_api/models/photo.rb +70 -0
  79. data/lib/spark_api/models/photo.rb~ +70 -0
  80. data/lib/spark_api/models/property_types.rb +7 -0
  81. data/lib/spark_api/models/property_types.rb~ +7 -0
  82. data/lib/spark_api/models/saved_search.rb +16 -0
  83. data/lib/spark_api/models/saved_search.rb~ +16 -0
  84. data/lib/spark_api/models/shared_listing.rb +35 -0
  85. data/lib/spark_api/models/shared_listing.rb~ +35 -0
  86. data/lib/spark_api/models/standard_fields.rb +50 -0
  87. data/lib/spark_api/models/standard_fields.rb~ +50 -0
  88. data/lib/spark_api/models/subresource.rb +19 -0
  89. data/lib/spark_api/models/subresource.rb~ +19 -0
  90. data/lib/spark_api/models/system_info.rb +14 -0
  91. data/lib/spark_api/models/system_info.rb~ +14 -0
  92. data/lib/spark_api/models/tour_of_home.rb +24 -0
  93. data/lib/spark_api/models/tour_of_home.rb~ +24 -0
  94. data/lib/spark_api/models/video.rb +16 -0
  95. data/lib/spark_api/models/video.rb~ +16 -0
  96. data/lib/spark_api/models/virtual_tour.rb +18 -0
  97. data/lib/spark_api/models/virtual_tour.rb~ +18 -0
  98. data/lib/spark_api/multi_client.rb +59 -0
  99. data/lib/spark_api/multi_client.rb~ +59 -0
  100. data/lib/spark_api/paginate.rb +109 -0
  101. data/lib/spark_api/paginate.rb~ +109 -0
  102. data/lib/spark_api/primary_array.rb +29 -0
  103. data/lib/spark_api/primary_array.rb~ +29 -0
  104. data/lib/spark_api/request.rb +96 -0
  105. data/lib/spark_api/request.rb~ +96 -0
  106. data/lib/spark_api/response.rb +70 -0
  107. data/lib/spark_api/response.rb~ +70 -0
  108. data/lib/spark_api/version.rb +4 -0
  109. data/lib/spark_api/version.rb~ +4 -0
  110. data/script/console +6 -0
  111. data/script/console~ +6 -0
  112. data/script/example.rb +27 -0
  113. data/script/example.rb~ +27 -0
  114. data/spec/fixtures/accounts/all.json +160 -0
  115. data/spec/fixtures/accounts/my.json +74 -0
  116. data/spec/fixtures/accounts/my_portal.json +20 -0
  117. data/spec/fixtures/accounts/my_put.json +5 -0
  118. data/spec/fixtures/accounts/my_save.json +5 -0
  119. data/spec/fixtures/accounts/office.json +142 -0
  120. data/spec/fixtures/accounts/password_save.json +6 -0
  121. data/spec/fixtures/authentication_failure.json +7 -0
  122. data/spec/fixtures/base.json +13 -0
  123. data/spec/fixtures/contacts/contacts.json +28 -0
  124. data/spec/fixtures/contacts/my.json +19 -0
  125. data/spec/fixtures/contacts/new.json +11 -0
  126. data/spec/fixtures/contacts/new_empty.json +8 -0
  127. data/spec/fixtures/contacts/new_notify.json +11 -0
  128. data/spec/fixtures/contacts/post.json +10 -0
  129. data/spec/fixtures/contacts/tags.json +11 -0
  130. data/spec/fixtures/count.json +10 -0
  131. data/spec/fixtures/empty.json +3 -0
  132. data/spec/fixtures/errors/expired.json +7 -0
  133. data/spec/fixtures/errors/failure.json +5 -0
  134. data/spec/fixtures/errors/failure_with_constraint.json +17 -0
  135. data/spec/fixtures/errors/failure_with_msg.json +7 -0
  136. data/spec/fixtures/generic_delete.json +1 -0
  137. data/spec/fixtures/generic_failure.json +5 -0
  138. data/spec/fixtures/listing_carts/add_listing.json +13 -0
  139. data/spec/fixtures/listing_carts/add_listing_post.json +5 -0
  140. data/spec/fixtures/listing_carts/empty.json +5 -0
  141. data/spec/fixtures/listing_carts/listing_cart.json +19 -0
  142. data/spec/fixtures/listing_carts/new.json +12 -0
  143. data/spec/fixtures/listing_carts/post.json +10 -0
  144. data/spec/fixtures/listing_carts/remove_listing.json +13 -0
  145. data/spec/fixtures/listings/constraints.json +18 -0
  146. data/spec/fixtures/listings/constraints_with_pagination.json +24 -0
  147. data/spec/fixtures/listings/document_index.json +19 -0
  148. data/spec/fixtures/listings/multiple.json +69 -0
  149. data/spec/fixtures/listings/no_subresources.json +38 -0
  150. data/spec/fixtures/listings/open_houses.json +21 -0
  151. data/spec/fixtures/listings/photos/index.json +469 -0
  152. data/spec/fixtures/listings/photos/new.json +12 -0
  153. data/spec/fixtures/listings/photos/post.json +20 -0
  154. data/spec/fixtures/listings/put.json +5 -0
  155. data/spec/fixtures/listings/put_expiration_date.json +5 -0
  156. data/spec/fixtures/listings/saved_search.json +17 -0
  157. data/spec/fixtures/listings/shared_listing_get.json +14 -0
  158. data/spec/fixtures/listings/shared_listing_new.json +9 -0
  159. data/spec/fixtures/listings/shared_listing_post.json +10 -0
  160. data/spec/fixtures/listings/tour_of_homes.json +23 -0
  161. data/spec/fixtures/listings/videos_index.json +18 -0
  162. data/spec/fixtures/listings/virtual_tours_index.json +42 -0
  163. data/spec/fixtures/listings/with_documents.json +52 -0
  164. data/spec/fixtures/listings/with_permissions.json +44 -0
  165. data/spec/fixtures/listings/with_photos.json +110 -0
  166. data/spec/fixtures/listings/with_supplement.json +39 -0
  167. data/spec/fixtures/listings/with_videos.json +54 -0
  168. data/spec/fixtures/listings/with_vtour.json +48 -0
  169. data/spec/fixtures/logo_fbs.png +0 -0
  170. data/spec/fixtures/messages/new.json +14 -0
  171. data/spec/fixtures/messages/new_empty.json +7 -0
  172. data/spec/fixtures/messages/new_with_recipients.json +15 -0
  173. data/spec/fixtures/messages/post.json +5 -0
  174. data/spec/fixtures/notes/add.json +11 -0
  175. data/spec/fixtures/notes/agent_shared.json +11 -0
  176. data/spec/fixtures/notes/agent_shared_empty.json +7 -0
  177. data/spec/fixtures/notes/new.json +5 -0
  178. data/spec/fixtures/notifications/mark_read.json +1 -0
  179. data/spec/fixtures/notifications/new.json +8 -0
  180. data/spec/fixtures/notifications/new_empty.json +7 -0
  181. data/spec/fixtures/notifications/notifications.json +43 -0
  182. data/spec/fixtures/notifications/post.json +10 -0
  183. data/spec/fixtures/notifications/unread.json +10 -0
  184. data/spec/fixtures/oauth2/access.json +3 -0
  185. data/spec/fixtures/oauth2/access_with_old_refresh.json +5 -0
  186. data/spec/fixtures/oauth2/access_with_refresh.json +5 -0
  187. data/spec/fixtures/oauth2/authorization_code_body.json +7 -0
  188. data/spec/fixtures/oauth2/error.json +3 -0
  189. data/spec/fixtures/oauth2/password_body.json +7 -0
  190. data/spec/fixtures/oauth2/refresh_body.json +7 -0
  191. data/spec/fixtures/oauth2_error.json +3 -0
  192. data/spec/fixtures/property_types/property_types.json +31 -0
  193. data/spec/fixtures/session.json +10 -0
  194. data/spec/fixtures/standardfields/city.json +1031 -0
  195. data/spec/fixtures/standardfields/nearby.json +53 -0
  196. data/spec/fixtures/standardfields/standardfields.json +188 -0
  197. data/spec/fixtures/standardfields/stateorprovince.json +36 -0
  198. data/spec/fixtures/success.json +5 -0
  199. data/spec/json_helper.rb +76 -0
  200. data/spec/mock_helper.rb +124 -0
  201. data/spec/oauth2_helper.rb +68 -0
  202. data/spec/spec_helper.rb +48 -0
  203. data/spec/unit/flexmls_api_spec.rb~ +23 -0
  204. data/spec/unit/spark_api/authentication/api_auth_spec.rb +169 -0
  205. data/spec/unit/spark_api/authentication/api_auth_spec.rb~ +169 -0
  206. data/spec/unit/spark_api/authentication/base_auth_spec.rb +10 -0
  207. data/spec/unit/spark_api/authentication/base_auth_spec.rb~ +10 -0
  208. data/spec/unit/spark_api/authentication/oauth2_impl/grant_type_base_spec.rb +10 -0
  209. data/spec/unit/spark_api/authentication/oauth2_impl/grant_type_base_spec.rb~ +10 -0
  210. data/spec/unit/spark_api/authentication/oauth2_spec.rb +205 -0
  211. data/spec/unit/spark_api/authentication/oauth2_spec.rb~ +205 -0
  212. data/spec/unit/spark_api/authentication_spec.rb +38 -0
  213. data/spec/unit/spark_api/authentication_spec.rb~ +38 -0
  214. data/spec/unit/spark_api/configuration/yaml_spec.rb +72 -0
  215. data/spec/unit/spark_api/configuration/yaml_spec.rb~ +72 -0
  216. data/spec/unit/spark_api/configuration_spec.rb +122 -0
  217. data/spec/unit/spark_api/configuration_spec.rb~ +122 -0
  218. data/spec/unit/spark_api/faraday_spec.rb +90 -0
  219. data/spec/unit/spark_api/faraday_spec.rb~ +90 -0
  220. data/spec/unit/spark_api/models/account_spec.rb +176 -0
  221. data/spec/unit/spark_api/models/base_spec.rb +106 -0
  222. data/spec/unit/spark_api/models/connect_prefs_spec.rb +9 -0
  223. data/spec/unit/spark_api/models/constraint_spec.rb +19 -0
  224. data/spec/unit/spark_api/models/contact_spec.rb +108 -0
  225. data/spec/unit/spark_api/models/contact_spec.rb~ +108 -0
  226. data/spec/unit/spark_api/models/document_spec.rb +32 -0
  227. data/spec/unit/spark_api/models/listing_cart_spec.rb +127 -0
  228. data/spec/unit/spark_api/models/listing_cart_spec.rb~ +127 -0
  229. data/spec/unit/spark_api/models/listing_spec.rb +320 -0
  230. data/spec/unit/spark_api/models/listing_spec.rb~ +320 -0
  231. data/spec/unit/spark_api/models/message_spec.rb +47 -0
  232. data/spec/unit/spark_api/models/message_spec.rb~ +47 -0
  233. data/spec/unit/spark_api/models/note_spec.rb +63 -0
  234. data/spec/unit/spark_api/models/note_spec.rb~ +63 -0
  235. data/spec/unit/spark_api/models/notification_spec.rb +62 -0
  236. data/spec/unit/spark_api/models/notification_spec.rb~ +62 -0
  237. data/spec/unit/spark_api/models/open_house_spec.rb +39 -0
  238. data/spec/unit/spark_api/models/photo_spec.rb +92 -0
  239. data/spec/unit/spark_api/models/property_types_spec.rb +33 -0
  240. data/spec/unit/spark_api/models/saved_search_spec.rb +40 -0
  241. data/spec/unit/spark_api/models/shared_listing_spec.rb +45 -0
  242. data/spec/unit/spark_api/models/shared_listing_spec.rb~ +45 -0
  243. data/spec/unit/spark_api/models/standard_fields_spec.rb +60 -0
  244. data/spec/unit/spark_api/models/system_info_spec.rb +83 -0
  245. data/spec/unit/spark_api/models/tour_of_home_spec.rb +44 -0
  246. data/spec/unit/spark_api/models/video_spec.rb +36 -0
  247. data/spec/unit/spark_api/models/virtual_tour_spec.rb +44 -0
  248. data/spec/unit/spark_api/multi_client_spec.rb +56 -0
  249. data/spec/unit/spark_api/multi_client_spec.rb~ +56 -0
  250. data/spec/unit/spark_api/paginate_spec.rb +224 -0
  251. data/spec/unit/spark_api/paginate_spec.rb~ +224 -0
  252. data/spec/unit/spark_api/primary_array_spec.rb +41 -0
  253. data/spec/unit/spark_api/primary_array_spec.rb~ +41 -0
  254. data/spec/unit/spark_api/request_spec.rb +344 -0
  255. data/spec/unit/spark_api/request_spec.rb~ +344 -0
  256. data/spec/unit/spark_api_spec.rb +23 -0
  257. metadata +725 -0
@@ -0,0 +1,53 @@
1
+ {
2
+ "D": {
3
+ "Success": true,
4
+ "Results": [{
5
+ "City": {
6
+ "ResourceUri": "/v1/standardfields/nearby/A/City",
7
+ "HasList": true,
8
+ "FieldList": [{
9
+ "Name": "Fargo",
10
+ "Value": "'Fargo'"
11
+ },
12
+ {
13
+ "Name": "Moorhead",
14
+ "Value": "'Moorhead'"
15
+ }],
16
+ "Searchable": true,
17
+ "Type": "Character"
18
+ },
19
+ "PostalCode": {
20
+ "ResourceUri": "/v1/standardfields/nearby/A/PostalCode",
21
+ "HasList": true,
22
+ "FieldList": [{
23
+ "Name": "56560",
24
+ "Value": "'56560'"
25
+ },
26
+ {
27
+ "Name": "58102",
28
+ "Value": "'58102'"
29
+ },
30
+ {
31
+ "Name": "58103",
32
+ "Value": "'58103'"
33
+ }],
34
+ "Searchable": true,
35
+ "Type": "Character"
36
+ },
37
+ "StateOrProvince": {
38
+ "ResourceUri": "/v1/standardfields/nearby/A/StateOrProvince",
39
+ "HasList": true,
40
+ "FieldList": [{
41
+ "Name": "MN",
42
+ "Value": "'MN'"
43
+ },
44
+ {
45
+ "Name": "ND",
46
+ "Value": "'ND'"
47
+ }],
48
+ "Searchable": true,
49
+ "Type": "Character"
50
+ }
51
+ }]
52
+ }
53
+ }
@@ -0,0 +1,188 @@
1
+ {
2
+ "D": {
3
+ "Success": true,
4
+ "Results": [
5
+ {
6
+ "MLSAreaMinor": {
7
+ "ResourceUri": "/v1/standardfields/MLSAreaMinor",
8
+ "HasList": true,
9
+ "Searchable": true,
10
+ "Type": "Character"
11
+ },
12
+ "StreetNumber": {
13
+ "ResourceUri": "/v1/standardfields/StreetNumber",
14
+ "HasList": false,
15
+ "Searchable": true,
16
+ "Type": "Character"
17
+ },
18
+ "ListingId": {
19
+ "ResourceUri": "/v1/standardfields/ListingId",
20
+ "HasList": false,
21
+ "Searchable": true,
22
+ "Type": "Character"
23
+ },
24
+ "City": {
25
+ "ResourceUri": "/v1/standardfields/City",
26
+ "HasList": true,
27
+ "Searchable": true,
28
+ "Type": "Character"
29
+ },
30
+ "Longitude": {
31
+ "ResourceUri": "/v1/standardfields/Longitude",
32
+ "HasList": false,
33
+ "Searchable": false,
34
+ "Type": "Decimal"
35
+ },
36
+ "StreetName": {
37
+ "ResourceUri": "/v1/standardfields/StreetName",
38
+ "HasList": false,
39
+ "Searchable": true,
40
+ "Type": "Character"
41
+ },
42
+ "YearBuilt": {
43
+ "ResourceUri": "/v1/standardfields/YearBuilt",
44
+ "HasList": false,
45
+ "Searchable": true,
46
+ "Type": "Integer"
47
+ },
48
+ "BuildingAreaTotal": {
49
+ "ResourceUri": "/v1/standardfields/BuildingAreaTotal",
50
+ "HasList": false,
51
+ "Searchable": true,
52
+ "Type": "Decimal"
53
+ },
54
+ "PublicRemarks": {
55
+ "ResourceUri": "/v1/standardfields/PublicRemarks",
56
+ "HasList": false,
57
+ "Searchable": false,
58
+ "Type": "Character"
59
+ },
60
+ "PostalCode": {
61
+ "ResourceUri": "/v1/standardfields/PostalCode",
62
+ "HasList": true,
63
+ "Searchable": true,
64
+ "Type": "Character"
65
+ },
66
+ "ListPrice": {
67
+ "ResourceUri": "/v1/standardfields/ListPrice",
68
+ "HasList": false,
69
+ "Searchable": true,
70
+ "Type": "Decimal"
71
+ },
72
+ "SubdivisionName": {
73
+ "ResourceUri": "/v1/standardfields/SubdivisionName",
74
+ "HasList": false,
75
+ "Searchable": true,
76
+ "Type": "Character"
77
+ },
78
+ "BathsThreeQuarter": {
79
+ "ResourceUri": "/v1/standardfields/BathsThreeQuarter",
80
+ "HasList": false,
81
+ "Searchable": true,
82
+ "Type": "Integer"
83
+ },
84
+ "Latitude": {
85
+ "ResourceUri": "/v1/standardfields/Latitude",
86
+ "HasList": false,
87
+ "Searchable": false,
88
+ "Type": "Decimal"
89
+ },
90
+ "MlsStatusInformation": {
91
+ "ResourceUri": "/v1/standardfields/MlsStatusInformation",
92
+ "HasList": true,
93
+ "Searchable": false,
94
+ "Type": "Character"
95
+ },
96
+ "StreetDirPrefix": {
97
+ "ResourceUri": "/v1/standardfields/StreetDirPrefix",
98
+ "HasList": true,
99
+ "Searchable": true,
100
+ "Type": "Character"
101
+ },
102
+ "StreetAdditionalInfo": {
103
+ "ResourceUri": "/v1/standardfields/StreetAdditionalInfo",
104
+ "HasList": false,
105
+ "Searchable": true,
106
+ "Type": "Character"
107
+ },
108
+ "PropertyType": {
109
+ "ResourceUri": "/v1/standardfields/PropertyType",
110
+ "HasList": false,
111
+ "Searchable": true,
112
+ "Type": "Character"
113
+ },
114
+ "StateOrProvince": {
115
+ "ResourceUri": "/v1/standardfields/StateOrProvince",
116
+ "HasList": true,
117
+ "Searchable": true,
118
+ "Type": "Character"
119
+ },
120
+ "BathsTotal": {
121
+ "ResourceUri": "/v1/standardfields/BathsTotal",
122
+ "HasList": false,
123
+ "Searchable": true,
124
+ "Type": "Decimal"
125
+ },
126
+ "BathsFull": {
127
+ "ResourceUri": "/v1/standardfields/BathsFull",
128
+ "HasList": false,
129
+ "Searchable": true,
130
+ "Type": "Integer"
131
+ },
132
+ "ListingKey": {
133
+ "ResourceUri": "/v1/standardfields/ListingKey",
134
+ "HasList": false,
135
+ "Searchable": false,
136
+ "Type": "Character"
137
+ },
138
+ "StreetDirSuffix": {
139
+ "ResourceUri": "/v1/standardfields/StreetDirSuffix",
140
+ "HasList": false,
141
+ "Searchable": true,
142
+ "Type": "Character"
143
+ },
144
+ "BedsTotal": {
145
+ "ResourceUri": "/v1/standardfields/BedsTotal",
146
+ "HasList": false,
147
+ "Searchable": true,
148
+ "Type": "Integer"
149
+ },
150
+ "ModificationTimestamp": {
151
+ "ResourceUri": "/v1/standardfields/ModificationTimestamp",
152
+ "HasList": false,
153
+ "Searchable": false,
154
+ "Type": "Datetime"
155
+ },
156
+ "MlsStatus": {
157
+ "ResourceUri": "/v1/standardfields/MlsStatus",
158
+ "HasList": true,
159
+ "Searchable": false,
160
+ "Type": "Character"
161
+ },
162
+ "BathsHalf": {
163
+ "ResourceUri": "/v1/standardfields/BathsHalf",
164
+ "HasList": false,
165
+ "Searchable": true,
166
+ "Type": "Integer"
167
+ },
168
+ "PropertySubType": {
169
+ "ResourceUri": "/v1/standardfields/PropertySubType",
170
+ "HasList": true,
171
+ "Searchable": true,
172
+ "Type": "Character"
173
+ },
174
+ "PrivateRemarks": {
175
+ "ResourceUri": "/v1/standardfields/PrivateRemarks",
176
+ "HasList": false,
177
+ "Searchable": false,
178
+ "Type": "Character"
179
+ },
180
+ "CountyOrParish": {
181
+ "ResourceUri": "/v1/standardfields/CountyOrParish",
182
+ "HasList": false,
183
+ "Searchable": true,
184
+ "Type": "Character"
185
+ }
186
+ }]
187
+ }
188
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "D": {
3
+ "Success": true,
4
+ "Results": [{
5
+ "StateOrProvince": {
6
+ "ResourceUri": "/v1/standardfields/StateOrProvince",
7
+ "FieldList": [{
8
+ "Name": "IA",
9
+ "Applies To": ["A", "B", "G", "I", "J", "K", "M"],
10
+ "Value": "IA"
11
+ },
12
+ {
13
+ "Name": "MN",
14
+ "Value": "MN"
15
+ },
16
+ {
17
+ "Name": "ND",
18
+ "Value": "ND"
19
+ },
20
+ {
21
+ "Name": "SD",
22
+ "Applies To": ["A", "B", "G", "I", "J", "K", "M"],
23
+ "Value": "SD"
24
+ },
25
+ {
26
+ "Name": "WI",
27
+ "Applies To": ["A", "B", "G", "I", "J", "K", "M"],
28
+ "Value": "WI"
29
+ }],
30
+ "HasList": true,
31
+ "Searchable": true,
32
+ "Type": "Character"
33
+ }
34
+ }]
35
+ }
36
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "D": {
3
+ "Success": true
4
+ }
5
+ }
@@ -0,0 +1,76 @@
1
+ class ListingJson
2
+ @counter = 0
3
+ def self.next_tech_id()
4
+ "#{@counter + 20110101000000000000}000000"
5
+ end
6
+ def self.next_list_id()
7
+ "06-#{@counter + 1000}"
8
+ end
9
+ def self.bump()
10
+ @counter += 1
11
+ end
12
+
13
+ def self.create
14
+ bump
15
+ json = <<-JSON
16
+ {
17
+ "ResourceUri": "/v1/listings/#{next_tech_id}",
18
+ "StandardFields": #{standard_fields},
19
+ "Id": "#{next_tech_id}"
20
+ }
21
+ JSON
22
+
23
+ end
24
+
25
+ def self.create_all(count = 1)
26
+ listings = []
27
+ count.times { listings << create }
28
+ json = listings * ","
29
+ end
30
+
31
+ private
32
+ def self.standard_fields
33
+ json = <<-JSON
34
+ {
35
+ "StreetNumber": "7298",
36
+ "Longitude": "-116.3237",
37
+ "City": "Bonners Ferry",
38
+ "ListingId": "#{next_list_id}",
39
+ "PublicRemarks": "Afforadable home in town close to hospital,yet quiet country like setting. Good views. Must see",
40
+ "BuildingAreaTotal": 924.0,
41
+ "YearBuilt": 1977,
42
+ "StreetName": "BIRCH",
43
+ "ListPrice": 50000.0,
44
+ "PostalCode": 83805,
45
+ "Latitude": "48.7001",
46
+ "BathsThreeQuarter": null,
47
+ "BathsFull": 1.0,
48
+ "BathsTotal": 1.0,
49
+ "StateOrProvince": "ID",
50
+ "PropertyType": "A",
51
+ "StreetAdditionalInfo": null,
52
+ "StreetDirPrefix": null,
53
+ "BedsTotal": 3,
54
+ "StreetDirSuffix": null,
55
+ "ListingKey": "#{next_tech_id}",
56
+ "ListOfficeName": "Century 21 On The Lake",
57
+ "BathsHalf": null,
58
+ "ModificationTimestamp": "2010-11-22T20:47:21Z",
59
+ "CountyOrParish": "Boundary"
60
+ }
61
+ JSON
62
+ end
63
+
64
+ end
65
+
66
+ def paginate_json(current_page = 1)
67
+ json = <<-JSON
68
+ "Pagination": {
69
+ "TotalRows": 38,
70
+ "PageSize": 10,
71
+ "TotalPages": 4,
72
+ "CurrentPage": #{current_page}
73
+ }
74
+ JSON
75
+ end
76
+
@@ -0,0 +1,124 @@
1
+ RSpec.configure do |config|
2
+ config.include WebMock::API
3
+ end
4
+
5
+ $test_client = SparkApi::Client.new({:api_key=>"", :api_secret=>""})
6
+ def stub_api_get(service_path, stub_fixture="success.json", opts={})
7
+ params = {:ApiUser => "foobar", :AuthToken => "c401736bf3d3f754f07c04e460e09573"}.merge(opts)
8
+ sig = $test_client.authenticator.sign_token("/#{SparkApi.version}#{service_path}", params)
9
+ s=stub_request(:get, "#{SparkApi.endpoint}/#{SparkApi.version}#{service_path}").
10
+ with(:query => {
11
+ :ApiSig => sig
12
+ }.merge(params))
13
+ if(block_given?)
14
+ yield s
15
+ else
16
+ s.to_return(:body => fixture(stub_fixture))
17
+ end
18
+ log_stub(s)
19
+ end
20
+ def stub_api_delete(service_path, stub_fixture="success.json", opts={})
21
+ params = {:ApiUser => "foobar", :AuthToken => "c401736bf3d3f754f07c04e460e09573"}.merge(opts)
22
+ sig = $test_client.authenticator.sign_token("/#{SparkApi.version}#{service_path}", params)
23
+ s=stub_request(:delete, "#{SparkApi.endpoint}/#{SparkApi.version}#{service_path}").
24
+ with(:query => {
25
+ :ApiSig => sig
26
+ }.merge(params))
27
+ if(block_given?)
28
+ yield s
29
+ else
30
+ s.to_return(:body => fixture(stub_fixture))
31
+ end
32
+ log_stub(s)
33
+ end
34
+ def stub_api_post(service_path, body, stub_fixture="success.json", opts={})
35
+ body_hash = JSON.parse(fixture(body).read)
36
+ body_str = body_hash.to_json
37
+ params = {:ApiUser => "foobar", :AuthToken => "c401736bf3d3f754f07c04e460e09573"}.merge(opts)
38
+ sig = $test_client.authenticator.sign_token("/#{SparkApi.version}#{service_path}", params, body_str)
39
+ s=stub_request(:post, "#{SparkApi.endpoint}/#{SparkApi.version}#{service_path}").
40
+ with(:query => {
41
+ :ApiSig => sig
42
+ }.merge(params),
43
+ :body => body_str
44
+ )
45
+ if(block_given?)
46
+ yield s
47
+ else
48
+ s.to_return(:body => fixture(stub_fixture))
49
+ end
50
+ log_stub(s)
51
+ end
52
+ def stub_api_put(service_path, body, stub_fixture="success.json", opts={})
53
+ body_hash = JSON.parse(fixture(body).read)
54
+ body_str = body_hash.to_json
55
+ params = {:ApiUser => "foobar", :AuthToken => "c401736bf3d3f754f07c04e460e09573"}.merge(opts)
56
+ sig = $test_client.authenticator.sign_token("/#{SparkApi.version}#{service_path}", params, body_str)
57
+ s=stub_request(:put, "#{SparkApi.endpoint}/#{SparkApi.version}#{service_path}").
58
+ with(:query => {
59
+ :ApiSig => sig
60
+ }.merge(params),
61
+ :body => body_str
62
+ )
63
+ if(block_given?)
64
+ yield s
65
+ else
66
+ s.to_return(:body => fixture(stub_fixture))
67
+ end
68
+ log_stub(s)
69
+ end
70
+
71
+ def log_stub(s)
72
+ SparkApi.logger.debug("Stubbed Request: #{s.inspect} \n\n")
73
+ end
74
+
75
+ def mock_session()
76
+ SparkApi::Authentication::Session.new("AuthToken" => "1234", "Expires" => (Time.now + 3600).to_s, "Roles" => "['idx']")
77
+ end
78
+
79
+ def mock_oauth_session()
80
+ SparkApi::Authentication::OAuthSession.new("access_token" => "1234", "expires_in" => 3600, "scope" => nil, "refresh_token"=> "1000refresh")
81
+ end
82
+
83
+ class MockClient < SparkApi::Client
84
+ attr_accessor :connection
85
+ def connection(ssl = false)
86
+ @connection
87
+ end
88
+ end
89
+
90
+ class MockApiAuthenticator < SparkApi::Authentication::ApiAuth
91
+ # Sign a request
92
+ def sign(sig)
93
+ "SignedToken"
94
+ end
95
+ end
96
+
97
+ def mock_client(stubs)
98
+ c = MockClient.new
99
+ c.session = mock_session()
100
+ c.connection = test_connection(stubs)
101
+ c
102
+ end
103
+
104
+ def mock_expired_session()
105
+ SparkApi::Authentication::Session.new("AuthToken" => "1234", "Expires" => (Time.now - 60).to_s, "Roles" => "['idx']")
106
+ end
107
+
108
+ def test_connection(stubs)
109
+ Faraday::Connection.new(nil, {:headers => SparkApi::Client.new.headers}) do |builder|
110
+ builder.adapter :test, stubs
111
+ builder.use SparkApi::FaradayExt::SparkMiddleware
112
+ end
113
+ end
114
+
115
+ def stub_auth_request()
116
+ stub_request(:post, "https://api.sparkapi.com/#{SparkApi.version}/session").
117
+ with(:query => {:ApiKey => "", :ApiSig => "806737984ab19be2fd08ba36030549ac"}).
118
+ to_return(:body => fixture("session.json"))
119
+ end
120
+
121
+ def fixture(file)
122
+ File.new(File.expand_path("../fixtures", __FILE__) + '/' + file)
123
+ end
124
+