groupdocs 1.5.7 → 1.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/CHANGELOG.md +51 -0
  2. data/examples/api-samples/Gemfile +1 -1
  3. data/examples/api-samples/Gemfile.lock +43 -0
  4. data/examples/api-samples/public/docs/{sample2.html → sample01.html} +39 -19
  5. data/examples/api-samples/public/docs/{sample3.html → sample02.html} +28 -22
  6. data/examples/api-samples/public/docs/sample03.html +285 -0
  7. data/examples/api-samples/public/docs/{sample4.html → sample04.html} +30 -36
  8. data/examples/api-samples/public/docs/{sample5.html → sample05.html} +68 -31
  9. data/examples/api-samples/public/docs/sample06.html +299 -0
  10. data/examples/api-samples/public/docs/{sample7.html → sample07.html} +53 -18
  11. data/examples/api-samples/public/docs/{sample8.html → sample08.html} +64 -41
  12. data/examples/api-samples/public/docs/sample09.html +260 -0
  13. data/examples/api-samples/public/docs/sample10.html +67 -28
  14. data/examples/api-samples/public/docs/sample11.html +171 -55
  15. data/examples/api-samples/public/docs/sample12.html +53 -17
  16. data/examples/api-samples/public/docs/sample13.html +52 -16
  17. data/examples/api-samples/public/docs/sample14.html +51 -8
  18. data/examples/api-samples/public/docs/sample15.html +46 -10
  19. data/examples/api-samples/public/docs/sample16.html +81 -7
  20. data/examples/api-samples/public/docs/sample17.html +103 -15
  21. data/examples/api-samples/public/docs/sample18.html +117 -41
  22. data/examples/api-samples/public/docs/sample19.html +410 -36
  23. data/examples/api-samples/public/docs/sample20.html +46 -10
  24. data/examples/api-samples/public/docs/sample21.html +504 -45
  25. data/examples/api-samples/public/docs/sample22.html +166 -28
  26. data/examples/api-samples/public/docs/sample23.html +61 -25
  27. data/examples/api-samples/public/docs/sample24.html +100 -12
  28. data/examples/api-samples/public/docs/sample25.html +123 -49
  29. data/examples/api-samples/public/docs/sample26.html +41 -8
  30. data/examples/api-samples/public/docs/sample27.html +125 -50
  31. data/examples/api-samples/public/docs/sample28.html +27 -9
  32. data/examples/api-samples/public/docs/sample29.html +10 -10
  33. data/examples/api-samples/public/docs/sample30.html +70 -14
  34. data/examples/api-samples/public/docs/sample31.html +108 -67
  35. data/examples/api-samples/public/docs/sample32.html +71 -99
  36. data/examples/api-samples/public/docs/sample33.html +107 -32
  37. data/examples/api-samples/public/docs/{sample1.html → sample34.html} +58 -18
  38. data/examples/api-samples/public/docs/sample35.html +666 -0
  39. data/examples/api-samples/public/docs/{sample6.html → sample36.html} +56 -37
  40. data/examples/api-samples/public/docs/sample37.html +815 -0
  41. data/examples/api-samples/public/docs/sample38.html +508 -0
  42. data/examples/api-samples/public/docs/sample39.html +921 -0
  43. data/examples/api-samples/public/docs/sample40.html +510 -0
  44. data/examples/api-samples/public/docs/sample41.html +452 -0
  45. data/examples/api-samples/public/docs/sample42.html +311 -0
  46. data/examples/api-samples/public/templates/test_all_fields2.pdf +0 -0
  47. data/examples/api-samples/samples/sample01.rb +37 -0
  48. data/examples/api-samples/samples/sample02.rb +41 -0
  49. data/examples/api-samples/samples/sample03.rb +73 -0
  50. data/examples/api-samples/samples/sample04.rb +47 -0
  51. data/examples/api-samples/samples/{sample5.rb → sample05.rb} +26 -14
  52. data/examples/api-samples/samples/sample06.rb +80 -0
  53. data/examples/api-samples/samples/sample07.rb +52 -0
  54. data/examples/api-samples/samples/sample08.rb +69 -0
  55. data/examples/api-samples/samples/sample09.rb +83 -0
  56. data/examples/api-samples/samples/sample10.rb +29 -15
  57. data/examples/api-samples/samples/sample11.rb +89 -37
  58. data/examples/api-samples/samples/sample12.rb +22 -11
  59. data/examples/api-samples/samples/sample13.rb +22 -10
  60. data/examples/api-samples/samples/sample14.rb +23 -5
  61. data/examples/api-samples/samples/sample15.rb +18 -7
  62. data/examples/api-samples/samples/sample16.rb +28 -4
  63. data/examples/api-samples/samples/sample17.rb +31 -5
  64. data/examples/api-samples/samples/sample18.rb +36 -8
  65. data/examples/api-samples/samples/sample19.rb +138 -18
  66. data/examples/api-samples/samples/sample20.rb +14 -3
  67. data/examples/api-samples/samples/sample21.rb +162 -23
  68. data/examples/api-samples/samples/sample22.rb +73 -22
  69. data/examples/api-samples/samples/sample23.rb +17 -6
  70. data/examples/api-samples/samples/sample24.rb +34 -7
  71. data/examples/api-samples/samples/sample25.rb +37 -12
  72. data/examples/api-samples/samples/sample26.rb +12 -5
  73. data/examples/api-samples/samples/sample27.rb +38 -12
  74. data/examples/api-samples/samples/sample28.rb +25 -6
  75. data/examples/api-samples/samples/sample29.rb +12 -12
  76. data/examples/api-samples/samples/sample30.rb +27 -15
  77. data/examples/api-samples/samples/sample31.rb +44 -33
  78. data/examples/api-samples/samples/sample32.rb +43 -41
  79. data/examples/api-samples/samples/sample33.rb +42 -14
  80. data/examples/api-samples/samples/sample34.rb +40 -0
  81. data/examples/api-samples/samples/sample35.rb +224 -0
  82. data/examples/api-samples/samples/sample36.rb +58 -0
  83. data/examples/api-samples/samples/sample37.rb +229 -0
  84. data/examples/api-samples/samples/sample38.rb +128 -0
  85. data/examples/api-samples/samples/sample39.rb +252 -0
  86. data/examples/api-samples/samples/sample40.rb +164 -0
  87. data/examples/api-samples/samples/sample41.rb +118 -0
  88. data/examples/api-samples/samples/sample42.rb +97 -0
  89. data/examples/api-samples/views/_others_samples.haml +25 -11
  90. data/examples/api-samples/views/index.haml +23 -11
  91. data/examples/api-samples/views/popup.haml +32 -0
  92. data/examples/api-samples/views/{sample1.haml → sample01.haml} +12 -7
  93. data/examples/api-samples/views/{sample2.haml → sample02.haml} +20 -15
  94. data/examples/api-samples/views/sample03.haml +83 -0
  95. data/examples/api-samples/views/sample04.haml +49 -0
  96. data/examples/api-samples/views/{sample5.haml → sample05.haml} +19 -14
  97. data/examples/api-samples/views/sample06.haml +53 -0
  98. data/examples/api-samples/views/sample07.haml +47 -0
  99. data/examples/api-samples/views/{sample8.haml → sample08.haml} +17 -12
  100. data/examples/api-samples/views/{sample9.haml → sample09.haml} +19 -4
  101. data/examples/api-samples/views/sample10.haml +18 -13
  102. data/examples/api-samples/views/sample11.haml +48 -19
  103. data/examples/api-samples/views/sample12.haml +26 -21
  104. data/examples/api-samples/views/sample13.haml +18 -12
  105. data/examples/api-samples/views/sample14.haml +21 -15
  106. data/examples/api-samples/views/sample15.haml +16 -9
  107. data/examples/api-samples/views/sample16.haml +18 -5
  108. data/examples/api-samples/views/sample17.haml +14 -9
  109. data/examples/api-samples/views/sample18.haml +13 -7
  110. data/examples/api-samples/views/sample19.haml +37 -8
  111. data/examples/api-samples/views/sample20.haml +13 -8
  112. data/examples/api-samples/views/sample21.haml +71 -13
  113. data/examples/api-samples/views/sample22.haml +53 -16
  114. data/examples/api-samples/views/sample23.haml +9 -4
  115. data/examples/api-samples/views/sample24.haml +9 -4
  116. data/examples/api-samples/views/sample25.haml +18 -13
  117. data/examples/api-samples/views/sample26.haml +8 -3
  118. data/examples/api-samples/views/sample27.haml +20 -14
  119. data/examples/api-samples/views/sample28.haml +16 -10
  120. data/examples/api-samples/views/sample29.haml +4 -4
  121. data/examples/api-samples/views/sample30.haml +16 -10
  122. data/examples/api-samples/views/sample31.haml +39 -32
  123. data/examples/api-samples/views/sample32.haml +25 -36
  124. data/examples/api-samples/views/sample33.haml +14 -17
  125. data/examples/api-samples/views/sample34.haml +48 -0
  126. data/examples/api-samples/views/sample35.haml +95 -0
  127. data/examples/api-samples/views/sample36.haml +64 -0
  128. data/examples/api-samples/views/sample37.haml +124 -0
  129. data/examples/api-samples/views/sample38.haml +115 -0
  130. data/examples/api-samples/views/sample39.haml +236 -0
  131. data/examples/api-samples/views/sample40.haml +95 -0
  132. data/examples/api-samples/views/{sample4.haml → sample41.haml} +90 -72
  133. data/examples/api-samples/views/sample42.haml +59 -0
  134. data/lib/groupdocs/api/helpers/rest_helper.rb +13 -1
  135. data/lib/groupdocs/datasource.rb +2 -1
  136. data/lib/groupdocs/document.rb +101 -13
  137. data/lib/groupdocs/document/annotation.rb +28 -13
  138. data/lib/groupdocs/document/annotation/marker.rb +18 -0
  139. data/lib/groupdocs/document/annotation/reply.rb +9 -2
  140. data/lib/groupdocs/document/field.rb +5 -1
  141. data/lib/groupdocs/job.rb +12 -2
  142. data/lib/groupdocs/questionnaire.rb +174 -4
  143. data/lib/groupdocs/questionnaire/collector.rb +21 -0
  144. data/lib/groupdocs/questionnaire/question.rb +19 -0
  145. data/lib/groupdocs/questionnaire/question/answer.rb +5 -0
  146. data/lib/groupdocs/questionnaire/question/conditions.rb +20 -0
  147. data/lib/groupdocs/signature.rb +36 -308
  148. data/lib/groupdocs/signature/envelope.rb +146 -4
  149. data/lib/groupdocs/signature/field.rb +20 -1
  150. data/lib/groupdocs/signature/field/location.rb +18 -7
  151. data/lib/groupdocs/signature/form.rb +199 -10
  152. data/lib/groupdocs/signature/shared/document_methods.rb +38 -0
  153. data/lib/groupdocs/signature/shared/entity_methods.rb +0 -1
  154. data/lib/groupdocs/signature/shared/field_methods.rb +13 -38
  155. data/lib/groupdocs/signature/shared/recipient_methods.rb +8 -0
  156. data/lib/groupdocs/signature/template.rb +3 -1
  157. data/lib/groupdocs/storage.rb +4 -1
  158. data/lib/groupdocs/storage/file.rb +18 -1
  159. data/lib/groupdocs/subscription.rb +8 -3
  160. data/lib/groupdocs/user.rb +8 -0
  161. data/lib/groupdocs/version.rb +1 -1
  162. data/spec/groupdocs/document/annotation_spec.rb +1 -14
  163. data/spec/groupdocs/subscription_spec.rb +2 -2
  164. metadata +86 -32
  165. checksums.yaml +0 -15
  166. data/examples/api-samples/public/docs/sample9.html +0 -200
  167. data/examples/api-samples/samples/sample1.rb +0 -25
  168. data/examples/api-samples/samples/sample2.rb +0 -29
  169. data/examples/api-samples/samples/sample3.rb +0 -33
  170. data/examples/api-samples/samples/sample4.rb +0 -51
  171. data/examples/api-samples/samples/sample6.rb +0 -49
  172. data/examples/api-samples/samples/sample7.rb +0 -42
  173. data/examples/api-samples/samples/sample8.rb +0 -61
  174. data/examples/api-samples/samples/sample9.rb +0 -48
  175. data/examples/api-samples/views/sample3.haml +0 -44
  176. data/examples/api-samples/views/sample6.haml +0 -49
  177. data/examples/api-samples/views/sample7.haml +0 -42
