-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate-requests.rb
95 lines (76 loc) · 2.05 KB
/
template-requests.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
def print_template(temp)
puts <<-EOS
TEMPLATE
-----
Template ID: #{temp.template_id}
Title: #{temp.title}
Embedded: #{temp.is_embedded}
EOS
end
def print_signer_roles(temp)
signers = temp.signer_roles
puts "SIGNER ROLES"
signers.each do |sig|
puts <<-EOS
Signer Role: #{sig.name}
Signer Order: #{sig.order}
EOS
end
end
def print_custom_fields(temp)
fields = temp.custom_fields
puts "CUSTOM FIELDS"
fields.each do |field|
puts <<-EOS
Field Name: #{field.name}
Field Type: #{field.type}
Signer: #{field.signer}
Required: #{field.required}
EOS
end
end
def get_template(id)
client = initiate_client
template = client.get_template :template_id => id
print_template(template)
print_signer_roles(template)
print_custom_fields(template)
end
def list_templates
client = initiate_client
templates = client.get_templates :page => 1, :page_size => 5
templates.each do |temp|
print_template(temp)
end
end
def add_template_access(id, email)
client = initiate_client
template = client.add_user_to_template :template_id => id, :email_address => email
print_template(template)
end
def remove_template_access(id, email)
client = initiate_client
template = client.remove_user_from_template :template_id => id, :email_address => email
print_template(template)
end
def delete_template(id)
client = initiate_client
template = client.delete_template :template_id => id
puts "Template ID #{id} deleted!"
end
def get_template_files(id)
client = initiate_client
template = client.get_template_files :template_id => id, :get_url => false
# #get_template_files method in Ruby SDK missing functionality to handle parameters
# added this on 11/29, waiting to merge PR
# p template
# puts <<-EOS
# Access your file here:
# #{template["file_url"]}
# EOS
end
def update_template_files(id)
client = initiate_client
template = client.update_template_files :template_id => id, :file_url => 'http://www.pdf995.com/samples/pdf.pdf'
puts "Template ID #{template.template_id} updated!"
end