lib/thebigdb/request.rb in thebigdb-1.2.0 vs lib/thebigdb/request.rb in thebigdb-1.2.1
- old
+ new
@@ -20,10 +20,14 @@
# Prepares the @http_request object with the actual content of the request
def prepare(method, request_uri, params = {})
method = method.downcase.to_s
+ if TheBigDB.api_key.is_a?(String) and !TheBigDB.api_key.empty?
+ params.merge!("api_key" => TheBigDB.api_key)
+ end
+
# we add the API version to the URL, with a trailing slash and the rest of the request
request_uri = "/v#{TheBigDB.api_version}" + (request_uri.start_with?("/") ? request_uri : "/#{request_uri}")
if method == "get"
encoded_params = TheBigDB::Helpers::serialize_query_params(params)
@@ -36,13 +40,13 @@
end
@http_request["user-agent"] = "TheBigDB RubyWrapper/#{TheBigDB::VERSION::STRING}"
client_user_agent = {
- :publisher => "thebigdb",
- :version => TheBigDB::VERSION::STRING,
- :language => "ruby",
- :language_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
+ "publisher" => "thebigdb",
+ "version" => TheBigDB::VERSION::STRING,
+ "language" => "ruby",
+ "language_version" => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
}
@http_request["X-TheBigDB-Client-User-Agent"] = JSON(client_user_agent)
self
\ No newline at end of file