Skip to content

Commit

Permalink
(TNR) Kaoru bump version to 2.1 (#42)
Browse files Browse the repository at this point in the history
* add user-agent with version number to router requests

* bump to 2.1.0.0
  • Loading branch information
KaoruDev authored Jan 13, 2017
1 parent f5f5734 commit 7920897
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/sift/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions lib/sift/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,26 @@ 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

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,
Expand Down
2 changes: 1 addition & 1 deletion lib/sift/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Sift
VERSION = "2.0.0.0"
VERSION = "2.1.0.0"
API_VERSION = "204"
end

0 comments on commit 7920897

Please sign in to comment.