lib/nubank_sdk/auth.rb in nubank_sdk-0.6.0 vs lib/nubank_sdk/auth.rb in nubank_sdk-0.6.1
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'securerandom'
module NubankSdk
class Auth
attr_reader :refresh_token, :refresh_before, :access_token
@@ -65,14 +67,13 @@
# Verify communication with the nubank api
#
# @return [File] the certificate file
def exchange_certs(email_code, password)
response = default_connection.post(@gen_certificate_path, payload(password).merge({
- code: email_code,
- 'encrypted-code': @encrypted_code
- })
- )
+ code: email_code,
+ 'encrypted-code': @encrypted_code
+ }))
response_data = Client.get_body(response)
certificate.process_decoded(key, response_data[:certificate])
end
@@ -87,16 +88,16 @@
def parse_authenticate_headers(header_content)
chunks = header_content.split(',')
parsed = {}
chunks.each do |chunk|
- key, value = chunk.split('=')
- key = key.strip().gsub(' ', '_').gsub('-', '_').to_sym
- value = value.gsub('"', '')
- parsed[key] = value
+ key, value = chunk.split('=')
+ key = key.strip.gsub(' ', '_').gsub('-', '_').to_sym
+ value = value.gsub('"', '')
+ parsed[key] = value
end
-
+
parsed
end
# @!visibility private
# Create a payload to generate a new certificate
@@ -108,11 +109,11 @@
{
login: @cpf,
password: password,
public_key: key.public_key.to_pem,
device_id: @device_id,
- model: "NubankSdk Client (#@device_id)",
+ model: "NubankSdk Client (#{@device_id})"
}
end
# @!visibility private
# Create a payload to authenticate with the nubank api
@@ -143,10 +144,10 @@
#
# @param [Hash] links the new links to add
#
# @return [NubankSdk::ApiRoutes] the api routes with the new links
def update_api_routes(links)
- feed_url_keys = [:events, :magnitude]
+ feed_url_keys = %i[events magnitude]
bills_url_keys = [:bills_summary]
customer_url_keys = [:customer]
account_url_keys = [:account]
@api_routes.add_entrypoint(path: :ssl, entrypoint: :revoke_token, url: links[:revoke_token][:href])
@api_routes.add_entrypoint(path: :ssl, entrypoint: :query, url: links[:ghostflame][:href])