groupdocs 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. data/CHANGELOG.md +34 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +3 -0
  4. data/examples/api-samples/public/docs/sample01.html +23 -23
  5. data/examples/api-samples/public/docs/sample02.html +27 -27
  6. data/examples/api-samples/public/docs/sample03.html +81 -69
  7. data/examples/api-samples/public/docs/sample04.html +29 -29
  8. data/examples/api-samples/public/docs/sample05.html +48 -48
  9. data/examples/api-samples/public/docs/sample06.html +47 -46
  10. data/examples/api-samples/public/docs/sample07.html +35 -35
  11. data/examples/api-samples/public/docs/sample08.html +45 -45
  12. data/examples/api-samples/public/docs/sample09.html +57 -57
  13. data/examples/api-samples/public/docs/sample10.html +41 -41
  14. data/examples/api-samples/public/docs/sample11.html +96 -118
  15. data/examples/api-samples/public/docs/sample12.html +29 -50
  16. data/examples/api-samples/public/docs/sample13.html +36 -44
  17. data/examples/api-samples/public/docs/sample14.html +29 -29
  18. data/examples/api-samples/public/docs/sample15.html +24 -24
  19. data/examples/api-samples/public/docs/sample16.html +32 -32
  20. data/examples/api-samples/public/docs/sample17.html +38 -38
  21. data/examples/api-samples/public/docs/sample18.html +105 -101
  22. data/examples/api-samples/public/docs/sample19.html +101 -101
  23. data/examples/api-samples/public/docs/sample20.html +42 -42
  24. data/examples/api-samples/public/docs/sample21.html +109 -109
  25. data/examples/api-samples/public/docs/sample22.html +56 -56
  26. data/examples/api-samples/public/docs/sample23.html +39 -39
  27. data/examples/api-samples/public/docs/sample24.html +36 -36
  28. data/examples/api-samples/public/docs/sample25.html +67 -67
  29. data/examples/api-samples/public/docs/sample26.html +23 -23
  30. data/examples/api-samples/public/docs/sample27.html +72 -72
  31. data/examples/api-samples/public/docs/sample28.html +46 -45
  32. data/examples/api-samples/public/docs/sample29.html +30 -30
  33. data/examples/api-samples/public/docs/sample30.html +30 -30
  34. data/examples/api-samples/public/docs/sample31.html +114 -114
  35. data/examples/api-samples/public/docs/sample32.html +96 -96
  36. data/examples/api-samples/public/docs/sample33.html +56 -56
  37. data/examples/api-samples/public/docs/sample34.html +27 -27
  38. data/examples/api-samples/public/docs/sample35.html +134 -135
  39. data/examples/api-samples/public/docs/sample36.html +32 -32
  40. data/examples/api-samples/public/docs/sample37.html +103 -103
  41. data/examples/api-samples/public/docs/sample38.html +76 -76
  42. data/examples/api-samples/public/docs/sample39.html +136 -136
  43. data/examples/api-samples/public/docs/sample40.html +104 -104
  44. data/examples/api-samples/public/docs/sample41.html +137 -137
  45. data/examples/api-samples/public/docs/sample42.html +61 -61
  46. data/examples/api-samples/public/docs/sample43.html +72 -72
  47. data/examples/api-samples/public/docs/sample44.html +751 -0
  48. data/examples/api-samples/public/docs/sample45.html +236 -0
  49. data/examples/api-samples/public/templates/merge_field3_doc.docx +0 -0
  50. data/examples/api-samples/samples/sample01.rb +2 -2
  51. data/examples/api-samples/samples/sample02.rb +2 -2
  52. data/examples/api-samples/samples/sample03.rb +2 -2
  53. data/examples/api-samples/samples/sample04.rb +2 -2
  54. data/examples/api-samples/samples/sample05.rb +2 -2
  55. data/examples/api-samples/samples/sample06.rb +2 -2
  56. data/examples/api-samples/samples/sample07.rb +2 -2
  57. data/examples/api-samples/samples/sample08.rb +2 -2
  58. data/examples/api-samples/samples/sample09.rb +2 -2
  59. data/examples/api-samples/samples/sample10.rb +2 -2
  60. data/examples/api-samples/samples/sample11.rb +2 -2
  61. data/examples/api-samples/samples/sample12.rb +2 -2
  62. data/examples/api-samples/samples/sample13.rb +2 -2
  63. data/examples/api-samples/samples/sample14.rb +2 -2
  64. data/examples/api-samples/samples/sample15.rb +2 -2
  65. data/examples/api-samples/samples/sample16.rb +2 -2
  66. data/examples/api-samples/samples/sample17.rb +2 -2
  67. data/examples/api-samples/samples/sample18.rb +2 -2
  68. data/examples/api-samples/samples/sample19.rb +2 -2
  69. data/examples/api-samples/samples/sample20.rb +2 -2
  70. data/examples/api-samples/samples/sample21.rb +2 -2
  71. data/examples/api-samples/samples/sample22.rb +2 -2
  72. data/examples/api-samples/samples/sample23.rb +2 -2
  73. data/examples/api-samples/samples/sample24.rb +2 -2
  74. data/examples/api-samples/samples/sample25.rb +2 -2
  75. data/examples/api-samples/samples/sample26.rb +2 -2
  76. data/examples/api-samples/samples/sample27.rb +2 -2
  77. data/examples/api-samples/samples/sample28.rb +2 -2
  78. data/examples/api-samples/samples/sample29.rb +2 -2
  79. data/examples/api-samples/samples/sample30.rb +2 -2
  80. data/examples/api-samples/samples/sample31.rb +2 -2
  81. data/examples/api-samples/samples/sample32.rb +2 -2
  82. data/examples/api-samples/samples/sample33.rb +2 -2
  83. data/examples/api-samples/samples/sample34.rb +2 -2
  84. data/examples/api-samples/samples/sample35.rb +4 -4
  85. data/examples/api-samples/samples/sample36.rb +2 -2
  86. data/examples/api-samples/samples/sample37.rb +2 -2
  87. data/examples/api-samples/samples/sample38.rb +2 -2
  88. data/examples/api-samples/samples/sample39.rb +2 -2
  89. data/examples/api-samples/samples/sample40.rb +2 -2
  90. data/examples/api-samples/samples/sample41.rb +2 -2
  91. data/examples/api-samples/samples/sample42.rb +2 -2
  92. data/examples/api-samples/samples/sample43.rb +2 -2
  93. data/examples/api-samples/samples/sample44.rb +188 -0
  94. data/examples/api-samples/samples/sample45.rb +74 -0
  95. data/examples/api-samples/views/_others_samples.haml +47 -43
  96. data/examples/api-samples/views/index.haml +55 -44
  97. data/examples/api-samples/views/layout.haml +1 -6
  98. data/examples/api-samples/views/sample01.haml +62 -57
  99. data/examples/api-samples/views/sample02.haml +52 -46
  100. data/examples/api-samples/views/sample03.haml +78 -73
  101. data/examples/api-samples/views/sample04.haml +51 -45
  102. data/examples/api-samples/views/sample05.haml +77 -71
  103. data/examples/api-samples/views/sample06.haml +58 -52
  104. data/examples/api-samples/views/sample07.haml +51 -45
  105. data/examples/api-samples/views/sample08.haml +90 -84
  106. data/examples/api-samples/views/sample09.haml +86 -80
  107. data/examples/api-samples/views/sample10.haml +83 -77
  108. data/examples/api-samples/views/sample11.haml +124 -120
  109. data/examples/api-samples/views/sample12.haml +65 -59
  110. data/examples/api-samples/views/sample13.haml +62 -56
  111. data/examples/api-samples/views/sample14.haml +57 -51
  112. data/examples/api-samples/views/sample15.haml +49 -43
  113. data/examples/api-samples/views/sample16.haml +49 -43
  114. data/examples/api-samples/views/sample17.haml +53 -47
  115. data/examples/api-samples/views/sample18.haml +140 -134
  116. data/examples/api-samples/views/sample19.haml +87 -81
  117. data/examples/api-samples/views/sample20.haml +53 -47
  118. data/examples/api-samples/views/sample21.haml +115 -111
  119. data/examples/api-samples/views/sample22.haml +94 -88
  120. data/examples/api-samples/views/sample23.haml +83 -78
  121. data/examples/api-samples/views/sample24.haml +54 -48
  122. data/examples/api-samples/views/sample25.haml +89 -83
  123. data/examples/api-samples/views/sample26.haml +62 -57
  124. data/examples/api-samples/views/sample27.haml +114 -109
  125. data/examples/api-samples/views/sample28.haml +55 -49
  126. data/examples/api-samples/views/sample29.haml +67 -69
  127. data/examples/api-samples/views/sample30.haml +54 -48
  128. data/examples/api-samples/views/sample31.haml +106 -100
  129. data/examples/api-samples/views/sample32.haml +90 -84
  130. data/examples/api-samples/views/sample33.haml +60 -54
  131. data/examples/api-samples/views/sample34.haml +51 -46
  132. data/examples/api-samples/views/sample35.haml +84 -78
  133. data/examples/api-samples/views/sample36.haml +63 -58
  134. data/examples/api-samples/views/sample37.haml +122 -116
  135. data/examples/api-samples/views/sample38.haml +104 -98
  136. data/examples/api-samples/views/sample39.haml +6 -2
  137. data/examples/api-samples/views/sample40.haml +94 -89
  138. data/examples/api-samples/views/sample41.haml +127 -123
  139. data/examples/api-samples/views/sample42.haml +60 -54
  140. data/examples/api-samples/views/sample43.haml +81 -77
  141. data/examples/api-samples/views/sample44.haml +85 -0
  142. data/examples/api-samples/views/sample45.haml +85 -0
  143. data/groupdocs.gemspec +2 -0
  144. data/lib/groupdocs/datasource/field.rb +9 -0
  145. data/lib/groupdocs/document.rb +66 -4
  146. data/lib/groupdocs/document/annotation.rb +11 -6
  147. data/lib/groupdocs/document/editor.rb +53 -0
  148. data/lib/groupdocs/document/field.rb +16 -0
  149. data/lib/groupdocs/document/style.rb +30 -0
  150. data/lib/groupdocs/job.rb +24 -0
  151. data/lib/groupdocs/questionnaire.rb +2 -0
  152. data/lib/groupdocs/questionnaire/collector.rb +52 -0
  153. data/lib/groupdocs/questionnaire/collector_style.rb +54 -0
  154. data/lib/groupdocs/questionnaire/question.rb +9 -0
  155. data/lib/groupdocs/questionnaire/style/base_font.rb +17 -0
  156. data/lib/groupdocs/questionnaire/style/question_title.rb +17 -0
  157. data/lib/groupdocs/questionnaire/style/title.rb +17 -0
  158. data/lib/groupdocs/signature/envelope.rb +43 -8
  159. data/lib/groupdocs/signature/form.rb +113 -12
  160. data/lib/groupdocs/signature/recipient.rb +38 -3
  161. data/lib/groupdocs/signature/shared/field_methods.rb +4 -2
  162. data/lib/groupdocs/signature/template.rb +20 -1
  163. data/lib/groupdocs/storage/file.rb +3 -2
  164. data/lib/groupdocs/user.rb +148 -0
  165. data/lib/groupdocs/version.rb +1 -1
  166. data/spec/groupdocs/api/helpers/access_rights_helper_spec.rb +5 -5
  167. data/spec/groupdocs/document/annotation_spec.rb +1 -1
  168. data/spec/groupdocs/signature/envelope_spec.rb +1 -1
  169. data/spec/groupdocs/user_spec.rb +4 -4
  170. data/spec/support/shared_examples/signature/shared/field_methods.rb +5 -4
  171. metadata +18 -3
