Skip to content

Commit

Permalink
Merge pull request #5 from kin/marco/auth-fixes
Browse files Browse the repository at this point in the history
fix auth pattern
  • Loading branch information
mcortes95 authored Nov 3, 2020
2 parents 034e4b0 + b52a93a commit e3c76e5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/customerio_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ def initialize(message, response)
end
end

def initialize(site_id, secret_key)
@username = site_id
@passwork = secret_key
def initialize(secret_key)
@key = "Bearer #{secret_key}"
@base_url = "https://beta-api.customer.io"
@timeout = 10
end
Expand Down Expand Up @@ -46,7 +45,7 @@ def request(type, path)
session.read_timeout = @timeout

req = request_type(type).new(uri.path)
req.basic_auth @username, @password
req['Authorization'] = @key

session.start do |http|
http.request(req)
Expand All @@ -55,7 +54,7 @@ def request(type, path)

def verify_response(response)
if response.code[0].to_i == 2
response
JSON.parse(response.body)
else
raise InvalidResponse.new("CustomerIO returned an invalid response: #{response.code}", response)
end
Expand Down

0 comments on commit e3c76e5

Please sign in to comment.