From 7920897d759744136e6512cb09cc7ce05d2452ab Mon Sep 17 00:00:00 2001 From: Kaoru Kohashigawa Date: Thu, 12 Jan 2017 17:17:11 -0800 Subject: [PATCH] (TNR) Kaoru bump version to 2.1 (#42) * add user-agent with version number to router requests * bump to 2.1.0.0 --- lib/sift/client.rb | 4 ++++ lib/sift/router.rb | 8 ++++++++ lib/sift/version.rb | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) 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