Sha256: 85fc6210c30660d7a635d256c8147adbc0a3d819f1ef3c0ad39b5ea5fe0953f6

Contents?: true

Size: 1.99 KB

Versions: 3

Compression:

Stored size: 1.99 KB

Contents

module Docusigner
  class Envelope < Docusigner::Base
    module Status
      CREATED   = "created"
      DELETED   = "deleted"
      SENT      = "sent"
      DELIVERED = "delivered"
      SIGNED    = "signed"
      COMPLETED = "completed"
      DECLINED  = "declined"
      VOIDED    = "voided"
      TIMED_OUT = "timedout"
      AUTHORITATIVE_COPY  = "authoritativecopy"
      TRANSFER_COMPLETED  = "transfercompleted"
      TEMPLATE  = "template"
      CORRECT   = "correct"
    end

    self.primary_key = "envelopeId"

    belongs_to :account

    has_many :documents
    has_many :recipients

    class << self
      def recipient_url(id, prefix_options = {}, params = {})
        resp = post("#{id}/views/recipient", prefix_options, params.to_json)
        format.decode(resp.body)
      end

      # fetch documents - don't use helper b/c we don't want to try to parse as json
      def documents_combined(id, prefix_options = {})
        connection.get(custom_method_collection_url("#{id}/documents/combined", prefix_options), headers).body
      end

    end

    def send!
      update_attribute(:status, Docusigner::Envelope::Status::SENT)
    end

    def void!(reason)
      update_attributes({
        :status => Docusigner::Envelope::Status::VOIDED,
        :voidReason => reason
      })
    end

    def recipient_url(params = {})
      resp = post("views/recipient", prefix_options, params.to_json)
      self.class.format.decode(resp.body)
    end

    def sender_url(params = {})
      resp = post("views/sender", prefix_options, params.to_json)
      self.class.format.decode(resp.body)
    end

    def correct_url(params = {})
      resp = post("views/correct", prefix_options, params.to_json)
      self.class.format.decode(resp.body)
    end

    # fetch documents - don't use helper b/c we don't want to try to parse as json
    def documents_combined(params = {})
      connection.get(custom_method_element_url("documents/combined", prefix_options.merge(params)), self.class.headers).body
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docusigner-0.0.9 lib/docusigner/envelope.rb
docusigner-0.0.8 lib/docusigner/envelope.rb
docusigner-0.0.6 lib/docusigner/envelope.rb