lib/nubank_sdk/certificate.rb in nubank_sdk-0.6.1 vs lib/nubank_sdk/certificate.rb in nubank_sdk-0.7.0

- old
+ new

@@ -1,10 +1,13 @@ # frozen_string_literal: true require 'openssl' module NubankSdk + # + # Controller of certifications + # class Certificate FILES_PATH = './certificates/' # # Controller of certifications @@ -51,12 +54,22 @@ # # @param [OpenSSL::PKCS12] p12 # # @return [File] def save(p12) + create_folder + File.open("#{FILES_PATH}#{@cpf}.p12", 'wb') do |file| file.write p12.to_der end + end + + # @!visibility private + # Create certificates folder + # + # @return [File] + def create_folder + Dir.mkdir(FILES_PATH) unless Dir.exist?(FILES_PATH) end # @!visibility private # crypt key and certificate to pkcs12 #