Skip to content

Commit

Permalink
private attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur-santos-foxbit committed Aug 22, 2024
1 parent 6083ac0 commit c9def05
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/lightspark-client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class Client
}
LOGGER_TAG = "LightsparkClient"

attr_reader :client_id, :client_secret, :api_url, :logger

def initialize(client_id:, client_secret:, api_url: DEFAULT_API_URL, logger: nil)
@client_id = client_id
@client_secret = client_secret
Expand All @@ -34,7 +32,7 @@ def request(payload)
log("Payload: #{payload}")

response = Typhoeus.post(
api_url,
@api_url,
body: payload.to_json,
headers: request_headers
)
Expand All @@ -43,7 +41,7 @@ def request(payload)
end

def request_headers
token = Base64.encode64("#{client_id}:#{client_secret}")
token = Base64.encode64("#{@client_id}:#{@client_secret}")

{
"Content-Type" => "application/json",
Expand All @@ -52,9 +50,9 @@ def request_headers
end

def log(message, level = :info)
return unless logger && looger.respond_to?(:tagged) && logger.respond_to?(level)
return unless @logger && looger.respond_to?(:tagged) && @logger.respond_to?(level)

logger.send(:tagged, LOGGER_TAG) { logger.send(level, message) }
@logger.send(:tagged, LOGGER_TAG) { @logger.send(level, message) }
end

def handle_response(response)
Expand Down

0 comments on commit c9def05

Please sign in to comment.