Class: DocuSign::Envelope

Inherits:
DocuSignModel show all
Defined in:
lib/docu_sign/envelope.rb

Constant Summary collapse

ATTRIBUTES =
[:transaction_id, :asynchronous, :account_id, :documents, :recipients, :tabs, :subject, :email_blurb,
:signing_location, :custom_fields, :vaulting_options, :auto_navigation, :envelope_id_stamping,
:authoritative_copy, :notification, :envelope_attachment, :enforce_signer_visibility, :enable_wet_sign,
:allow_markup, :event_notification, :allow_reassign]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DocuSignModel

#method_missing

Constructor Details

#initialize(attributes = {}) ⇒ Envelope

Returns a new instance of Envelope.



16
17
18
19
20
# File 'lib/docu_sign/envelope.rb', line 16

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class DocuSign::DocuSignModel

Instance Attribute Details

#document_builderObject



42
43
44
# File 'lib/docu_sign/envelope.rb', line 42

def document_builder
  @document_builder ||= DocuSign::Builder::DocumentBuilder.new()
end

#notification_builderObject



98
99
100
# File 'lib/docu_sign/envelope.rb', line 98

def notification_builder
  @notification_builder ||= DocuSign::Builder::NotificationBuilder.new
end

#recipient_builderObject



66
67
68
# File 'lib/docu_sign/envelope.rb', line 66

def recipient_builder
  @recipient_builder ||= DocuSign::Builder::RecipientBuilder.new()
end

#tab_builderObject



90
91
92
# File 'lib/docu_sign/envelope.rb', line 90

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

Instance Method Details

#document(options = {}, &block) ⇒ Object



36
37
38
39
40
# File 'lib/docu_sign/envelope.rb', line 36

def document(options = {}, &block)
  document_builder.build(options, &block).tap do |d|
    documents << d
  end
end

#documents(&block) ⇒ Object

Documents



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/docu_sign/envelope.rb', line 24

def documents(&block)
  @documents ||= DocuSign::ArrayOfDocument.new

  return @documents unless block_given?

  self.document_builder = DocuSign::Builder::DocumentBuilder.new()

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

#notification(options = {}, &block) ⇒ Object



94
95
96
# File 'lib/docu_sign/envelope.rb', line 94

def notification(options = {}, &block)
  @notification ||= notification_builder.build(options, &block)
end

#recipient(options = {}, &block) ⇒ Object



60
61
62
63
64
# File 'lib/docu_sign/envelope.rb', line 60

def recipient(options = {}, &block)
  recipient_builder.build(options, &block).tap do |r|
    recipients << r
  end
end

#recipients(&block) ⇒ Object

Recipients



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/docu_sign/envelope.rb', line 48

def recipients(&block)
  @recipients ||= DocuSign::ArrayOfRecipient.new

  return @recipients unless block_given?

  self.recipient_builder = DocuSign::Builder::RecipientBuilder.new()

  @recipients.tap do |r|
    yield self if block_given?
  end
end

#tab(options = {}, &block) ⇒ Object



84
85
86
87
88
# File 'lib/docu_sign/envelope.rb', line 84

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

#tabs(recipient = nil, &block) ⇒ Object

Tabs



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/docu_sign/envelope.rb', line 72

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

  return @tabs unless block_given?

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

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

#to_savonObject



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/docu_sign/envelope.rb', line 102

def to_savon
  {"Envelope" => {
    "TransactionID" => self.transaction_id,
    "Asynchronous" => self.asynchronous?,
    "AccountId" => self.,
    "Documents" => {
      "Document" => self.documents.collect(&:to_savon)
    },
    "Recipients" => {
      "Recipient" => self.recipients.collect(&:to_savon)
    },
    "Tabs" => {
      "Tab" => self.tabs.collect(&:to_savon)
    },
    "Subject" => self.subject,
    "EmailBlurb" => self.email_blurb,
    "SigningLocation" => self.signing_location,
    # TODO: CustomFields
    # TODO: VaultingOptions
    "AutoNavigation" => self.auto_navigation?,
    "EnvelopeIDStamping" => self.envelope_id_stamping?,
    "AuthoritativeCopy" => self.authoritative_copy?,
    # TODO: EnvelopeAttachment
    "Notification" => self.notification.try(:to_savon),
    "EnforceSignerVisibility" => self.enforce_signer_visibility?,
    "EnableWetSign" => self.enable_wet_sign?,
    "AllowMarkup" => self.allow_markup?,
    # TODO: EventNotification
    "AllowReassign" => self.allow_reassign?
  }.delete_if{|key, value| value.nil?}}
end