@@ -0,0 +1,921 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>sample39.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>sample39.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="string">'/sample39'</span> <span class="keyword">do</span>
35
+ haml <span class="symbol">:sample39</span>
36
+ <span class="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>GET request</p>
48
+
49
+ </div>
50
+
51
+ <div class="content"><div class='highlight'><pre>get <span class="string">'/popup'</span> <span class="keyword">do</span>
52
+ haml <span class="symbol">:popup</span>
53
+ <span class="keyword">end</span></pre></div></div>
54
+
55
+ </li>
56
+
57
+
58
+ <li id="section-3">
59
+ <div class="annotation">
60
+
61
+ <div class="pilwrap ">
62
+ <a class="pilcrow" href="#section-3">&#182;</a>
63
+ </div>
64
+ <p>POST request</p>
65
+
66
+ </div>
67
+
68
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample39/signature_callback'</span> <span class="keyword">do</span>
69
+ <span class="keyword">begin</span></pre></div></div>
70
+
71
+ </li>
72
+
73
+
74
+ <li id="section-4">
75
+ <div class="annotation">
76
+
77
+ <div class="pilwrap ">
78
+ <a class="pilcrow" href="#section-4">&#182;</a>
79
+ </div>
80
+ <p>Get callback request</p>
81
+
82
+ </div>
83
+
84
+ <div class="content"><div class='highlight'><pre> data = <span class="constant">JSON</span>.parse(request.body.read)
85
+
86
+ raise <span class="string">'Empty params!'</span> <span class="keyword">if</span> data.empty?
87
+ source_id = <span class="keyword">nil</span>
88
+ client_id = <span class="keyword">nil</span>
89
+ private_key = <span class="keyword">nil</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>Get value of SourceId</p>
101
+
102
+ </div>
103
+
104
+ <div class="content"><div class='highlight'><pre> data.each <span class="keyword">do</span> |key, value|
105
+ <span class="keyword">if</span> key == <span class="string">'SourceId'</span>
106
+ source_id = value
107
+ <span class="keyword">end</span>
108
+ <span class="keyword">end</span></pre></div></div>
109
+
110
+ </li>
111
+
112
+
113
+ <li id="section-6">
114
+ <div class="annotation">
115
+
116
+ <div class="pilwrap ">
117
+ <a class="pilcrow" href="#section-6">&#182;</a>
118
+ </div>
119
+ <p>Get private key and client_id from file user_info.txt</p>
120
+
121
+ </div>
122
+
123
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> <span class="constant">File</span>.exist?(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/user_info.txt"</span>)
124
+ contents = <span class="constant">File</span>.read(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/user_info.txt"</span>)
125
+ contents = contents.split(<span class="string">' '</span>)
126
+ client_id = contents.first
127
+ private_key = contents.last
128
+ <span class="keyword">end</span></pre></div></div>
129
+
130
+ </li>
131
+
132
+
133
+ <li id="section-7">
134
+ <div class="annotation">
135
+
136
+ <div class="pilwrap ">
137
+ <a class="pilcrow" href="#section-7">&#182;</a>
138
+ </div>
139
+ <p>Create Job instance</p>
140
+
141
+ </div>
142
+
143
+ <div class="content"><div class='highlight'><pre> job = <span class="constant">GroupDocs::Signature::Envelope</span>.new({<span class="symbol">:id</span> =&gt; source_id})</pre></div></div>
144
+
145
+ </li>
146
+
147
+
148
+ <li id="section-8">
149
+ <div class="annotation">
150
+
151
+ <div class="pilwrap ">
152
+ <a class="pilcrow" href="#section-8">&#182;</a>
153
+ </div>
154
+ <p>Get document by job id</p>
155
+
156
+ </div>
157
+
158
+ <div class="content"><div class='highlight'><pre> documents = job.documents!({}, {<span class="symbol">:client_id</span> =&gt; client_id, <span class="symbol">:private_key</span> =&gt; private_key}).first</pre></div></div>
159
+
160
+ </li>
161
+
162
+
163
+ <li id="section-9">
164
+ <div class="annotation">
165
+
166
+ <div class="pilwrap ">
167
+ <a class="pilcrow" href="#section-9">&#182;</a>
168
+ </div>
169
+ <p>Get guid from file</p>
170
+
171
+ </div>
172
+
173
+ <div class="content"><div class='highlight'><pre> guid = documents.file.guid</pre></div></div>
174
+
175
+ </li>
176
+
177
+
178
+ <li id="section-10">
179
+ <div class="annotation">
180
+
181
+ <div class="pilwrap ">
182
+ <a class="pilcrow" href="#section-10">&#182;</a>
183
+ </div>
184
+ <p>Create new file callback_info.txt and write the guid document</p>
185
+
186
+ </div>
187
+
188
+ <div class="content"><div class='highlight'><pre> out_file = <span class="constant">File</span>.new(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/callback_info.txt"</span>, <span class="string">'w'</span>)</pre></div></div>
189
+
190
+ </li>
191
+
192
+
193
+ <li id="section-11">
194
+ <div class="annotation">
195
+
196
+ <div class="pilwrap ">
197
+ <a class="pilcrow" href="#section-11">&#182;</a>
198
+ </div>
199
+ <p>White space is required</p>
200
+
201
+ </div>
202
+
203
+ <div class="content"><div class='highlight'><pre> out_file.write(<span class="string">"<span class="subst">#{guid}</span>"</span>)
204
+ out_file.close
205
+
206
+ <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e
207
+ err = e.message
208
+ <span class="keyword">end</span>
209
+ <span class="keyword">end</span></pre></div></div>
210
+
211
+ </li>
212
+
213
+
214
+ <li id="section-12">
215
+ <div class="annotation">
216
+
217
+ <div class="pilwrap ">
218
+ <a class="pilcrow" href="#section-12">&#182;</a>
219
+ </div>
220
+ <p>POST request</p>
221
+
222
+ </div>
223
+
224
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample39/check'</span> <span class="keyword">do</span>
225
+ <span class="keyword">begin</span>
226
+ result = <span class="keyword">nil</span>
227
+ i = <span class="number">0</span>
228
+ <span class="keyword">for</span> i <span class="keyword">in</span> <span class="number">1</span>..<span class="number">10</span>
229
+ i +=<span class="number">1</span></pre></div></div>
230
+
231
+ </li>
232
+
233
+
234
+ <li id="section-13">
235
+ <div class="annotation">
236
+
237
+ <div class="pilwrap ">
238
+ <a class="pilcrow" href="#section-13">&#182;</a>
239
+ </div>
240
+ <p>Check is downloads folder exist</p>
241
+
242
+ </div>
243
+
244
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> <span class="constant">File</span>.exist?(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/callback_info.txt"</span>)
245
+ result = <span class="constant">File</span>.read(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/callback_info.txt"</span>)
246
+ <span class="keyword">if</span> result.<span class="keyword">nil</span>? <span class="keyword">then</span> <span class="keyword">break</span> <span class="keyword">end</span>
247
+ <span class="keyword">end</span>
248
+ sleep(<span class="number">5</span>)
249
+ <span class="keyword">end</span></pre></div></div>
250
+
251
+ </li>
252
+
253
+
254
+ <li id="section-14">
255
+ <div class="annotation">
256
+
257
+ <div class="pilwrap ">
258
+ <a class="pilcrow" href="#section-14">&#182;</a>
259
+ </div>
260
+ <p>Check result</p>
261
+
262
+ </div>
263
+
264
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> result == <span class="string">'Error'</span>
265
+ result = <span class="string">"File was not found. Looks like something went wrong."</span>
266
+ <span class="keyword">else</span>
267
+ result
268
+ <span class="keyword">end</span>
269
+
270
+ <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e
271
+ err = e.message
272
+ <span class="keyword">end</span>
273
+ <span class="keyword">end</span></pre></div></div>
274
+
275
+ </li>
276
+
277
+
278
+ <li id="section-15">
279
+ <div class="annotation">
280
+
281
+ <div class="pilwrap ">
282
+ <a class="pilcrow" href="#section-15">&#182;</a>
283
+ </div>
284
+ <p>POST request</p>
285
+
286
+ </div>
287
+
288
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample39/postdata'</span> <span class="keyword">do</span>
289
+
290
+ data = request.body.read</pre></div></div>
291
+
292
+ </li>
293
+
294
+
295
+ <li id="section-16">
296
+ <div class="annotation">
297
+
298
+ <div class="pilwrap ">
299
+ <a class="pilcrow" href="#section-16">&#182;</a>
300
+ </div>
301
+ <p>Decode ajax data</p>
302
+
303
+ </div>
304
+
305
+ <div class="content"><div class='highlight'><pre> json_post_data = <span class="constant">JSON</span>.parse(data);</pre></div></div>
306
+
307
+ </li>
308
+
309
+
310
+ <li id="section-17">
311
+ <div class="annotation">
312
+
313
+ <div class="pilwrap ">
314
+ <a class="pilcrow" href="#section-17">&#182;</a>
315
+ </div>
316
+ <p>Get Client ID</p>
317
+
318
+ </div>
319
+
320
+ <div class="content"><div class='highlight'><pre> clientId = json_post_data[<span class="string">'userId'</span>];</pre></div></div>
321
+
322
+ </li>
323
+
324
+
325
+ <li id="section-18">
326
+ <div class="annotation">
327
+
328
+ <div class="pilwrap ">
329
+ <a class="pilcrow" href="#section-18">&#182;</a>
330
+ </div>
331
+ <p>Get Private Key</p>
332
+
333
+ </div>
334
+
335
+ <div class="content"><div class='highlight'><pre> privateKey = json_post_data[<span class="string">'privateKey'</span>];</pre></div></div>
336
+
337
+ </li>
338
+
339
+
340
+ <li id="section-19">
341
+ <div class="annotation">
342
+
343
+ <div class="pilwrap ">
344
+ <a class="pilcrow" href="#section-19">&#182;</a>
345
+ </div>
346
+ <p>Get document for sign</p>
347
+
348
+ </div>
349
+
350
+ <div class="content"><div class='highlight'><pre> documents = json_post_data[<span class="string">'documents'</span>];</pre></div></div>
351
+
352
+ </li>
353
+
354
+
355
+ <li id="section-20">
356
+ <div class="annotation">
357
+
358
+ <div class="pilwrap ">
359
+ <a class="pilcrow" href="#section-20">&#182;</a>
360
+ </div>
361
+ <p>Get signature file</p>
362
+
363
+ </div>
364
+
365
+ <div class="content"><div class='highlight'><pre> signers = json_post_data[<span class="string">'signers'</span>];</pre></div></div>
366
+
367
+ </li>
368
+
369
+
370
+ <li id="section-21">
371
+ <div class="annotation">
372
+
373
+ <div class="pilwrap ">
374
+ <a class="pilcrow" href="#section-21">&#182;</a>
375
+ </div>
376
+ <p>Documents local path</p>
377
+
378
+ </div>
379
+
380
+ <div class="content"><div class='highlight'><pre> document_path = <span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/downloads/<span class="subst">#{documents[<span class="number">0</span>][<span class="string">'name'</span>]}</span>"</span>
381
+ signer_path = <span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/downloads/<span class="subst">#{signers[<span class="number">0</span>][<span class="string">'name'</span>]}</span>.png"</span></pre></div></div>
382
+
383
+ </li>
384
+
385
+
386
+ <li id="section-22">
387
+ <div class="annotation">
388
+
389
+ <div class="pilwrap ">
390
+ <a class="pilcrow" href="#section-22">&#182;</a>
391
+ </div>
392
+ <p>Get base64 string</p>
393
+
394
+ </div>
395
+
396
+ <div class="content"><div class='highlight'><pre> base64_documents = documents[<span class="number">0</span>][<span class="string">'data'</span>].split(<span class="string">','</span>).last
397
+ base64_signers = signers[<span class="number">0</span>][<span class="string">'data'</span>].split(<span class="string">','</span>).last</pre></div></div>
398
+
399
+ </li>
400
+
401
+
402
+ <li id="section-23">
403
+ <div class="annotation">
404
+
405
+ <div class="pilwrap ">
406
+ <a class="pilcrow" href="#section-23">&#182;</a>
407
+ </div>
408
+ <p>Write to the files decode base64 strings</p>
409
+
410
+ </div>
411
+
412
+ <div class="content"><div class='highlight'><pre> <span class="constant">File</span>.open(document_path, <span class="string">'wb'</span>) <span class="keyword">do</span> |f|
413
+ f.write(<span class="constant">Base64</span>.strict_decode64(base64_documents))
414
+ <span class="keyword">end</span>
415
+
416
+ <span class="constant">File</span>.open(signer_path, <span class="string">'wb'</span>) <span class="keyword">do</span> |f|
417
+ f.write(<span class="constant">Base64</span>.strict_decode64(base64_signers))
418
+ <span class="keyword">end</span></pre></div></div>
419
+
420
+ </li>
421
+
422
+
423
+ <li id="section-24">
424
+ <div class="annotation">
425
+
426
+ <div class="pilwrap ">
427
+ <a class="pilcrow" href="#section-24">&#182;</a>
428
+ </div>
429
+ <p>Set document for signing</p>
430
+
431
+ </div>
432
+
433
+ <div class="content"><div class='highlight'><pre> documents = <span class="constant">GroupDocs::Storage::File</span>.new(<span class="symbol">:name=&gt;documents</span>[<span class="number">0</span>][<span class="string">'name'</span>], <span class="symbol">:local_path=&gt;document_path</span>).to_document</pre></div></div>
434
+
435
+ </li>
436
+
437
+
438
+ <li id="section-25">
439
+ <div class="annotation">
440
+
441
+ <div class="pilwrap ">
442
+ <a class="pilcrow" href="#section-25">&#182;</a>
443
+ </div>
444
+ <p>Set signature</p>
445
+
446
+ </div>
447
+
448
+ <div class="content"><div class='highlight'><pre> signers = <span class="constant">GroupDocs::Signature</span>.new(<span class="symbol">:name=&gt;signers</span>[<span class="number">0</span>][<span class="string">'name'</span>], <span class="symbol">:image_path=&gt;signer_path</span>)
449
+ signers.position = {<span class="symbol">top:</span> <span class="number">0</span>.<span class="number">83319</span>, <span class="symbol">left:</span> <span class="number">0</span>.<span class="number">72171</span>, <span class="symbol">width:</span> <span class="number">100</span>, <span class="symbol">height:</span> <span class="number">40</span>}</pre></div></div>
450
+
451
+ </li>
452
+
453
+
454
+ <li id="section-26">
455
+ <div class="annotation">
456
+
457
+ <div class="pilwrap ">
458
+ <a class="pilcrow" href="#section-26">&#182;</a>
459
+ </div>
460
+ <p>Make request to sign documnet</p>
461
+
462
+ </div>
463
+
464
+ <div class="content"><div class='highlight'><pre> signDocument = <span class="constant">GroupDocs::Document</span>.sign_documents!([documents], [signers], {}, {<span class="symbol">:client_id=&gt;clientId</span>, <span class="symbol">:private_key=&gt;privateKey</span>})
465
+ sleep(<span class="number">5</span>)</pre></div></div>
466
+
467
+ </li>
468
+
469
+
470
+ <li id="section-27">
471
+ <div class="annotation">
472
+
473
+ <div class="pilwrap ">
474
+ <a class="pilcrow" href="#section-27">&#182;</a>
475
+ </div>
476
+ <p>Get the document guid</p>
477
+
478
+ </div>
479
+
480
+ <div class="content"><div class='highlight'><pre> document = <span class="constant">GroupDocs::Signature</span>.sign_document_status!(signDocument, {<span class="symbol">:client_id=&gt;clientId</span>, <span class="symbol">:private_key=&gt;privateKey</span>})</pre></div></div>
481
+
482
+ </li>
483
+
484
+
485
+ <li id="section-28">
486
+ <div class="annotation">
487
+
488
+ <div class="pilwrap ">
489
+ <a class="pilcrow" href="#section-28">&#182;</a>
490
+ </div>
491
+ <p>Get file GUID</p>
492
+
493
+ </div>
494
+
495
+ <div class="content"><div class='highlight'><pre> guid = document.guid</pre></div></div>
496
+
497
+ </li>
498
+
499
+
500
+ <li id="section-29">
501
+ <div class="annotation">
502
+
503
+ <div class="pilwrap ">
504
+ <a class="pilcrow" href="#section-29">&#182;</a>
505
+ </div>
506
+ <p>Create array with result data</p>
507
+
508
+ </div>
509
+
510
+ <div class="content"><div class='highlight'><pre> result = [<span class="string">'guid'</span> =&gt; guid,<span class="string">'clientId'</span> =&gt; clientId,<span class="string">'privateKey'</span> =&gt; privateKey]</pre></div></div>
511
+
512
+ </li>
513
+
514
+
515
+ <li id="section-30">
516
+ <div class="annotation">
517
+
518
+ <div class="pilwrap ">
519
+ <a class="pilcrow" href="#section-30">&#182;</a>
520
+ </div>
521
+ <p>Decode array to json and return json string to ajax request</p>
522
+
523
+ </div>
524
+
525
+ <div class="content"><div class='highlight'><pre> result.to_json
526
+ <span class="keyword">end</span></pre></div></div>
527
+
528
+ </li>
529
+
530
+
531
+ <li id="section-31">
532
+ <div class="annotation">
533
+
534
+ <div class="pilwrap ">
535
+ <a class="pilcrow" href="#section-31">&#182;</a>
536
+ </div>
537
+ <p>POST request</p>
538
+
539
+ </div>
540
+
541
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample39'</span> <span class="keyword">do</span></pre></div></div>
542
+
543
+ </li>
544
+
545
+
546
+ <li id="section-32">
547
+ <div class="annotation">
548
+
549
+ <div class="pilwrap ">
550
+ <a class="pilcrow" href="#section-32">&#182;</a>
551
+ </div>
552
+ <p>set variables</p>
553
+
554
+ </div>
555
+
556
+ <div class="content"><div class='highlight'><pre> set <span class="symbol">:client_id</span>, params[<span class="symbol">:clientId</span>]
557
+ set <span class="symbol">:private_key</span>, params[<span class="symbol">:privateKey</span>]
558
+ set <span class="symbol">:name</span>, params[<span class="symbol">:name</span>]
559
+ set <span class="symbol">:email</span>, params[<span class="symbol">:email</span>]
560
+ set <span class="symbol">:callback</span>, params[<span class="symbol">:callbackUrl</span>]
561
+ set <span class="symbol">:last_name</span>, params[<span class="symbol">:lastName</span>]</pre></div></div>
562
+
563
+ </li>
564
+
565
+
566
+ <li id="section-33">
567
+ <div class="annotation">
568
+
569
+ <div class="pilwrap ">
570
+ <a class="pilcrow" href="#section-33">&#182;</a>
571
+ </div>
572
+ <p>Set download path</p>
573
+
574
+ </div>
575
+
576
+ <div class="content"><div class='highlight'><pre> downloads_path = <span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/downloads"</span></pre></div></div>
577
+
578
+ </li>
579
+
580
+
581
+ <li id="section-34">
582
+ <div class="annotation">
583
+
584
+ <div class="pilwrap ">
585
+ <a class="pilcrow" href="#section-34">&#182;</a>
586
+ </div>
587
+ <p>Remove all files from download directory or create folder if it not there</p>
588
+
589
+ </div>
590
+
591
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> <span class="constant">File</span>.directory?(downloads_path)
592
+ <span class="constant">Dir</span>.foreach(downloads_path) { |f| fn = <span class="constant">File</span>.join(downloads_path, f); <span class="constant">File</span>.delete(fn) <span class="keyword">if</span> f != <span class="string">'.'</span> &amp;&amp; f != <span class="string">'..'</span> }
593
+ <span class="keyword">else</span>
594
+ <span class="constant">Dir::</span>mkdir(downloads_path)
595
+ <span class="keyword">end</span>
596
+
597
+ <span class="keyword">begin</span></pre></div></div>
598
+
599
+ </li>
600
+
601
+
602
+ <li id="section-35">
603
+ <div class="annotation">
604
+
605
+ <div class="pilwrap ">
606
+ <a class="pilcrow" href="#section-35">&#182;</a>
607
+ </div>
608
+ <p>check required variables</p>
609
+
610
+ </div>
611
+
612
+ <div class="content"><div class='highlight'><pre> raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> settings.client_id.empty? <span class="keyword">or</span> settings.private_key.empty? <span class="keyword">or</span> settings.name.empty? <span class="keyword">or</span> settings.email.empty? <span class="keyword">or</span> settings.last_name.empty?</pre></div></div>
613
+
614
+ </li>
615
+
616
+
617
+ <li id="section-36">
618
+ <div class="annotation">
619
+
620
+ <div class="pilwrap ">
621
+ <a class="pilcrow" href="#section-36">&#182;</a>
622
+ </div>
623
+ <p>Configure your access to API server</p>
624
+
625
+ </div>
626
+
627
+ <div class="content"><div class='highlight'><pre> <span class="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs|
628
+ groupdocs.client_id = settings.client_id
629
+ groupdocs.private_key = settings.private_key
630
+ <span class="keyword">end</span></pre></div></div>
631
+
632
+ </li>
633
+
634
+
635
+ <li id="section-37">
636
+ <div class="annotation">
637
+
638
+ <div class="pilwrap ">
639
+ <a class="pilcrow" href="#section-37">&#182;</a>
640
+ </div>
641
+ <p>Write client and private key to the file for callback job</p>
642
+
643
+ </div>
644
+
645
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.callback[<span class="number">0</span>]
646
+ out_file = <span class="constant">File</span>.new(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/user_info.txt"</span>, <span class="string">'w'</span>)</pre></div></div>
647
+
648
+ </li>
649
+
650
+
651
+ <li id="section-38">
652
+ <div class="annotation">
653
+
654
+ <div class="pilwrap ">
655
+ <a class="pilcrow" href="#section-38">&#182;</a>
656
+ </div>
657
+ <p>white space is required</p>
658
+
659
+ </div>
660
+
661
+ <div class="content"><div class='highlight'><pre> out_file.write(<span class="string">"<span class="subst">#{settings.client_id}</span> "</span>)
662
+ out_file.write(<span class="string">"<span class="subst">#{settings.private_key}</span>"</span>)
663
+ out_file.close
664
+ <span class="keyword">end</span></pre></div></div>
665
+
666
+ </li>
667
+
668
+
669
+ <li id="section-39">
670
+ <div class="annotation">
671
+
672
+ <div class="pilwrap ">
673
+ <a class="pilcrow" href="#section-39">&#182;</a>
674
+ </div>
675
+ <p>Construct path</p>
676
+
677
+ </div>
678
+
679
+ <div class="content"><div class='highlight'><pre> file_path = <span class="string">"<span class="subst">#{<span class="constant">Dir</span>.tmpdir}</span>/<span class="subst">#{params[<span class="symbol">:file</span>][<span class="symbol">:filename</span>]}</span>"</span></pre></div></div>
680
+
681
+ </li>
682
+
683
+
684
+ <li id="section-40">
685
+ <div class="annotation">
686
+
687
+ <div class="pilwrap ">
688
+ <a class="pilcrow" href="#section-40">&#182;</a>
689
+ </div>
690
+ <p>Open file</p>
691
+
692
+ </div>
693
+
694
+ <div class="content"><div class='highlight'><pre> <span class="constant">File</span>.open(file_path, <span class="string">'wb'</span>) { |f| f.write(params[<span class="symbol">:file</span>][<span class="symbol">:tempfile</span>].read) }</pre></div></div>
695
+
696
+ </li>
697
+
698
+
699
+ <li id="section-41">
700
+ <div class="annotation">
701
+
702
+ <div class="pilwrap ">
703
+ <a class="pilcrow" href="#section-41">&#182;</a>
704
+ </div>
705
+ <p>Make a request to API using client_id and private_key</p>
706
+
707
+ </div>
708
+
709
+ <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload!(file_path)
710
+ document = file.to_document</pre></div></div>
711
+
712
+ </li>
713
+
714
+
715
+ <li id="section-42">
716
+ <div class="annotation">
717
+
718
+ <div class="pilwrap ">
719
+ <a class="pilcrow" href="#section-42">&#182;</a>
720
+ </div>
721
+ <p>create envelope using user id and entered by user name</p>
722
+
723
+ </div>
724
+
725
+ <div class="content"><div class='highlight'><pre> envelope = <span class="constant">GroupDocs::Signature::Envelope</span>.new
726
+ envelope.name = file.name
727
+ envelope.email_subject = <span class="string">'Sing this!'</span>
728
+ envelope.create!</pre></div></div>
729
+
730
+ </li>
731
+
732
+
733
+ <li id="section-43">
734
+ <div class="annotation">
735
+
736
+ <div class="pilwrap ">
737
+ <a class="pilcrow" href="#section-43">&#182;</a>
738
+ </div>
739
+ <p>Add uploaded document to envelope</p>
740
+
741
+ </div>
742
+
743
+ <div class="content"><div class='highlight'><pre> envelope.add_document!(document)</pre></div></div>
744
+
745
+ </li>
746
+
747
+
748
+ <li id="section-44">
749
+ <div class="annotation">
750
+
751
+ <div class="pilwrap ">
752
+ <a class="pilcrow" href="#section-44">&#182;</a>
753
+ </div>
754
+ <p>Get role list for current user</p>
755
+
756
+ </div>
757
+
758
+ <div class="content"><div class='highlight'><pre> roles = <span class="constant">GroupDocs::Signature::Role</span>.get!</pre></div></div>
759
+
760
+ </li>
761
+
762
+
763
+ <li id="section-45">
764
+ <div class="annotation">
765
+
766
+ <div class="pilwrap ">
767
+ <a class="pilcrow" href="#section-45">&#182;</a>
768
+ </div>
769
+ <p>Create new recipient</p>
770
+
771
+ </div>
772
+
773
+ <div class="content"><div class='highlight'><pre> recipient = <span class="constant">GroupDocs::Signature::Recipient</span>.new
774
+ recipient.email = settings.email
775
+ recipient.first_name = settings.name
776
+ recipient.last_name = settings.last_name
777
+ recipient.role_id = roles.detect { |role| role.name == <span class="string">'Signer'</span> }.id</pre></div></div>
778
+
779
+ </li>
780
+
781
+
782
+ <li id="section-46">
783
+ <div class="annotation">
784
+
785
+ <div class="pilwrap ">
786
+ <a class="pilcrow" href="#section-46">&#182;</a>
787
+ </div>
788
+ <p>Add recipient to envelope</p>
789
+
790
+ </div>
791
+
792
+ <div class="content"><div class='highlight'><pre> recipient = envelope.add_recipient!(recipient)</pre></div></div>
793
+
794
+ </li>
795
+
796
+
797
+ <li id="section-47">
798
+ <div class="annotation">
799
+
800
+ <div class="pilwrap ">
801
+ <a class="pilcrow" href="#section-47">&#182;</a>
802
+ </div>
803
+ <p>Get document id</p>
804
+
805
+ </div>
806
+
807
+ <div class="content"><div class='highlight'><pre> document = envelope.documents!()</pre></div></div>
808
+
809
+ </li>
810
+
811
+
812
+ <li id="section-48">
813
+ <div class="annotation">
814
+
815
+ <div class="pilwrap ">
816
+ <a class="pilcrow" href="#section-48">&#182;</a>
817
+ </div>
818
+ <p>Get field and add the location to field</p>
819
+
820
+ </div>
821
+
822
+ <div class="content"><div class='highlight'><pre> field = <span class="constant">GroupDocs::Signature::Field</span>.get!().detect { |f| f.type == <span class="symbol">:signature</span> }
823
+ field.location = {<span class="symbol">:location_x</span> =&gt; <span class="number">0</span>.<span class="number">15</span>, <span class="symbol">:location_y</span> =&gt; <span class="number">0</span>.<span class="number">73</span>, <span class="symbol">:location_w</span> =&gt; <span class="number">150</span>, <span class="symbol">:location_h</span> =&gt; <span class="number">50</span>, <span class="symbol">:page</span> =&gt; <span class="number">1</span>}
824
+ field.name = <span class="string">'EMPLOYEE SIGNATURE'</span></pre></div></div>
825
+
826
+ </li>
827
+
828
+
829
+ <li id="section-49">
830
+ <div class="annotation">
831
+
832
+ <div class="pilwrap ">
833
+ <a class="pilcrow" href="#section-49">&#182;</a>
834
+ </div>
835
+ <p>Add field to envelope</p>
836
+
837
+ </div>
838
+
839
+ <div class="content"><div class='highlight'><pre> envelope.add_field!(field, document[<span class="number">0</span>], recipient, {})</pre></div></div>
840
+
841
+ </li>
842
+
843
+
844
+ <li id="section-50">
845
+ <div class="annotation">
846
+
847
+ <div class="pilwrap ">
848
+ <a class="pilcrow" href="#section-50">&#182;</a>
849
+ </div>
850
+ <p>Send envelop</p>
851
+
852
+ </div>
853
+
854
+ <div class="content"><div class='highlight'><pre> envelope.send!({<span class="symbol">:callbackUrl</span> =&gt; settings.callback})</pre></div></div>
855
+
856
+ </li>
857
+
858
+
859
+ <li id="section-51">
860
+ <div class="annotation">
861
+
862
+ <div class="pilwrap ">
863
+ <a class="pilcrow" href="#section-51">&#182;</a>
864
+ </div>
865
+ <p>Get url from request</p>
866
+
867
+ </div>
868
+
869
+ <div class="content"><div class='highlight'><pre> url = <span class="string">"https://apps.groupdocs.com/signature/signembed/<span class="subst">#{envelope.id}</span>/<span class="subst">#{recipient.id}</span>"</span>
870
+
871
+ iframe = <span class="constant">GroupDocs::Api::Request</span>.new(<span class="symbol">:path</span> =&gt; url).prepare_and_sign_url</pre></div></div>
872
+
873
+ </li>
874
+
875
+
876
+ <li id="section-52">
877
+ <div class="annotation">
878
+
879
+ <div class="pilwrap ">
880
+ <a class="pilcrow" href="#section-52">&#182;</a>
881
+ </div>
882
+ <p>Make iframe</p>
883
+
884
+ </div>
885
+
886
+ <div class="content"><div class='highlight'><pre> iframe = <span class="string">"&lt;iframe id='downloadframe' src='<span class="subst">#{iframe}</span>' width='800' height='1000'&gt;&lt;/iframe&gt;"</span>
887
+
888
+
889
+ <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e
890
+ err = e.message
891
+ <span class="keyword">end</span></pre></div></div>
892
+
893
+ </li>
894
+
895
+
896
+ <li id="section-53">
897
+ <div class="annotation">
898
+
899
+ <div class="pilwrap ">
900
+ <a class="pilcrow" href="#section-53">&#182;</a>
901
+ </div>
902
+ <p>set variables for template</p>
903
+
904
+ </div>
905
+
906
+ <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample39</span>, <span class="symbol">:locals</span> =&gt; {<span class="symbol">:userId</span> =&gt; settings.client_id,
907
+ <span class="symbol">:privateKey</span> =&gt; settings.private_key,
908
+ <span class="symbol">:callback</span> =&gt; settings.callback,
909
+ <span class="symbol">:email</span> =&gt; settings.email,
910
+ <span class="symbol">:name</span> =&gt; settings.name,
911
+ <span class="symbol">:lastName</span> =&gt; settings.last_name,
912
+ <span class="symbol">:iframe</span> =&gt; iframe,
913
+ <span class="symbol">:err</span> =&gt; err}
914
+ <span class="keyword">end</span></pre></div></div>
915
+
916
+ </li>
917
+
918
+ </ul>
919
+ </div>
920
+ </body>
921
+ </html>