def create_envelope_from_document(options={})
      ios = create_file_ios(options[:files])
      file_params = create_file_params(ios)
      recipients = if options[:certified_deliveries].nil? || options[:certified_deliveries].empty?
                     { signers: get_signers(options[:signers]) }
                   else
                     { certifiedDeliveries: get_signers(options[:certified_deliveries]) }
                   end


      post_hash = {
        emailBlurb:   "#{options[:email][:body] if options[:email]}",
        emailSubject: "#{options[:email][:subject] if options[:email]}",
        emailSettings: get_email_settings(options[:email_settings]),
        documents: get_documents(ios),
        recipients: {
          signers: get_signers(options[:signers]),
          carbonCopies: get_carbon_copies(options[:carbon_copies],options[:signers].size)
        },
        eventNotification: get_event_notification(options[:event_notification]),
        status: "#{options[:status]}",
        customFields: options[:custom_fields]
      }
      post_hash[:enableWetSign] = options[:wet_sign] if options.has_key? :wet_sign
      post_body = post_hash.to_json

      uri = build_uri("/accounts/#{acct_id}/envelopes")

      http = initialize_net_http_ssl(uri)

      request = initialize_net_http_multipart_post_request(
                  uri, post_body, file_params, headers(options[:headers])
                )

      response = http.request(request)
      generate_log(request, response, uri)
      JSON.parse(response.body)
    end
def create_envelope_from_document(options={})
      ios = create_file_ios(options[:files])
      file_params = create_file_params(ios)
      recipients = if options[:certified_deliveries].nil? || options[:certified_deliveries].empty?
                     { signers: get_signers(options[:signers]) }
                   else
                     { certifiedDeliveries: get_signers(options[:certified_deliveries]) }
                   end


      post_hash = {
        emailBlurb:   "#{options[:email][:body] if options[:email]}",
        emailSubject: "#{options[:email][:subject] if options[:email]}",
        emailSettings: get_email_settings(options[:email_settings]),
        documents: get_documents(ios),
        recipients: {
          signers: get_signers(options[:signers]),
          carbonCopies: get_carbon_copies(options[:carbon_copies],options[:signers].size)
        },
        eventNotification: get_event_notification(options[:event_notification]),
        status: "#{options[:status]}",
        customFields: options[:custom_fields]
      }
      post_hash[:enableWetSign] = options[:wet_sign] if options.has_key? :wet_sign
      post_body = post_hash.to_json

      uri = build_uri("/accounts/#{acct_id}/envelopes")

      http = initialize_net_http_ssl(uri)

      request = initialize_net_http_multipart_post_request(
                  uri, post_body, file_params, headers(options[:headers])
                )

      response = http.request(request)
      generate_log(request, response, uri)
      JSON.parse(response.body)
    end
Public: creates an envelope from a document directly without a template

 file_io       - Optional: an opened file stream of data (if you don't
                 want to save the file to the file system as an incremental
                 step)
 file_path     - Required if you don't provide a file_io stream, this is
                 the local path of the file you wish to upload. Absolute
                 paths recommended.
 file_name     - The name you want to give to the file you are uploading
 content_type  - (for the request body) application/json is what DocuSign
                 is expecting
 email[subject] - (Optional) short subject line for the email
 email[body]    - (Optional) custom text that will be injected into the
                 DocuSign generated email
 email_settings[bcc_emails] - (Optional) array of emails to BCC.
 email_settings[reply_to_email] - (Optional) override the default reply to email for the account.
 email_settings[reply_to_name] - (Optional) override the default reply to name for the account.
 signers       - A hash of users who should receive the document and need
                 to sign it. More info about the options available for
                 this method are documented above it's method definition.
 carbon_copies - An array of hashes that includes users names and email who
                 should receive a copy of the document once it is complete.
 status        - Options include: 'sent', 'created', 'voided' and determine
                 if the envelope is sent out immediately or stored for
                 sending at a later time
 customFields  - (Optional) A hash of listCustomFields and textCustomFields.
                 Each contains an array of corresponding customField hashes.
                 For details, please see: http://bit.ly/1FnmRJx
 headers       - Allows a client to pass in some headers
 wet_sign      - (Optional) If true, the signer is allowed to print the
                 document and sign it on paper. False if not defined.

 Returns a JSON parsed response object containing:
   envelopeId     - The envelope's ID
   status         - Sent, created, or voided
   statusDateTime - The date/time the envelope was created
   uri            - The relative envelope uri