lib/mls.rb in mls-0.2.29 vs lib/mls.rb in mls-0.2.31
- old
+ new
@@ -21,11 +21,11 @@
class MLS
include Singleton
API_VERSION = '0.1.0'
- attr_reader :url
+ attr_reader :url, :user_agent
attr_writer :asset_host, :listing_amenities, :address_amenities
attr_accessor :api_key, :auth_key, :logger
# Sets the API Token and Host of the MLS Server
#
@@ -34,10 +34,16 @@
def url=(uri) # TODO: testme
@url = URI.parse(uri)
@api_key = CGI.unescape(@url.user)
@host, @port = @url.host, @url.port
end
+
+ # Sets the user agent so that MLS can distinguish between multiple users
+ # with the same auth
+ def user_agent=(user_agent)
+ @user_agent = user_agent
+ end
def logger # TODO: testme
@logger ||= default_logger
end
@@ -64,9 +70,10 @@
end
def headers # TODO: testme
h = {
'Content-Type' => 'application/json',
+ 'User-Agent' => @user_agent,
'X-42Floors-API-Version' => API_VERSION,
'X-42Floors-API-Key' => api_key
}
h['X-42Floors-API-Auth-Key'] = auth_key if auth_key
h