class Object
Public Instance Methods
create_api_client()
click to toggle source
# File tests/spec/unit_tests_using_jwt_spec.rb, line 55 def create_api_client if $api_client.nil? self.login() end return $api_client end
create_envelope_on_document(status, is_embedded_signing)
click to toggle source
# File tests/spec/unit_tests_using_jwt_spec.rb, line 63 def create_envelope_on_document(status, is_embedded_signing) if (!$account_id.nil?) # STEP 2: Create envelope definition # Add a document to the envelope document_path = "../docs/Test.pdf" document_name = "Test.docx" document = DocuSign_eSign::Document.new document.document_base64 = Base64.encode64(File.open(document_path).read) document.name = document_name document.document_id = '1' # Create a |SignHere| tab somewhere on the document for the recipient to sign signHere = DocuSign_eSign::SignHere.new signHere.x_position = "100" signHere.y_position = "100" signHere.document_id = "1" signHere.page_number = "1" signHere.recipient_id = "1" tabs = DocuSign_eSign::Tabs.new tabs.sign_here_tabs = Array(signHere) signer = DocuSign_eSign::Signer.new signer.email = ENV["RECIPIENT_EMAIL"] signer.name = $recipient_name signer.recipient_id = "1" if (is_embedded_signing) signer.client_user_id = $client_user_id end signer.tabs = tabs # Add a recipient to sign the document recipients = DocuSign_eSign::Recipients.new recipients.signers = Array(signer) envelop_definition = DocuSign_eSign::EnvelopeDefinition.new envelop_definition.email_subject = "[DocuSign Ruby SDK] - Please sign this doc" # set envelope status to "sent" to immediately send the signature request envelop_definition.status = status.nil? ? 'sent' : status envelop_definition.recipients = recipients envelop_definition.documents = Array(document) options = DocuSign_eSign::CreateEnvelopeOptions.new # STEP 3: Create envelope api_client = create_api_client() envelopes_api = DocuSign_eSign::EnvelopesApi.new(api_client) return envelopes_api.create_envelope($account_id, envelop_definition, options) end end
login()
click to toggle source
# File tests/spec/unit_tests_using_jwt_spec.rb, line 7 def login begin if $api_client.nil? configuration = DocuSign_eSign::Configuration.new configuration.host = $host $api_client = DocuSign_eSign::ApiClient.new(configuration) $api_client.set_oauth_base_path(DocuSign_eSign::OAuth::DEMO_OAUTH_BASE_PATH) # IMPORTANT NOTE: # the first time you ask for a JWT access token, you should grant access by making the following call # visit DocuSign OAuth authorization url in the browser, login, grant access and restart the tests # url = $api_client.get_authorization_uri($integrator_key,%w[signature organization_read impersonation],$return_url,'code') # Launchy.open(url) # abort "Please restart the tests" # END OF NOTE end decode_base64_content = Base64.decode64(ENV["PRIVATE_KEY"]) File.open($private_key_filename, "wb") do |f| f.write(decode_base64_content) end token_obj = $api_client.request_jwt_user_token(ENV["INTEGRATOR_KEY_JWT"], ENV["USER_ID"], File.read($private_key_filename), $expires_in_seconds) user_info = $api_client.get_user_info(token_obj.access_token) if !user_info.nil? user_info.accounts.each do |account| if account.is_default == "true" $base_uri = account.base_uri $account_id = account.account_id # IMPORTANT: Use the base url from the login account to instantiant the api_client base_uri = URI.parse($base_uri) $api_client.set_base_path("%s://%s/restapi" % [base_uri.scheme, base_uri.host]) return account end end end rescue => e puts "Error during processing: #{$!}" end return nil end