Sha256: 83eaf66ef6a3179dcf70560e8699878e11ddd03cb83a48391fe2c60e0ef79852

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

module DocuSign
  class Document < DocuSignModel
    ATTRIBUTES = [:tabs, :id, :name, :pdf_bytes, :password, :transform_pdf_fields, :file_extension, :match_boxes,
      :attachment_description]
    ATTRIBUTES.each do |attr|
      self.send(:attr_accessor, attr)
    end
    attr_writer :tab_builder

    def initialize(attributes = {})
      ATTRIBUTES.each do |attr|
        self.send("#{attr}=", attributes[attr])
      end
    end

    def tabs(recipient = nil, &block)
      @tabs ||= DocuSign::ArrayOfTab.new

      return @tabs unless block_given?

      self.tab_builder = DocuSign::Builder::TabBuilder.new(self, recipient)

      @tabs.tap do |a|
        yield self if block_given?
      end
    end

    def tab(options = {}, &block)
      tab_builder.build(options, &block).tap do |t|
        tabs << t
      end
    end

    def tab_builder
      @tab_builder ||= DocuSign::Builder::TabBuilder.new(self)
    end

    def to_savon
      {
        "ID" => self.id,
        "Name" => self.name,
        "PDFBytes" => self.pdf_bytes,
        "Password" => self.password,
        "TransformPdfFields" => self.transform_pdf_fields,
        "FileExtension" => self.file_extension,
        "MatchBoxes" => self.match_boxes,
        "AttachmentDescription" => self.attachment_description
      }.delete_if{|key, value| value.nil?}
    end
  end
end

# {http://www.docusign.net/API/3.0}ArrayOfDocument
module DocuSign
  class ArrayOfDocument < ::Array
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
docu_sign-0.0.6 lib/docu_sign/document.rb
docu_sign-0.0.5 lib/docu_sign/document.rb
docu_sign-0.0.4 lib/docu_sign/document.rb
docu_sign-0.0.3 lib/docu_sign/document.rb