simplyrets 2.0.0 → 2.0.1

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. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -3
  3. data/Makefile +1 -2
  4. data/README.org +2 -0
  5. data/lib/simplyrets.rb +12 -1
  6. data/lib/simplyrets/api/default_api.rb +132 -128
  7. data/lib/simplyrets/api_client.rb +48 -9
  8. data/lib/simplyrets/api_client.rb.orig +373 -0
  9. data/lib/simplyrets/api_error.rb +12 -1
  10. data/lib/simplyrets/configuration.rb +23 -0
  11. data/lib/simplyrets/models/agent.rb +61 -27
  12. data/lib/simplyrets/models/broker.rb +57 -20
  13. data/lib/simplyrets/models/contact_information.rb +62 -27
  14. data/lib/simplyrets/models/error.rb +59 -23
  15. data/lib/simplyrets/models/geographic_data.rb +61 -28
  16. data/lib/simplyrets/models/listing.rb +94 -70
  17. data/lib/simplyrets/models/mls_information.rb +95 -37
  18. data/lib/simplyrets/models/office.rb +62 -28
  19. data/lib/simplyrets/models/open_house.rb +66 -36
  20. data/lib/simplyrets/models/parking.rb +59 -24
  21. data/lib/simplyrets/models/property.rb +128 -136
  22. data/lib/simplyrets/models/sales.rb +61 -28
  23. data/lib/simplyrets/models/school.rb +60 -34
  24. data/lib/simplyrets/models/street_address.rb +66 -55
  25. data/lib/simplyrets/models/tax.rb +70 -35
  26. data/lib/simplyrets/version.rb +13 -2
  27. data/ruby-client.meta +1 -0
  28. data/ruby-client.zip +0 -0
  29. data/ruby-client/.gitignore +50 -0
  30. data/ruby-client/.rspec +2 -0
  31. data/ruby-client/.swagger-codegen-ignore +23 -0
  32. data/ruby-client/LICENSE +201 -0
  33. data/ruby-client/README.md +128 -0
  34. data/ruby-client/docs/Agent.md +11 -0
  35. data/ruby-client/docs/Broker.md +8 -0
  36. data/ruby-client/docs/ContactInformation.md +10 -0
  37. data/ruby-client/docs/DefaultApi.md +306 -0
  38. data/ruby-client/docs/Error.md +9 -0
  39. data/ruby-client/docs/GeographicData.md +12 -0
  40. data/ruby-client/docs/Listing.md +30 -0
  41. data/ruby-client/docs/MlsInformation.md +11 -0
  42. data/ruby-client/docs/Office.md +11 -0
  43. data/ruby-client/docs/OpenHouse.md +15 -0
  44. data/ruby-client/docs/Parking.md +10 -0
  45. data/ruby-client/docs/Property.md +43 -0
  46. data/ruby-client/docs/Sales.md +12 -0
  47. data/ruby-client/docs/School.md +11 -0
  48. data/ruby-client/docs/StreetAddress.md +16 -0
  49. data/ruby-client/docs/Tax.md +10 -0
  50. data/ruby-client/git_push.sh +67 -0
  51. data/ruby-client/lib/swagger_client.rb +66 -0
  52. data/ruby-client/lib/swagger_client/api/default_api.rb +383 -0
  53. data/ruby-client/lib/swagger_client/api_client.rb +373 -0
  54. data/ruby-client/lib/swagger_client/api_error.rb +47 -0
  55. data/ruby-client/lib/swagger_client/configuration.rb +193 -0
  56. data/ruby-client/lib/swagger_client/models/agent.rb +230 -0
  57. data/ruby-client/lib/swagger_client/models/broker.rb +200 -0
  58. data/ruby-client/lib/swagger_client/models/contact_information.rb +220 -0
  59. data/ruby-client/lib/swagger_client/models/error.rb +210 -0
  60. data/ruby-client/lib/swagger_client/models/geographic_data.rb +240 -0
  61. data/ruby-client/lib/swagger_client/models/listing.rb +422 -0
  62. data/ruby-client/lib/swagger_client/models/mls_information.rb +263 -0
  63. data/ruby-client/lib/swagger_client/models/office.rb +230 -0
  64. data/ruby-client/lib/swagger_client/models/open_house.rb +270 -0
  65. data/ruby-client/lib/swagger_client/models/parking.rb +219 -0
  66. data/ruby-client/lib/swagger_client/models/property.rb +574 -0
  67. data/ruby-client/lib/swagger_client/models/sales.rb +240 -0
  68. data/ruby-client/lib/swagger_client/models/school.rb +230 -0
  69. data/ruby-client/lib/swagger_client/models/street_address.rb +280 -0
  70. data/ruby-client/lib/swagger_client/models/tax.rb +220 -0
  71. data/ruby-client/lib/swagger_client/version.rb +26 -0
  72. data/ruby-client/spec/api/default_api_spec.rb +132 -0
  73. data/ruby-client/spec/api_client_spec.rb +296 -0
  74. data/ruby-client/spec/configuration_spec.rb +48 -0
  75. data/ruby-client/spec/models/agent_spec.rb +71 -0
  76. data/ruby-client/spec/models/broker_spec.rb +53 -0
  77. data/ruby-client/spec/models/contact_information_spec.rb +65 -0
  78. data/ruby-client/spec/models/error_spec.rb +59 -0
  79. data/ruby-client/spec/models/geographic_data_spec.rb +77 -0
  80. data/ruby-client/spec/models/listing_spec.rb +185 -0
  81. data/ruby-client/spec/models/mls_information_spec.rb +74 -0
  82. data/ruby-client/spec/models/office_spec.rb +71 -0
  83. data/ruby-client/spec/models/open_house_spec.rb +95 -0
  84. data/ruby-client/spec/models/parking_spec.rb +65 -0
  85. data/ruby-client/spec/models/property_spec.rb +266 -0
  86. data/ruby-client/spec/models/sales_spec.rb +77 -0
  87. data/ruby-client/spec/models/school_spec.rb +71 -0
  88. data/ruby-client/spec/models/street_address_spec.rb +101 -0
  89. data/ruby-client/spec/models/tax_spec.rb +65 -0
  90. data/ruby-client/spec/spec_helper.rb +122 -0
  91. data/ruby-client/swagger_client.gemspec +55 -0
  92. data/simplyrets.gemspec +1 -1
  93. metadata +71 -5
