lib/nubank_sdk/auth.rb in nubank_sdk-0.7.5 vs lib/nubank_sdk/auth.rb in nubank_sdk-0.7.6

- old
+ new

@@ -24,14 +24,10 @@ @connection_adapter = connection_adapter @p_key = OpenSSL::PKey::RSA.new 2048 @encrypted_code = '' end - def def_encrypted_code=(value) - @encrypted_code = value - end - # # Return the instance of user certificate # # @return [NubankSdk::Certificate] the certificate instance def certificate @@ -73,12 +69,15 @@ # # Verify communication with the nubank api # # @return [File] the certificate file - def exchange_certs(email_code, password) + def exchange_certs(email_code, password, custom_encryption = nil) + device_authorization_encrypted_code = custom_encryption || @encrypted_code || '' + raise Errors::InvalidEncryptedCode if device_authorization_encrypted_code.empty? + new_payload = payload(password) - .merge({ code: email_code, 'encrypted-code': @encrypted_code }) + .merge({ code: email_code, 'encrypted-code': device_authorization_encrypted_code }) response = default_connection.post(@gen_certificate_path, new_payload) response_data = Client.get_body(response) certificate.process_decoded(@p_key, response_data[:certificate]) end