diff --git a/lib/sift/client.rb b/lib/sift/client.rb index 7054b2a..2978b8b 100644 --- a/lib/sift/client.rb +++ b/lib/sift/client.rb @@ -92,6 +92,10 @@ def self.build_auth_header(api_key) { "Authorization" => "Basic #{Base64.encode64(api_key)}" } end + def self.user_agent + "sift-ruby/#{VERSION}" + end + # Constructor # # ==== Parameters: diff --git a/lib/sift/router.rb b/lib/sift/router.rb index da826d8..69e4015 100644 --- a/lib/sift/router.rb +++ b/lib/sift/router.rb @@ -8,11 +8,13 @@ class Router class << self def get(path, options = {}) serialize_body(options) + add_default_headers(options) wrap_response(super(path, options)) end def post(path, options = {}) serialize_body(options) + add_default_headers(options) wrap_response(super(path, options)) end @@ -20,6 +22,12 @@ def serialize_body(options) options[:body] = MultiJson.dump(options[:body]) if options[:body] end + def add_default_headers(options) + options[:headers] = { + "User-Agent" => Sift::Client.user_agent + }.merge(options[:headers] || {}) + end + def wrap_response(response) Response.new( response.body, diff --git a/lib/sift/version.rb b/lib/sift/version.rb index b3658ba..4b4a138 100644 --- a/lib/sift/version.rb +++ b/lib/sift/version.rb @@ -1,4 +1,4 @@ module Sift - VERSION = "2.0.0.0" + VERSION = "2.1.0.0" API_VERSION = "204" end