@@ -0,0 +1,373 @@
1
+ =begin
2
+ SimplyRETS API
3
+
4
+ The SimplyRETS API is an exciting step towards making it easier for developers and real estate agents to build something awesome with real estate data! The documentation below makes live requests to our API using the trial data. To get set up with the API using live MLS data, you must have RETS credentials from your MLS, which you can then use to create an app with SimplyRETS. For more information on that process, please see our [FAQ](https://simplyrets.com/faq), [Getting Started](https://simplyrets.com/blog/getting-set-up.html) page, or [contact us](https://simplyrets.com/\\#home-contact). Below you'll find the API endpoints, query parameters, response bodies, and other information about using the SimplyRETS API. You can run queries by clicking the 'Try it Out' button at the bottom of each section. ### Authentication The SimplyRETS API uses Basic Authentication. When you create an app, you'll get a set of API credentials to access your listings. If you're trying out the test data, you can use `simplyrets:simplyrets` for connecting to the API. ### Media Types The SimplyRETS API uses the `Accept` header to allow clients to control media types (content versions). We maintain backwards compatibility with API clients by allowing them to specify a content version. We highly recommend setting and explicity media type when your application reaches production. Both the structure and content of our API response bodies is subject to change so we can add new features while respecting the stability of applications which have already been developed. To always use the latest SimplyRETS content version, simply use `application/json` in your application `Accept` header. If you want to pin your clients media type to a specific version, you can use the vendor-specific SimplyRETS media type, e.g. `application/vnd.simplyrets-v0.1+json\"` To view all valid content-types for making an `OPTIONS`, make a request to the SimplyRETS api root `curl -XOPTIONS -u simplyrets:simplyrets https://api.simplyrets.com/` The default media types used in our API responses may change in the future. If you're building an application and care about the stability of the API, be sure to request a specific media type in the Accept header as shown in the examples below. The wordpress plugin automatically sets the `Accept` header for the compatible SimplyRETS media types. ### Pagination There a few pieces of useful information about each request stored in the HTTP Headers: - `X-Total-Count` shows you the total amount of listings that match your current query. - `Link` contains pre-built pagination links for accessing the next 'page' of listings that match your query. Read more about that [here](https://simplyrets.com/blog/api-pagination.html).
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+ require 'json'
26
+ require 'logger'
27
+ require 'tempfile'
28
+ require 'typhoeus'
29
+ require 'uri'
30
+
31
+ module SwaggerClient
32
+ class ApiClient
33
+ # The Configuration object holding settings to be used in the API client.
34
+ attr_accessor :config
35
+
36
+ # Defines the headers to be used in HTTP requests of all API calls by default.
37
+ #
38
+ # @return [Hash]
39
+ attr_accessor :default_headers
40
+
41
+ # Initializes the ApiClient
42
+ # @option config [Configuration] Configuraiton for initializing the object, default to Configuration.default
43
+ def initialize(config = Configuration.default)
44
+ @config = config
45
+ @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
46
+ @default_headers = {
47
+ 'Content-Type' => "application/json",
48
+ 'User-Agent' => @user_agent
49
+ }
50
+ end
51
+
52
+ def self.default
53
+ @@default ||= ApiClient.new
54
+ end
55
+
56
+ # Call an API with given options.
57
+ #
58
+ # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
59
+ # the data deserialized from response body (could be nil), response status code and response headers.
60
+ def call_api(http_method, path, opts = {})
61
+ request = build_request(http_method, path, opts)
62
+ response = request.run
63
+
64
+ if @config.debugging
65
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
66
+ end
67
+
68
+ unless response.success?
69
+ fail ApiError.new(:code => response.code,
70
+ :response_headers => response.headers,
71
+ :response_body => response.body),
72
+ response.status_message
73
+ end
74
+
75
+ if opts[:return_type]
76
+ data = deserialize(response, opts[:return_type])
77
+ else
78
+ data = nil
79
+ end
80
+ return data, response.code, response.headers
81
+ end
82
+
83
+ # Builds the HTTP request
84
+ #
85
+ # @param [String] http_method HTTP method/verb (e.g. POST)
86
+ # @param [String] path URL path (e.g. /account/new)
87
+ # @option opts [Hash] :header_params Header parameters
88
+ # @option opts [Hash] :query_params Query parameters
89
+ # @option opts [Hash] :form_params Query parameters
90
+ # @option opts [Object] :body HTTP body (JSON/XML)
91
+ # @return [Typhoeus::Request] A Typhoeus Request
92
+ def build_request(http_method, path, opts = {})
93
+ url = build_request_url(path)
94
+ http_method = http_method.to_sym.downcase
95
+
96
+ header_params = @default_headers.merge(opts[:header_params] || {})
97
+ query_params = opts[:query_params] || {}
98
+ form_params = opts[:form_params] || {}
99
+
100
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
101
+
102
+ req_opts = {
103
+ :method => http_method,
104
+ :headers => header_params,
105
+ :params => query_params,
106
+ :timeout => @config.timeout,
107
+ :ssl_verifypeer => @config.verify_ssl,
108
+ :sslcert => @config.cert_file,
109
+ :sslkey => @config.key_file,
110
+ :verbose => @config.debugging
111
+ }
112
+
113
+ req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
114
+
115
+ if [:post, :patch, :put, :delete].include?(http_method)
116
+ req_body = build_request_body(header_params, form_params, opts[:body])
117
+ req_opts.update :body => req_body
118
+ if @config.debugging
119
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
120
+ end
121
+ end
122
+
123
+ Typhoeus::Request.new(url, req_opts)
124
+ end
125
+
126
+ # Check if the given MIME is a JSON MIME.
127
+ # JSON MIME examples:
128
+ # application/json
129
+ # application/json; charset=UTF8
130
+ # APPLICATION/JSON
131
+ # @param [String] mime MIME
132
+ # @return [Boolean] True if the MIME is applicaton/json
133
+ def json_mime?(mime)
134
+ !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
135
+ end
136
+
137
+ # Deserialize the response to the given return type.
138
+ #
139
+ # @param [Response] response HTTP response
140
+ # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
141
+ def deserialize(response, return_type)
142
+ body = response.body
143
+ return nil if body.nil? || body.empty?
144
+
145
+ # return response body directly for String return type
146
+ return body if return_type == 'String'
147
+
148
+ # handle file downloading - save response body into a tmp file and return the File instance
149
+ return download_file(response) if return_type == 'File'
150
+
151
+ # ensuring a default content type
152
+ content_type = response.headers['Content-Type'] || 'application/json'
153
+
154
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
155
+
156
+ begin
157
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
158
+ rescue JSON::ParserError => e
159
+ if %w(String Date DateTime).include?(return_type)
160
+ data = body
161
+ else
162
+ raise e
163
+ end
164
+ end
165
+
166
+ convert_to_type data, return_type
167
+ end
168
+
169
+ # Convert data to the given return type.
170
+ # @param [Object] data Data to be converted
171
+ # @param [String] return_type Return type
172
+ # @return [Mixed] Data in a particular type
173
+ def convert_to_type(data, return_type)
174
+ return nil if data.nil?
175
+ case return_type
176
+ when 'String'
177
+ data.to_s
178
+ when 'Integer'
179
+ data.to_i
180
+ when 'Float'
181
+ data.to_f
182
+ when 'BOOLEAN'
183
+ data == true
184
+ when 'DateTime'
185
+ # parse date time (expecting ISO 8601 format)
186
+ DateTime.parse data
187
+ when 'Date'
188
+ # parse date time (expecting ISO 8601 format)
189
+ Date.parse data
190
+ when 'Object'
191
+ # generic object (usually a Hash), return directly
192
+ data
193
+ when /\AArray<(.+)>\z/
194
+ # e.g. Array<Pet>
195
+ sub_type = $1
196
+ data.map {|item| convert_to_type(item, sub_type) }
197
+ when /\AHash\<String, (.+)\>\z/
198
+ # e.g. Hash<String, Integer>
199
+ sub_type = $1
200
+ {}.tap do |hash|
201
+ data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
202
+ end
203
+ else
204
+ # models, e.g. Pet
205
+ SwaggerClient.const_get(return_type).new.tap do |model|
206
+ model.build_from_hash data
207
+ end
208
+ end
209
+ end
210
+
211
+ # Save response body into a file in (the defined) temporary folder, using the filename
212
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
213
+ #
214
+ # @see Configuration#temp_folder_path
215
+ # @return [Tempfile] the file downloaded
216
+ def download_file(response)
217
+ content_disposition = response.headers['Content-Disposition']
218
+ if content_disposition
219
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
220
+ prefix = sanitize_filename(filename)
221
+ else
222
+ prefix = 'download-'
223
+ end
224
+ prefix = prefix + '-' unless prefix.end_with?('-')
225
+
226
+ tempfile = nil
227
+ encoding = response.body.encoding
228
+ Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file|
229
+ file.write(response.body)
230
+ tempfile = file
231
+ end
232
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
233
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
234
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
235
+ "explicitly with `tempfile.delete`"
236
+ tempfile
237
+ end
238
+
239
+ # Sanitize filename by removing path.
240
+ # e.g. ../../sun.gif becomes sun.gif
241
+ #
242
+ # @param [String] filename the filename to be sanitized
243
+ # @return [String] the sanitized filename
244
+ def sanitize_filename(filename)
245
+ filename.gsub(/.*[\/\\]/, '')
246
+ end
247
+
248
+ def build_request_url(path)
249
+ # Add leading and trailing slashes to path
250
+ path = "/#{path}".gsub(/\/+/, '/')
251
+ URI.encode(@config.base_url + path)
252
+ end
253
+
254
+ # Builds the HTTP request body
255
+ #
256
+ # @param [Hash] header_params Header parameters
257
+ # @param [Hash] form_params Query parameters
258
+ # @param [Object] body HTTP body (JSON/XML)
259
+ # @return [String] HTTP body data in the form of string
260
+ def build_request_body(header_params, form_params, body)
261
+ # http form
262
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
263
+ header_params['Content-Type'] == 'multipart/form-data'
264
+ data = {}
265
+ form_params.each do |key, value|
266
+ case value
267
+ when File, Array, nil
268
+ # let typhoeus handle File, Array and nil parameters
269
+ data[key] = value
270
+ else
271
+ data[key] = value.to_s
272
+ end
273
+ end
274
+ elsif body
275
+ data = body.is_a?(String) ? body : body.to_json
276
+ else
277
+ data = nil
278
+ end
279
+ data
280
+ end
281
+
282
+ # Update hearder and query params based on authentication settings.
283
+ #
284
+ # @param [Hash] header_params Header parameters
285
+ # @param [Hash] form_params Query parameters
286
+ # @param [String] auth_names Authentication scheme name
287
+ def update_params_for_auth!(header_params, query_params, auth_names)
288
+ Array(auth_names).each do |auth_name|
289
+ auth_setting = @config.auth_settings[auth_name]
290
+ next unless auth_setting
291
+ case auth_setting[:in]
292
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
293
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
294
+ else fail ArgumentError, 'Authentication token must be in `query` of `header`'
295
+ end
296
+ end
297
+ end
298
+
299
+ # Sets user agent in HTTP header
300
+ #
301
+ # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
302
+ def user_agent=(user_agent)
303
+ @user_agent = user_agent
304
+ @default_headers['User-Agent'] = @user_agent
305
+ end
306
+
307
+ # Return Accept header based on an array of accepts provided.
308
+ # @param [Array] accepts array for Accept
309
+ # @return [String] the Accept header (e.g. application/json)
310
+ def select_header_accept(accepts)
311
+ return nil if accepts.nil? || accepts.empty?
312
+ # use JSON when present, otherwise use all of the provided
313
+ json_accept = accepts.find { |s| json_mime?(s) }
314
+ return json_accept || accepts.join(',')
315
+ end
316
+
317
+ # Return Content-Type header based on an array of content types provided.
318
+ # @param [Array] content_types array for Content-Type
319
+ # @return [String] the Content-Type header (e.g. application/json)
320
+ def select_header_content_type(content_types)
321
+ # use application/json by default
322
+ return 'application/json' if content_types.nil? || content_types.empty?
323
+ # use JSON when present, otherwise use the first one
324
+ json_content_type = content_types.find { |s| json_mime?(s) }
325
+ return json_content_type || content_types.first
326
+ end
327
+
328
+ # Convert object (array, hash, object, etc) to JSON string.
329
+ # @param [Object] model object to be converted into JSON string
330
+ # @return [String] JSON string representation of the object
331
+ def object_to_http_body(model)
332
+ return model if model.nil? || model.is_a?(String)
333
+ local_body = nil
334
+ if model.is_a?(Array)
335
+ local_body = model.map{|m| object_to_hash(m) }
336
+ else
337
+ local_body = object_to_hash(model)
338
+ end
339
+ local_body.to_json
340
+ end
341
+
342
+ # Convert object(non-array) to hash.
343
+ # @param [Object] obj object to be converted into JSON string
344
+ # @return [String] JSON string representation of the object
345
+ def object_to_hash(obj)
346
+ if obj.respond_to?(:to_hash)
347
+ obj.to_hash
348
+ else
349
+ obj
350
+ end
351
+ end
352
+
353
+ # Build parameter value according to the given collection format.
354
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
355
+ def build_collection_param(param, collection_format)
356
+ case collection_format
357
+ when :csv
358
+ param.join(',')
359
+ when :ssv
360
+ param.join(' ')
361
+ when :tsv
362
+ param.join("\t")
363
+ when :pipes
364
+ param.join('|')
365
+ when :multi
366
+ # return the array directly as typhoeus will handle it as expected
367
+ param
368
+ else
369
+ fail "unknown collection format: #{collection_format.inspect}"
370
+ end
371
+ end
372
+ end
373
+ end
@@ -0,0 +1,47 @@
1
+ =begin
2
+ SimplyRETS API
3
+
4
+ The SimplyRETS API is an exciting step towards making it easier for developers and real estate agents to build something awesome with real estate data! The documentation below makes live requests to our API using the trial data. To get set up with the API using live MLS data, you must have RETS credentials from your MLS, which you can then use to create an app with SimplyRETS. For more information on that process, please see our [FAQ](https://simplyrets.com/faq), [Getting Started](https://simplyrets.com/blog/getting-set-up.html) page, or [contact us](https://simplyrets.com/\\#home-contact). Below you'll find the API endpoints, query parameters, response bodies, and other information about using the SimplyRETS API. You can run queries by clicking the 'Try it Out' button at the bottom of each section. ### Authentication The SimplyRETS API uses Basic Authentication. When you create an app, you'll get a set of API credentials to access your listings. If you're trying out the test data, you can use `simplyrets:simplyrets` for connecting to the API. ### Media Types The SimplyRETS API uses the `Accept` header to allow clients to control media types (content versions). We maintain backwards compatibility with API clients by allowing them to specify a content version. We highly recommend setting and explicity media type when your application reaches production. Both the structure and content of our API response bodies is subject to change so we can add new features while respecting the stability of applications which have already been developed. To always use the latest SimplyRETS content version, simply use `application/json` in your application `Accept` header. If you want to pin your clients media type to a specific version, you can use the vendor-specific SimplyRETS media type, e.g. `application/vnd.simplyrets-v0.1+json\"` To view all valid content-types for making an `OPTIONS`, make a request to the SimplyRETS api root `curl -XOPTIONS -u simplyrets:simplyrets https://api.simplyrets.com/` The default media types used in our API responses may change in the future. If you're building an application and care about the stability of the API, be sure to request a specific media type in the Accept header as shown in the examples below. The wordpress plugin automatically sets the `Accept` header for the compatible SimplyRETS media types. ### Pagination There a few pieces of useful information about each request stored in the HTTP Headers: - `X-Total-Count` shows you the total amount of listings that match your current query. - `Link` contains pre-built pagination links for accessing the next 'page' of listings that match your query. Read more about that [here](https://simplyrets.com/blog/api-pagination.html).
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ module SwaggerClient
25
+ class ApiError < StandardError
26
+ attr_reader :code, :response_headers, :response_body
27
+
28
+ # Usage examples:
29
+ # ApiError.new
30
+ # ApiError.new("message")
31
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
32
+ # ApiError.new(:code => 404, :message => "Not Found")
33
+ def initialize(arg = nil)
34
+ if arg.is_a? Hash
35
+ arg.each do |k, v|
36
+ if k.to_s == 'message'
37
+ super v
38
+ else
39
+ instance_variable_set "@#{k}", v
40
+ end
41
+ end
42
+ else
43
+ super arg
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,193 @@
1
+ =begin
2
+ SimplyRETS API
3
+
4
+ The SimplyRETS API is an exciting step towards making it easier for developers and real estate agents to build something awesome with real estate data! The documentation below makes live requests to our API using the trial data. To get set up with the API using live MLS data, you must have RETS credentials from your MLS, which you can then use to create an app with SimplyRETS. For more information on that process, please see our [FAQ](https://simplyrets.com/faq), [Getting Started](https://simplyrets.com/blog/getting-set-up.html) page, or [contact us](https://simplyrets.com/\\#home-contact). Below you'll find the API endpoints, query parameters, response bodies, and other information about using the SimplyRETS API. You can run queries by clicking the 'Try it Out' button at the bottom of each section. ### Authentication The SimplyRETS API uses Basic Authentication. When you create an app, you'll get a set of API credentials to access your listings. If you're trying out the test data, you can use `simplyrets:simplyrets` for connecting to the API. ### Media Types The SimplyRETS API uses the `Accept` header to allow clients to control media types (content versions). We maintain backwards compatibility with API clients by allowing them to specify a content version. We highly recommend setting and explicity media type when your application reaches production. Both the structure and content of our API response bodies is subject to change so we can add new features while respecting the stability of applications which have already been developed. To always use the latest SimplyRETS content version, simply use `application/json` in your application `Accept` header. If you want to pin your clients media type to a specific version, you can use the vendor-specific SimplyRETS media type, e.g. `application/vnd.simplyrets-v0.1+json\"` To view all valid content-types for making an `OPTIONS`, make a request to the SimplyRETS api root `curl -XOPTIONS -u simplyrets:simplyrets https://api.simplyrets.com/` The default media types used in our API responses may change in the future. If you're building an application and care about the stability of the API, be sure to request a specific media type in the Accept header as shown in the examples below. The wordpress plugin automatically sets the `Accept` header for the compatible SimplyRETS media types. ### Pagination There a few pieces of useful information about each request stored in the HTTP Headers: - `X-Total-Count` shows you the total amount of listings that match your current query. - `Link` contains pre-built pagination links for accessing the next 'page' of listings that match your query. Read more about that [here](https://simplyrets.com/blog/api-pagination.html).
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'uri'
25
+
26
+ module SwaggerClient
27
+ class Configuration
28
+ # Defines url scheme
29
+ attr_accessor :scheme
30
+
31
+ # Defines url host
32
+ attr_accessor :host
33
+
34
+ # Defines url base path
35
+ attr_accessor :base_path
36
+
37
+ # Defines API keys used with API Key authentications.
38
+ #
39
+ # @return [Hash] key: parameter name, value: parameter value (API key)
40
+ #
41
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
42
+ # config.api_key['api_key'] = 'xxx'
43
+ attr_accessor :api_key
44
+
45
+ # Defines API key prefixes used with API Key authentications.
46
+ #
47
+ # @return [Hash] key: parameter name, value: API key prefix
48
+ #
49
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
50
+ # config.api_key_prefix['api_key'] = 'Token'
51
+ attr_accessor :api_key_prefix
52
+
53
+ # Defines the username used with HTTP basic authentication.
54
+ #
55
+ # @return [String]
56
+ attr_accessor :username
57
+
58
+ # Defines the password used with HTTP basic authentication.
59
+ #
60
+ # @return [String]
61
+ attr_accessor :password
62
+
63
+ # Defines the access token (Bearer) used with OAuth2.
64
+ attr_accessor :access_token
65
+
66
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
67
+ # details will be logged with `logger.debug` (see the `logger` attribute).
68
+ # Default to false.
69
+ #
70
+ # @return [true, false]
71
+ attr_accessor :debugging
72
+
73
+ # Defines the logger used for debugging.
74
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
75
+ #
76
+ # @return [#debug]
77
+ attr_accessor :logger
78
+
79
+ # Defines the temporary folder to store downloaded files
80
+ # (for API endpoints that have file response).
81
+ # Default to use `Tempfile`.
82
+ #
83
+ # @return [String]
84
+ attr_accessor :temp_folder_path
85
+
86
+ # The time limit for HTTP request in seconds.
87
+ # Default to 0 (never times out).
88
+ attr_accessor :timeout
89
+
90
+ ### TLS/SSL
91
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
92
+ # Default to true.
93
+ #
94
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
95
+ #
96
+ # @return [true, false]
97
+ attr_accessor :verify_ssl
98
+
99
+ # Set this to customize the certificate file to verify the peer.
100
+ #
101
+ # @return [String] the path to the certificate file
102
+ #
103
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
104
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
105
+ attr_accessor :ssl_ca_cert
106
+
107
+ # Client certificate file (for client certificate)
108
+ attr_accessor :cert_file
109
+
110
+ # Client private key file (for client certificate)
111
+ attr_accessor :key_file
112
+
113
+ attr_accessor :inject_format
114
+
115
+ attr_accessor :force_ending_format
116
+
117
+ def initialize
118
+ @scheme = 'https'
119
+ @host = 'api.simplyrets.com'
120
+ @base_path = '/'
121
+ @api_key = {}
122
+ @api_key_prefix = {}
123
+ @timeout = 0
124
+ @verify_ssl = true
125
+ @cert_file = nil
126
+ @key_file = nil
127
+ @debugging = false
128
+ @inject_format = false
129
+ @force_ending_format = false
130
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
131
+
132
+ yield(self) if block_given?
133
+ end
134
+
135
+ # The default Configuration object.
136
+ def self.default
137
+ @@default ||= Configuration.new
138
+ end
139
+
140
+ def configure
141
+ yield(self) if block_given?
142
+ end
143
+
144
+ def scheme=(scheme)
145
+ # remove :// from scheme
146
+ @scheme = scheme.sub(/:\/\//, '')
147
+ end
148
+
149
+ def host=(host)
150
+ # remove http(s):// and anything after a slash
151
+ @host = host.sub(/https?:\/\//, '').split('/').first
152
+ end
153
+
154
+ def base_path=(base_path)
155
+ # Add leading and trailing slashes to base_path
156
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
157
+ @base_path = "" if @base_path == "/"
158
+ end
159
+
160
+ def base_url
161
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
162
+ URI.encode(url)
163
+ end
164
+
165
+ # Gets API key (with prefix if set).
166
+ # @param [String] param_name the parameter name of API key auth
167
+ def api_key_with_prefix(param_name)
168
+ if @api_key_prefix[param_name]
169
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
170
+ else
171
+ @api_key[param_name]
172
+ end
173
+ end
174
+
175
+ # Gets Basic Auth token string
176
+ def basic_auth_token
177
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
178
+ end
179
+
180
+ # Returns Auth Settings hash for api client.
181
+ def auth_settings
182
+ {
183
+ 'basicAuth' =>
184
+ {
185
+ type: 'basic',
186
+ in: 'header',
187
+ key: 'Authorization',
188
+ value: basic_auth_token
189
+ },
190
+ }
191
+ end
192
+ end
193
+ end