lib/mls.rb in mls-0.12.5 vs lib/mls.rb in mls-0.13.0

- old
+ new

@@ -33,10 +33,11 @@ # MLS.url = "https://mls.42floors.com/API_KEY" def url=(uri) # TODO: testme @url = URI.parse(uri) @api_key = CGI.unescape(@url.user) @host, @port = @url.host, @url.port + @ssl = (url.scheme == 'https') end # Sets the user agent so that MLS can distinguish between multiple users # with the same auth def user_agent=(user_agent) @@ -48,11 +49,14 @@ end # Returns the current connection to the MLS or if connection has been made # it returns a new connection def connection # TODO: testme - @connection ||= Net::HTTP.new(@host, @port) + return @connection if @connection + @connection = Net::HTTP.new(@host, @port) + @connection.use_ssl = @ssl + @connection end # provides the asset host, if asset_host is set then it is returned, # otherwise it queries the MLS for this configuration. def asset_host # TODO: testme @@ -363,15 +367,19 @@ case code when 400 raise MLS::Exception::BadRequest, response.body when 401 raise MLS::Exception::Unauthorized, response.body - when 404, 410 + when 404 raise MLS::Exception::NotFound + when 410 + raise MLS::Exception::Gone when 422 raise MLS::Exception::ApiVersionUnsupported, response.body when 503 raise MLS::Exception::ServiceUnavailable, response.body + when 301 + raise MLS::Exception::MovedPermanently, response.body when 300..599 raise MLS::Exception, code end end