Class: Signatory::Recipient

Inherits:
API::Base
  • Object
show all
Defined in:
lib/signatory/recipient.rb

Instance Method Summary collapse

Methods inherited from API::Base

all, connection, formatted_collection_name, formatted_name, #id, instantiate_collection, #to_xml

Instance Method Details

#document=(doc) ⇒ Object



3
4
5
# File 'lib/signatory/recipient.rb', line 3

def document=(doc)
  @document = doc
end

#embed_code(redirect_url, options = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/signatory/recipient.rb', line 17

def embed_code(redirect_url, options={})
  args = ['frameborder="0"', 'scrolling="no"']
  args << "width=\"#{options[:width]}px\"" if options.has_key?(:width)
  args << "height=\"#{options[:height]}px\"" if options.has_key?(:height)
  "<iframe src =\"#{embed_url(redirect_url, options)}\" #{args.join(' ')}><p>Your browser does not support iframes.</p></iframe>"
end

#embed_url(redirect_url, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/signatory/recipient.rb', line 7

def embed_url(redirect_url, options={})
  signer_links = @document.get(:signer_links, "redirect_location" => redirect_url)
  signer = [signer_links['signer_links']['signer_link']].flatten.select do |s|
    s['role'] == role_id
  end.first
  options.merge!(:rt => signer['signer_token'])
  params = options.sort.map{|k,v| "#{k}=#{v}"}.flatten.join('&')
  "https://rightsignature.com/signatures/embedded?#{params}"
end