@@ -0,0 +1,751 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>sample44.rb</title>
6
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
+ <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
8
+ <link rel="stylesheet" media="all" href="docco.css" />
9
+ </head>
10
+ <body>
11
+ <div id="container">
12
+ <div id="background"></div>
13
+
14
+ <ul class="sections">
15
+
16
+ <li id="title">
17
+ <div class="annotation">
18
+ <h1>sample44.rb</h1>
19
+ </div>
20
+ </li>
21
+
22
+
23
+
24
+ <li id="section-1">
25
+ <div class="annotation">
26
+
27
+ <div class="pilwrap ">
28
+ <a class="pilcrow" href="#section-1">&#182;</a>
29
+ </div>
30
+ <p>GET request</p>
31
+
32
+ </div>
33
+
34
+ <div class="content"><div class='highlight'><pre>get <span class="hljs-string">'/sample-44-how-to-assemble-document-and-add-multiple-signatures-and-signers-to-a-document'</span> <span class="hljs-keyword">do</span>
35
+ haml <span class="hljs-symbol">:sample44</span>
36
+ <span class="hljs-keyword">end</span></pre></div></div>
37
+
38
+ </li>
39
+
40
+
41
+ <li id="section-2">
42
+ <div class="annotation">
43
+
44
+ <div class="pilwrap ">
45
+ <a class="pilcrow" href="#section-2">&#182;</a>
46
+ </div>
47
+ <p>POST request</p>
48
+
49
+ </div>
50
+
51
+ <div class="content"><div class='highlight'><pre>post <span class="hljs-string">'/sample-44-how-to-assemble-document-and-add-multiple-signatures-and-signers-to-a-document'</span> <span class="hljs-keyword">do</span></pre></div></div>
52
+
53
+ </li>
54
+
55
+
56
+ <li id="section-3">
57
+ <div class="annotation">
58
+
59
+ <div class="pilwrap ">
60
+ <a class="pilcrow" href="#section-3">&#182;</a>
61
+ </div>
62
+ <p>Set variables</p>
63
+
64
+ </div>
65
+
66
+ <div class="content"><div class='highlight'><pre> set <span class="hljs-symbol">:client_id</span>, params[<span class="hljs-symbol">:clientId</span>]
67
+ set <span class="hljs-symbol">:private_key</span>, params[<span class="hljs-symbol">:privateKey</span>]
68
+ set <span class="hljs-symbol">:file_id</span>, params[<span class="hljs-symbol">:fileId</span>]
69
+ set <span class="hljs-symbol">:first_name</span>, params[<span class="hljs-symbol">:firstName</span>]
70
+ set <span class="hljs-symbol">:last_name</span>, params[<span class="hljs-symbol">:lastName</span>]
71
+ set <span class="hljs-symbol">:first_email</span>, params[<span class="hljs-symbol">:firstEmail</span>]
72
+ set <span class="hljs-symbol">:second_email</span>, params[<span class="hljs-symbol">:secondEmail</span>]
73
+ set <span class="hljs-symbol">:gender</span>, params[<span class="hljs-symbol">:gender</span>]
74
+ set <span class="hljs-symbol">:base_path</span>, params[<span class="hljs-symbol">:basePath</span>]</pre></div></div>
75
+
76
+ </li>
77
+
78
+
79
+ <li id="section-4">
80
+ <div class="annotation">
81
+
82
+ <div class="pilwrap ">
83
+ <a class="pilcrow" href="#section-4">&#182;</a>
84
+ </div>
85
+ <p>Set download path</p>
86
+
87
+ </div>
88
+
89
+ <div class="content"><div class='highlight'><pre> downloads_path = <span class="hljs-string">"<span class="hljs-subst">#{<span class="hljs-constant">File</span>.dirname(__FILE_<span class="hljs-number">_</span>)}</span>/../public/downloads"</span></pre></div></div>
90
+
91
+ </li>
92
+
93
+
94
+ <li id="section-5">
95
+ <div class="annotation">
96
+
97
+ <div class="pilwrap ">
98
+ <a class="pilcrow" href="#section-5">&#182;</a>
99
+ </div>
100
+ <p>Remove all files from download directory or create folder if it not there</p>
101
+
102
+ </div>
103
+
104
+ <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-constant">File</span>.directory?(downloads_path)
105
+ <span class="hljs-constant">Dir</span>.foreach(downloads_path) { |f| fn = <span class="hljs-constant">File</span>.join(downloads_path, f); <span class="hljs-constant">File</span>.delete(fn) <span class="hljs-keyword">if</span> f != <span class="hljs-string">'.'</span> &amp;&amp; f != <span class="hljs-string">'..'</span> }
106
+ <span class="hljs-keyword">else</span>
107
+ <span class="hljs-constant">Dir::</span>mkdir(downloads_path)
108
+ <span class="hljs-keyword">end</span>
109
+
110
+ <span class="hljs-keyword">begin</span></pre></div></div>
111
+
112
+ </li>
113
+
114
+
115
+ <li id="section-6">
116
+ <div class="annotation">
117
+
118
+ <div class="pilwrap ">
119
+ <a class="pilcrow" href="#section-6">&#182;</a>
120
+ </div>
121
+ <p>Check required variables</p>
122
+
123
+ </div>
124
+
125
+ <div class="content"><div class='highlight'><pre> raise <span class="hljs-string">'Please enter all required parameters'</span> <span class="hljs-keyword">if</span> settings.client_id.empty? <span class="hljs-keyword">or</span> settings.private_key.empty? <span class="hljs-keyword">or</span> settings.first_email.empty? <span class="hljs-keyword">or</span> settings.second_email.empty? <span class="hljs-keyword">or</span> settings.first_name.empty?</pre></div></div>
126
+
127
+ </li>
128
+
129
+
130
+ <li id="section-7">
131
+ <div class="annotation">
132
+
133
+ <div class="pilwrap ">
134
+ <a class="pilcrow" href="#section-7">&#182;</a>
135
+ </div>
136
+ <p>Prepare base path</p>
137
+
138
+ </div>
139
+
140
+ <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> settings.base_path.empty?
141
+ base_path = <span class="hljs-string">'https://api.groupdocs.com'</span>
142
+ <span class="hljs-keyword">elsif</span> settings.base_path.match(<span class="hljs-string">'/v2.0'</span>)
143
+ base_path = settings.base_path.split(<span class="hljs-string">'/v2.0'</span>)[<span class="hljs-number">0</span>]
144
+ <span class="hljs-keyword">else</span>
145
+ base_path = settings.base_path
146
+ <span class="hljs-keyword">end</span></pre></div></div>
147
+
148
+ </li>
149
+
150
+
151
+ <li id="section-8">
152
+ <div class="annotation">
153
+
154
+ <div class="pilwrap ">
155
+ <a class="pilcrow" href="#section-8">&#182;</a>
156
+ </div>
157
+ <p>Configure your access to API server</p>
158
+
159
+ </div>
160
+
161
+ <div class="content"><div class='highlight'><pre> <span class="hljs-constant">GroupDocs</span>.configure <span class="hljs-keyword">do</span> |groupdocs|
162
+ groupdocs.client_id = settings.client_id
163
+ groupdocs.private_key = settings.private_key</pre></div></div>
164
+
165
+ </li>
166
+
167
+
168
+ <li id="section-9">
169
+ <div class="annotation">
170
+
171
+ <div class="pilwrap ">
172
+ <a class="pilcrow" href="#section-9">&#182;</a>
173
+ </div>
174
+ <p>Optionally specify API server and version</p>
175
+
176
+ </div>
177
+
178
+ <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="hljs-comment"># default is 'https://api.groupdocs.com'</span>
179
+ <span class="hljs-keyword">end</span>
180
+
181
+ (settings.last_name.<span class="hljs-keyword">nil</span>? <span class="hljs-keyword">or</span> settings.last_name.empty?) ? settings.last_name = settings.first_name <span class="hljs-symbol">:</span> settings.last_name
182
+
183
+ second_signer_name = settings.first_name + <span class="hljs-string">"2"</span>
184
+ second_signer_last_name = settings.last_name + <span class="hljs-string">"2"</span></pre></div></div>
185
+
186
+ </li>
187
+
188
+
189
+ <li id="section-10">
190
+ <div class="annotation">
191
+
192
+ <div class="pilwrap ">
193
+ <a class="pilcrow" href="#section-10">&#182;</a>
194
+ </div>
195
+ <p>Construct path</p>
196
+
197
+ </div>
198
+
199
+ <div class="content"><div class='highlight'><pre>
200
+ file_path = <span class="hljs-string">"<span class="hljs-subst">#{<span class="hljs-constant">Dir</span>.tmpdir}</span>/<span class="hljs-subst">#{params[<span class="hljs-symbol">:file</span>][<span class="hljs-symbol">:filename</span>]}</span>"</span></pre></div></div>
201
+
202
+ </li>
203
+
204
+
205
+ <li id="section-11">
206
+ <div class="annotation">
207
+
208
+ <div class="pilwrap ">
209
+ <a class="pilcrow" href="#section-11">&#182;</a>
210
+ </div>
211
+ <p>Open file</p>
212
+
213
+ </div>
214
+
215
+ <div class="content"><div class='highlight'><pre> <span class="hljs-constant">File</span>.open(file_path, <span class="hljs-string">'wb'</span>) { |f| f.write(params[<span class="hljs-symbol">:file</span>][<span class="hljs-symbol">:tempfile</span>].read) }</pre></div></div>
216
+
217
+ </li>
218
+
219
+
220
+ <li id="section-12">
221
+ <div class="annotation">
222
+
223
+ <div class="pilwrap ">
224
+ <a class="pilcrow" href="#section-12">&#182;</a>
225
+ </div>
226
+ <p>Make a request to API using client_id and private_key</p>
227
+
228
+ </div>
229
+
230
+ <div class="content"><div class='highlight'><pre> file = <span class="hljs-constant">GroupDocs::Storage::File</span>.upload!(file_path, {})</pre></div></div>
231
+
232
+ </li>
233
+
234
+
235
+ <li id="section-13">
236
+ <div class="annotation">
237
+
238
+ <div class="pilwrap ">
239
+ <a class="pilcrow" href="#section-13">&#182;</a>
240
+ </div>
241
+ <p>Raise exception if something went wrong</p>
242
+
243
+ </div>
244
+
245
+ <div class="content"><div class='highlight'><pre> raise <span class="hljs-string">'No such file'</span> <span class="hljs-keyword">unless</span> file.is_a?(<span class="hljs-constant">GroupDocs::Storage::File</span>)</pre></div></div>
246
+
247
+ </li>
248
+
249
+
250
+ <li id="section-14">
251
+ <div class="annotation">
252
+
253
+ <div class="pilwrap ">
254
+ <a class="pilcrow" href="#section-14">&#182;</a>
255
+ </div>
256
+ <p>Make GroupDocs::Storage::Document instance</p>
257
+
258
+ </div>
259
+
260
+ <div class="content"><div class='highlight'><pre> document = file.to_document</pre></div></div>
261
+
262
+ </li>
263
+
264
+
265
+ <li id="section-15">
266
+ <div class="annotation">
267
+
268
+ <div class="pilwrap ">
269
+ <a class="pilcrow" href="#section-15">&#182;</a>
270
+ </div>
271
+ <p>Create datasource with fields</p>
272
+
273
+ </div>
274
+
275
+ <div class="content"><div class='highlight'><pre> datasource = <span class="hljs-constant">GroupDocs::DataSource</span>.new</pre></div></div>
276
+
277
+ </li>
278
+
279
+
280
+ <li id="section-16">
281
+ <div class="annotation">
282
+
283
+ <div class="pilwrap ">
284
+ <a class="pilcrow" href="#section-16">&#182;</a>
285
+ </div>
286
+ <p>Get arry of document’s fields</p>
287
+
288
+ </div>
289
+
290
+ <div class="content"><div class='highlight'><pre> enteredData = {<span class="hljs-string">"name"</span> =&gt; settings.first_name, <span class="hljs-string">"gender"</span> =&gt; settings.gender}</pre></div></div>
291
+
292
+ </li>
293
+
294
+
295
+ <li id="section-17">
296
+ <div class="annotation">
297
+
298
+ <div class="pilwrap ">
299
+ <a class="pilcrow" href="#section-17">&#182;</a>
300
+ </div>
301
+ <p>Create Field instance and fill the fields</p>
302
+
303
+ </div>
304
+
305
+ <div class="content"><div class='highlight'><pre> datasource.fields = enteredData.map { |key, value| <span class="hljs-constant">GroupDocs::DataSource::Field</span>.new(<span class="hljs-symbol">name:</span> key, <span class="hljs-symbol">type:</span> <span class="hljs-symbol">:text</span>, <span class="hljs-symbol">values:</span> <span class="hljs-constant">Array</span>.new() &lt;&lt; value) }</pre></div></div>
306
+
307
+ </li>
308
+
309
+
310
+ <li id="section-18">
311
+ <div class="annotation">
312
+
313
+ <div class="pilwrap ">
314
+ <a class="pilcrow" href="#section-18">&#182;</a>
315
+ </div>
316
+ <p>Adds datasource.</p>
317
+
318
+ </div>
319
+
320
+ <div class="content"><div class='highlight'><pre> datasource.add!()</pre></div></div>
321
+
322
+ </li>
323
+
324
+
325
+ <li id="section-19">
326
+ <div class="annotation">
327
+
328
+ <div class="pilwrap ">
329
+ <a class="pilcrow" href="#section-19">&#182;</a>
330
+ </div>
331
+ <p>Creates new job to merge datasource into document.</p>
332
+
333
+ </div>
334
+
335
+ <div class="content"><div class='highlight'><pre> job = document.datasource!(datasource)
336
+ sleep <span class="hljs-number">10</span> <span class="hljs-comment">#Wait for merge and convert</span></pre></div></div>
337
+
338
+ </li>
339
+
340
+
341
+ <li id="section-20">
342
+ <div class="annotation">
343
+
344
+ <div class="pilwrap ">
345
+ <a class="pilcrow" href="#section-20">&#182;</a>
346
+ </div>
347
+ <p>Returns an hash of input and output documents associated to job.</p>
348
+
349
+ </div>
350
+
351
+ <div class="content"><div class='highlight'><pre> document = job.documents!()</pre></div></div>
352
+
353
+ </li>
354
+
355
+
356
+ <li id="section-21">
357
+ <div class="annotation">
358
+
359
+ <div class="pilwrap ">
360
+ <a class="pilcrow" href="#section-21">&#182;</a>
361
+ </div>
362
+ <p>Set converted document GUID</p>
363
+
364
+ </div>
365
+
366
+ <div class="content"><div class='highlight'><pre> guid = document[<span class="hljs-symbol">:inputs</span>][<span class="hljs-number">0</span>].outputs[<span class="hljs-number">0</span>].guid
367
+ file = <span class="hljs-constant">GroupDocs::Storage::File</span>.new({<span class="hljs-symbol">:guid</span> =&gt; guid})</pre></div></div>
368
+
369
+ </li>
370
+
371
+
372
+ <li id="section-22">
373
+ <div class="annotation">
374
+
375
+ <div class="pilwrap ">
376
+ <a class="pilcrow" href="#section-22">&#182;</a>
377
+ </div>
378
+ <p>Set converted document Name</p>
379
+
380
+ </div>
381
+
382
+ <div class="content"><div class='highlight'><pre> file_name = document[<span class="hljs-symbol">:inputs</span>][<span class="hljs-number">0</span>].outputs[<span class="hljs-number">0</span>].name</pre></div></div>
383
+
384
+ </li>
385
+
386
+
387
+ <li id="section-23">
388
+ <div class="annotation">
389
+
390
+ <div class="pilwrap ">
391
+ <a class="pilcrow" href="#section-23">&#182;</a>
392
+ </div>
393
+ <p>Create envelope using user id and entered by user name</p>
394
+
395
+ </div>
396
+
397
+ <div class="content"><div class='highlight'><pre> envelope = <span class="hljs-constant">GroupDocs::Signature::Envelope</span>.new
398
+ envelope.name = file_name
399
+ envelope.create!({})</pre></div></div>
400
+
401
+ </li>
402
+
403
+
404
+ <li id="section-24">
405
+ <div class="annotation">
406
+
407
+ <div class="pilwrap ">
408
+ <a class="pilcrow" href="#section-24">&#182;</a>
409
+ </div>
410
+ <p>Add uploaded document to envelope</p>
411
+
412
+ </div>
413
+
414
+ <div class="content"><div class='highlight'><pre> envelope.add_document!(file.to_document, {})</pre></div></div>
415
+
416
+ </li>
417
+
418
+
419
+ <li id="section-25">
420
+ <div class="annotation">
421
+
422
+ <div class="pilwrap ">
423
+ <a class="pilcrow" href="#section-25">&#182;</a>
424
+ </div>
425
+ <p>Get role list for current user</p>
426
+
427
+ </div>
428
+
429
+ <div class="content"><div class='highlight'><pre> roles = <span class="hljs-constant">GroupDocs::Signature::Role</span>.get!({})</pre></div></div>
430
+
431
+ </li>
432
+
433
+
434
+ <li id="section-26">
435
+ <div class="annotation">
436
+
437
+ <div class="pilwrap ">
438
+ <a class="pilcrow" href="#section-26">&#182;</a>
439
+ </div>
440
+ <p>Create new first recipient</p>
441
+
442
+ </div>
443
+
444
+ <div class="content"><div class='highlight'><pre> first_recipient = <span class="hljs-constant">GroupDocs::Signature::Recipient</span>.new
445
+ first_recipient.email = settings.first_email
446
+ first_recipient.first_name = settings.first_name
447
+ first_recipient.last_name = settings.last_name
448
+ first_recipient.role_id = roles.detect { |role| role.name == <span class="hljs-string">'Signer'</span> }.id</pre></div></div>
449
+
450
+ </li>
451
+
452
+
453
+ <li id="section-27">
454
+ <div class="annotation">
455
+
456
+ <div class="pilwrap ">
457
+ <a class="pilcrow" href="#section-27">&#182;</a>
458
+ </div>
459
+ <p>Create new second recipient</p>
460
+
461
+ </div>
462
+
463
+ <div class="content"><div class='highlight'><pre> second_recipient = <span class="hljs-constant">GroupDocs::Signature::Recipient</span>.new
464
+ second_recipient.email = settings.second_email
465
+ second_recipient.first_name = second_signer_name
466
+ second_recipient.last_name = second_signer_last_name
467
+ second_recipient.role_id = roles.detect { |role| role.name == <span class="hljs-string">'Signer'</span> }.id</pre></div></div>
468
+
469
+ </li>
470
+
471
+
472
+ <li id="section-28">
473
+ <div class="annotation">
474
+
475
+ <div class="pilwrap ">
476
+ <a class="pilcrow" href="#section-28">&#182;</a>
477
+ </div>
478
+ <p>Add first recipient to envelope</p>
479
+
480
+ </div>
481
+
482
+ <div class="content"><div class='highlight'><pre> first_recipient = envelope.add_recipient!(first_recipient)</pre></div></div>
483
+
484
+ </li>
485
+
486
+
487
+ <li id="section-29">
488
+ <div class="annotation">
489
+
490
+ <div class="pilwrap ">
491
+ <a class="pilcrow" href="#section-29">&#182;</a>
492
+ </div>
493
+ <p>Add second recipient to envelope</p>
494
+
495
+ </div>
496
+
497
+ <div class="content"><div class='highlight'><pre> second_recipient = envelope.add_recipient!(second_recipient)</pre></div></div>
498
+
499
+ </li>
500
+
501
+
502
+ <li id="section-30">
503
+ <div class="annotation">
504
+
505
+ <div class="pilwrap ">
506
+ <a class="pilcrow" href="#section-30">&#182;</a>
507
+ </div>
508
+ <p>Get document id</p>
509
+
510
+ </div>
511
+
512
+ <div class="content"><div class='highlight'><pre> document = envelope.documents!({})</pre></div></div>
513
+
514
+ </li>
515
+
516
+
517
+ <li id="section-31">
518
+ <div class="annotation">
519
+
520
+ <div class="pilwrap ">
521
+ <a class="pilcrow" href="#section-31">&#182;</a>
522
+ </div>
523
+ <p>Get field and add the location to field</p>
524
+
525
+ </div>
526
+
527
+ <div class="content"><div class='highlight'><pre> field1 = <span class="hljs-constant">GroupDocs::Signature::Field</span>.get!({}).detect { |f| f.type == <span class="hljs-symbol">:signature</span> }
528
+ field1.location = {<span class="hljs-symbol">:location_x</span> =&gt; <span class="hljs-number">0</span>.<span class="hljs-number">15</span>, <span class="hljs-symbol">:location_y</span> =&gt; <span class="hljs-number">0</span>.<span class="hljs-number">23</span>, <span class="hljs-symbol">:location_w</span> =&gt; <span class="hljs-number">150</span>, <span class="hljs-symbol">:location_h</span> =&gt; <span class="hljs-number">50</span>, <span class="hljs-symbol">:page</span> =&gt; <span class="hljs-number">1</span>}
529
+ field1.name = <span class="hljs-string">'singlIndex1'</span></pre></div></div>
530
+
531
+ </li>
532
+
533
+
534
+ <li id="section-32">
535
+ <div class="annotation">
536
+
537
+ <div class="pilwrap ">
538
+ <a class="pilcrow" href="#section-32">&#182;</a>
539
+ </div>
540
+ <p>Add field to envelope</p>
541
+
542
+ </div>
543
+
544
+ <div class="content"><div class='highlight'><pre> envelope.add_field!(field1, document[<span class="hljs-number">0</span>], first_recipient, {})</pre></div></div>
545
+
546
+ </li>
547
+
548
+
549
+ <li id="section-33">
550
+ <div class="annotation">
551
+
552
+ <div class="pilwrap ">
553
+ <a class="pilcrow" href="#section-33">&#182;</a>
554
+ </div>
555
+ <p>Get field and add the location to field</p>
556
+
557
+ </div>
558
+
559
+ <div class="content"><div class='highlight'><pre> field2 = <span class="hljs-constant">GroupDocs::Signature::Field</span>.get!({}).detect { |f| f.type == <span class="hljs-symbol">:signature</span> }
560
+ field2.location = {<span class="hljs-symbol">:location_x</span> =&gt; <span class="hljs-number">0</span>.<span class="hljs-number">35</span>, <span class="hljs-symbol">:location_y</span> =&gt; <span class="hljs-number">0</span>.<span class="hljs-number">23</span>, <span class="hljs-symbol">:location_w</span> =&gt; <span class="hljs-number">150</span>, <span class="hljs-symbol">:location_h</span> =&gt; <span class="hljs-number">50</span>, <span class="hljs-symbol">:page</span> =&gt; <span class="hljs-number">1</span>}
561
+ field2.name = <span class="hljs-string">'singlIndex2'</span></pre></div></div>
562
+
563
+ </li>
564
+
565
+
566
+ <li id="section-34">
567
+ <div class="annotation">
568
+
569
+ <div class="pilwrap ">
570
+ <a class="pilcrow" href="#section-34">&#182;</a>
571
+ </div>
572
+ <p>Add field to envelope</p>
573
+
574
+ </div>
575
+
576
+ <div class="content"><div class='highlight'><pre> envelope.add_field!(field2, document[<span class="hljs-number">0</span>], second_recipient, {})</pre></div></div>
577
+
578
+ </li>
579
+
580
+
581
+ <li id="section-35">
582
+ <div class="annotation">
583
+
584
+ <div class="pilwrap ">
585
+ <a class="pilcrow" href="#section-35">&#182;</a>
586
+ </div>
587
+ <p>Send envelop</p>
588
+
589
+ </div>
590
+
591
+ <div class="content"><div class='highlight'><pre> envelope.send!()</pre></div></div>
592
+
593
+ </li>
594
+
595
+
596
+ <li id="section-36">
597
+ <div class="annotation">
598
+
599
+ <div class="pilwrap ">
600
+ <a class="pilcrow" href="#section-36">&#182;</a>
601
+ </div>
602
+ <p>Prepare to sign first url</p>
603
+
604
+ </div>
605
+
606
+ <div class="content"><div class='highlight'><pre> first_iframe = <span class="hljs-string">"/signature2/signembed/<span class="hljs-subst">#{envelope.id}</span>/<span class="hljs-subst">#{first_recipient.id}</span>"</span></pre></div></div>
607
+
608
+ </li>
609
+
610
+
611
+ <li id="section-37">
612
+ <div class="annotation">
613
+
614
+ <div class="pilwrap ">
615
+ <a class="pilcrow" href="#section-37">&#182;</a>
616
+ </div>
617
+ <p>Construct result string</p>
618
+
619
+ </div>
620
+
621
+ <div class="content"><div class='highlight'><pre> first_url = <span class="hljs-constant">GroupDocs::Api::Request</span>.new(<span class="hljs-symbol">:path</span> =&gt; first_iframe).prepare_and_sign_url</pre></div></div>
622
+
623
+ </li>
624
+
625
+
626
+ <li id="section-38">
627
+ <div class="annotation">
628
+
629
+ <div class="pilwrap ">
630
+ <a class="pilcrow" href="#section-38">&#182;</a>
631
+ </div>
632
+ <p>Prepare to sign second url</p>
633
+
634
+ </div>
635
+
636
+ <div class="content"><div class='highlight'><pre> second_iframe = <span class="hljs-string">"/signature2/signembed/<span class="hljs-subst">#{envelope.id}</span>/<span class="hljs-subst">#{second_recipient.id}</span>"</span></pre></div></div>
637
+
638
+ </li>
639
+
640
+
641
+ <li id="section-39">
642
+ <div class="annotation">
643
+
644
+ <div class="pilwrap ">
645
+ <a class="pilcrow" href="#section-39">&#182;</a>
646
+ </div>
647
+ <p>Construct result string</p>
648
+
649
+ </div>
650
+
651
+ <div class="content"><div class='highlight'><pre> second_url = <span class="hljs-constant">GroupDocs::Api::Request</span>.new(<span class="hljs-symbol">:path</span> =&gt; second_iframe).prepare_and_sign_url</pre></div></div>
652
+
653
+ </li>
654
+
655
+
656
+ <li id="section-40">
657
+ <div class="annotation">
658
+
659
+ <div class="pilwrap ">
660
+ <a class="pilcrow" href="#section-40">&#182;</a>
661
+ </div>
662
+ <p>Generate iframes URL</p>
663
+
664
+ </div>
665
+
666
+ <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">case</span> base_path
667
+ <span class="hljs-keyword">when</span> <span class="hljs-string">'https://stage-api-groupdocs.dynabic.com'</span>
668
+ first_iframe = <span class="hljs-string">"https://stage-api-groupdocs.dynabic.com<span class="hljs-subst">#{first_url}</span>"</span>
669
+ second_iframe = <span class="hljs-string">"https://stage-api-groupdocs.dynabic.com<span class="hljs-subst">#{second_url}</span>"</span>
670
+ <span class="hljs-keyword">when</span> <span class="hljs-string">'https://dev-api-groupdocs.dynabic.com'</span>
671
+ first_iframe = <span class="hljs-string">"https://dev-apps.groupdocs.com<span class="hljs-subst">#{first_url}</span>"</span>
672
+ second_iframe = <span class="hljs-string">"https://dev-apps.groupdocs.com<span class="hljs-subst">#{second_url}</span>"</span>
673
+ <span class="hljs-keyword">else</span>
674
+ first_iframe = <span class="hljs-string">"https://apps.groupdocs.com<span class="hljs-subst">#{first_url}</span>"</span>
675
+ second_iframe = <span class="hljs-string">"https://apps.groupdocs.com<span class="hljs-subst">#{second_url}</span>"</span>
676
+ <span class="hljs-keyword">end</span></pre></div></div>
677
+
678
+ </li>
679
+
680
+
681
+ <li id="section-41">
682
+ <div class="annotation">
683
+
684
+ <div class="pilwrap ">
685
+ <a class="pilcrow" href="#section-41">&#182;</a>
686
+ </div>
687
+ <p>Set iframe with document GUID or raise an error</p>
688
+
689
+ </div>
690
+
691
+ <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> guid</pre></div></div>
692
+
693
+ </li>
694
+
695
+
696
+ <li id="section-42">
697
+ <div class="annotation">
698
+
699
+ <div class="pilwrap ">
700
+ <a class="pilcrow" href="#section-42">&#182;</a>
701
+ </div>
702
+ <p>Make first iframe</p>
703
+
704
+ </div>
705
+
706
+ <div class="content"><div class='highlight'><pre> first_iframe = <span class="hljs-string">"&lt;p&gt;&lt;span style=\"color: green\"&gt;Document for first signer&lt;/span&gt;&lt;/p&gt;&lt;iframe id='downloadframe' src='<span class="hljs-subst">#{first_iframe}</span>' width='800' height='1000'&gt;&lt;/iframe&gt;&lt;br&gt;"</span></pre></div></div>
707
+
708
+ </li>
709
+
710
+
711
+ <li id="section-43">
712
+ <div class="annotation">
713
+
714
+ <div class="pilwrap ">
715
+ <a class="pilcrow" href="#section-43">&#182;</a>
716
+ </div>
717
+ <p>Make second iframe</p>
718
+
719
+ </div>
720
+
721
+ <div class="content"><div class='highlight'><pre> second_iframe = <span class="hljs-string">"&lt;p&gt;&lt;span style=\"color: green\"&gt;Document for second signer&lt;/span&gt;&lt;/p&gt;&lt;iframe id='downloadframe' src='<span class="hljs-subst">#{second_iframe}</span>' width='800' height='1000'&gt;&lt;/iframe&gt;"</span>
722
+ <span class="hljs-keyword">else</span>
723
+ raise <span class="hljs-string">'File was not converted'</span>
724
+ <span class="hljs-keyword">end</span>
725
+
726
+ <span class="hljs-keyword">rescue</span> <span class="hljs-constant">Exception</span> =&gt; e
727
+ err = e.message
728
+ <span class="hljs-keyword">end</span></pre></div></div>
729
+
730
+ </li>
731
+
732
+
733
+ <li id="section-44">
734
+ <div class="annotation">
735
+
736
+ <div class="pilwrap ">
737
+ <a class="pilcrow" href="#section-44">&#182;</a>
738
+ </div>
739
+ <p>Set variables for template</p>
740
+
741
+ </div>
742
+
743
+ <div class="content"><div class='highlight'><pre> haml <span class="hljs-symbol">:sample44</span>, <span class="hljs-symbol">:locals</span> =&gt; {<span class="hljs-symbol">:userId</span> =&gt; settings.client_id, <span class="hljs-symbol">:privateKey</span> =&gt; settings.private_key, <span class="hljs-symbol">:first_iframe</span> =&gt; first_iframe, <span class="hljs-symbol">:second_iframe</span> =&gt; second_iframe, <span class="hljs-symbol">:err</span> =&gt; err}
744
+ <span class="hljs-keyword">end</span></pre></div></div>
745
+
746
+ </li>
747
+
748
+ </ul>
749
+ </div>
750
+ </body>
751
+ </html>