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
@@ -48,7 +48,7 @@
48
48
 
49
49
  </div>
50
50
 
51
- <div class="content"><div class='highlight'><pre>post <span class="string">'/sample19'</span> <span class="keyword">do</span></pre></div></div>
51
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample19/compere_callback'</span> <span class="keyword">do</span></pre></div></div>
52
52
 
53
53
  </li>
54
54
 
@@ -59,17 +59,11 @@
59
59
  <div class="pilwrap ">
60
60
  <a class="pilcrow" href="#section-3">&#182;</a>
61
61
  </div>
62
- <p>set variables</p>
62
+ <p>Set download path</p>
63
63
 
64
64
  </div>
65
65
 
66
- <div class="content"><div class='highlight'><pre> set <span class="symbol">:client_id</span>, params[<span class="symbol">:client_id</span>]
67
- set <span class="symbol">:private_key</span>, params[<span class="symbol">:private_key</span>]
68
- set <span class="symbol">:sourceFileId</span>, params[<span class="symbol">:sourceFileId</span>]
69
- set <span class="symbol">:targetFileId</span>, params[<span class="symbol">:targetFileId</span>]
70
- set <span class="symbol">:callbackUrl</span>, params[<span class="symbol">:callbackUrl</span>]
71
-
72
- <span class="keyword">begin</span></pre></div></div>
66
+ <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>
73
67
 
74
68
  </li>
75
69
 
@@ -80,11 +74,16 @@
80
74
  <div class="pilwrap ">
81
75
  <a class="pilcrow" href="#section-4">&#182;</a>
82
76
  </div>
83
- <p>check required variables</p>
77
+ <p>Get callback request</p>
84
78
 
85
79
  </div>
86
80
 
87
- <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.sourceFileId.empty? <span class="keyword">or</span> settings.targetFileId.empty?</pre></div></div>
81
+ <div class="content"><div class='highlight'><pre> data = <span class="constant">JSON</span>.parse(request.body.read)
82
+ <span class="keyword">begin</span>
83
+ raise <span class="string">'Empty params!'</span> <span class="keyword">if</span> data.empty?
84
+ source_id = <span class="keyword">nil</span>
85
+ client_id = <span class="keyword">nil</span>
86
+ private_key = <span class="keyword">nil</span></pre></div></div>
88
87
 
89
88
  </li>
90
89
 
@@ -95,11 +94,339 @@
95
94
  <div class="pilwrap ">
96
95
  <a class="pilcrow" href="#section-5">&#182;</a>
97
96
  </div>
98
- <p>make a request to API using client_id and private_key</p>
97
+ <p>Get value of SourceId</p>
98
+
99
+ </div>
100
+
101
+ <div class="content"><div class='highlight'><pre> data.each <span class="keyword">do</span> |key, value|
102
+ <span class="keyword">if</span> key == <span class="string">'SourceId'</span>
103
+ source_id = value
104
+ <span class="keyword">end</span>
105
+ <span class="keyword">end</span></pre></div></div>
106
+
107
+ </li>
108
+
109
+
110
+ <li id="section-6">
111
+ <div class="annotation">
112
+
113
+ <div class="pilwrap ">
114
+ <a class="pilcrow" href="#section-6">&#182;</a>
115
+ </div>
116
+ <p>Get private key and client_id from file user_info.txt</p>
117
+
118
+ </div>
119
+
120
+ <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>)
121
+ 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>)
122
+ contents = contents.split(<span class="string">' '</span>)
123
+ client_id = contents.first
124
+ private_key = contents.last
125
+ <span class="keyword">end</span></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>Create Job instance</p>
137
+
138
+ </div>
139
+
140
+ <div class="content"><div class='highlight'><pre> job = <span class="constant">GroupDocs::Job</span>.new({<span class="symbol">:id</span> =&gt; source_id})</pre></div></div>
141
+
142
+ </li>
143
+
144
+
145
+ <li id="section-8">
146
+ <div class="annotation">
147
+
148
+ <div class="pilwrap ">
149
+ <a class="pilcrow" href="#section-8">&#182;</a>
150
+ </div>
151
+ <p>Get document by job id</p>
152
+
153
+ </div>
154
+
155
+ <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})</pre></div></div>
156
+
157
+ </li>
158
+
159
+
160
+ <li id="section-9">
161
+ <div class="annotation">
162
+
163
+ <div class="pilwrap ">
164
+ <a class="pilcrow" href="#section-9">&#182;</a>
165
+ </div>
166
+ <p>Download converted file</p>
167
+
168
+ </div>
169
+
170
+ <div class="content"><div class='highlight'><pre> documents[<span class="symbol">:inputs</span>].first.outputs.first.download!(downloads_path, {<span class="symbol">:client_id</span> =&gt; client_id, <span class="symbol">:private_key</span> =&gt; private_key})
171
+
172
+ <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e
173
+ err = e.message
174
+ <span class="keyword">end</span>
175
+ <span class="keyword">end</span></pre></div></div>
176
+
177
+ </li>
178
+
179
+
180
+ <li id="section-10">
181
+ <div class="annotation">
182
+
183
+ <div class="pilwrap ">
184
+ <a class="pilcrow" href="#section-10">&#182;</a>
185
+ </div>
186
+ <p>GET request</p>
187
+
188
+ </div>
189
+
190
+ <div class="content"><div class='highlight'><pre>get <span class="string">'/sample19/check'</span> <span class="keyword">do</span></pre></div></div>
191
+
192
+ </li>
193
+
194
+
195
+ <li id="section-11">
196
+ <div class="annotation">
197
+
198
+ <div class="pilwrap ">
199
+ <a class="pilcrow" href="#section-11">&#182;</a>
200
+ </div>
201
+ <p>Check is there download directory</p>
202
+
203
+ </div>
204
+
205
+ <div class="content"><div class='highlight'><pre> <span class="keyword">unless</span> <span class="constant">File</span>.directory?(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/downloads"</span>)
206
+ <span class="keyword">return</span> <span class="string">'Directory was not found.'</span>
207
+ <span class="keyword">end</span></pre></div></div>
208
+
209
+ </li>
210
+
211
+
212
+ <li id="section-12">
213
+ <div class="annotation">
214
+
215
+ <div class="pilwrap ">
216
+ <a class="pilcrow" href="#section-12">&#182;</a>
217
+ </div>
218
+ <p>Get file name from download directory</p>
219
+
220
+ </div>
221
+
222
+ <div class="content"><div class='highlight'><pre> name = <span class="keyword">nil</span>
223
+ <span class="constant">Dir</span>.entries(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/downloads"</span>).each <span class="keyword">do</span> |file|
224
+ name = file <span class="keyword">if</span> file != <span class="string">'.'</span> &amp;&amp; file != <span class="string">'..'</span>
225
+ <span class="keyword">end</span>
226
+
227
+ name
228
+ <span class="keyword">end</span></pre></div></div>
229
+
230
+ </li>
231
+
232
+
233
+ <li id="section-13">
234
+ <div class="annotation">
235
+
236
+ <div class="pilwrap ">
237
+ <a class="pilcrow" href="#section-13">&#182;</a>
238
+ </div>
239
+ <p>GET request</p>
240
+
241
+ </div>
242
+
243
+ <div class="content"><div class='highlight'><pre>get <span class="string">'/sample19/downloads/:filename'</span> <span class="keyword">do</span> |filename|</pre></div></div>
244
+
245
+ </li>
246
+
247
+
248
+ <li id="section-14">
249
+ <div class="annotation">
250
+
251
+ <div class="pilwrap ">
252
+ <a class="pilcrow" href="#section-14">&#182;</a>
253
+ </div>
254
+ <p>Send file with header to download it</p>
255
+
256
+ </div>
257
+
258
+ <div class="content"><div class='highlight'><pre> send_file <span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/downloads/<span class="subst">#{filename}</span>"</span>, <span class="symbol">:filename</span> =&gt; filename, <span class="symbol">:type</span> =&gt; <span class="string">'Application/octet-stream'</span>
259
+ <span class="keyword">end</span></pre></div></div>
260
+
261
+ </li>
262
+
263
+
264
+ <li id="section-15">
265
+ <div class="annotation">
266
+
267
+ <div class="pilwrap ">
268
+ <a class="pilcrow" href="#section-15">&#182;</a>
269
+ </div>
270
+ <p>POST request</p>
271
+
272
+ </div>
273
+
274
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample19'</span> <span class="keyword">do</span></pre></div></div>
275
+
276
+ </li>
277
+
278
+
279
+ <li id="section-16">
280
+ <div class="annotation">
281
+
282
+ <div class="pilwrap ">
283
+ <a class="pilcrow" href="#section-16">&#182;</a>
284
+ </div>
285
+ <p>Set variables</p>
286
+
287
+ </div>
288
+
289
+ <div class="content"><div class='highlight'><pre> set <span class="symbol">:client_id</span>, params[<span class="symbol">:clientId</span>]
290
+ set <span class="symbol">:private_key</span>, params[<span class="symbol">:privateKey</span>]
291
+ set <span class="symbol">:sourceFileId</span>, params[<span class="symbol">:sourceFileId</span>]
292
+ set <span class="symbol">:targetFileId</span>, params[<span class="symbol">:targetFileId</span>]
293
+ set <span class="symbol">:callback</span>, params[<span class="symbol">:callback</span>]
294
+ set <span class="symbol">:base_path</span>, params[<span class="symbol">:basePath</span>]</pre></div></div>
295
+
296
+ </li>
297
+
298
+
299
+ <li id="section-17">
300
+ <div class="annotation">
301
+
302
+ <div class="pilwrap ">
303
+ <a class="pilcrow" href="#section-17">&#182;</a>
304
+ </div>
305
+ <p>Set download path</p>
306
+
307
+ </div>
308
+
309
+ <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>
310
+
311
+ </li>
312
+
313
+
314
+ <li id="section-18">
315
+ <div class="annotation">
316
+
317
+ <div class="pilwrap ">
318
+ <a class="pilcrow" href="#section-18">&#182;</a>
319
+ </div>
320
+ <p>Remove all files from download directory or create folder if it not there</p>
99
321
 
100
322
  </div>
101
323
 
102
- <div class="content"><div class='highlight'><pre> files_list = <span class="constant">GroupDocs::Storage::Folder</span>.list!(<span class="string">'/'</span>, {}, {<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})
324
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> <span class="constant">File</span>.directory?(downloads_path)
325
+ <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> }
326
+ <span class="keyword">else</span>
327
+ <span class="constant">Dir::</span>mkdir(downloads_path)
328
+ <span class="keyword">end</span>
329
+
330
+ <span class="keyword">begin</span></pre></div></div>
331
+
332
+ </li>
333
+
334
+
335
+ <li id="section-19">
336
+ <div class="annotation">
337
+
338
+ <div class="pilwrap ">
339
+ <a class="pilcrow" href="#section-19">&#182;</a>
340
+ </div>
341
+ <p>Check required variables</p>
342
+
343
+ </div>
344
+
345
+ <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.sourceFileId.empty? <span class="keyword">or</span> settings.targetFileId.empty?
346
+
347
+ <span class="keyword">if</span> settings.base_path.empty? <span class="keyword">then</span> settings.base_path = <span class="string">'https://api.groupdocs.com'</span> <span class="keyword">end</span></pre></div></div>
348
+
349
+ </li>
350
+
351
+
352
+ <li id="section-20">
353
+ <div class="annotation">
354
+
355
+ <div class="pilwrap ">
356
+ <a class="pilcrow" href="#section-20">&#182;</a>
357
+ </div>
358
+ <p>Configure your access to API server</p>
359
+
360
+ </div>
361
+
362
+ <div class="content"><div class='highlight'><pre> <span class="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs|
363
+ groupdocs.client_id = settings.client_id
364
+ groupdocs.private_key = settings.private_key</pre></div></div>
365
+
366
+ </li>
367
+
368
+
369
+ <li id="section-21">
370
+ <div class="annotation">
371
+
372
+ <div class="pilwrap ">
373
+ <a class="pilcrow" href="#section-21">&#182;</a>
374
+ </div>
375
+ <p>Optionally specify API server and version</p>
376
+
377
+ </div>
378
+
379
+ <div class="content"><div class='highlight'><pre> groupdocs.api_server = settings.base_path <span class="comment"># default is 'https://api.groupdocs.com'</span>
380
+ <span class="keyword">end</span></pre></div></div>
381
+
382
+ </li>
383
+
384
+
385
+ <li id="section-22">
386
+ <div class="annotation">
387
+
388
+ <div class="pilwrap ">
389
+ <a class="pilcrow" href="#section-22">&#182;</a>
390
+ </div>
391
+ <p>Write client and private key to the file for callback job</p>
392
+
393
+ </div>
394
+
395
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.callback
396
+ 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>
397
+
398
+ </li>
399
+
400
+
401
+ <li id="section-23">
402
+ <div class="annotation">
403
+
404
+ <div class="pilwrap ">
405
+ <a class="pilcrow" href="#section-23">&#182;</a>
406
+ </div>
407
+ <p>white space is required</p>
408
+
409
+ </div>
410
+
411
+ <div class="content"><div class='highlight'><pre> out_file.write(<span class="string">"<span class="subst">#{settings.client_id}</span> "</span>)
412
+ out_file.write(<span class="string">"<span class="subst">#{settings.private_key}</span>"</span>)
413
+ out_file.close
414
+ <span class="keyword">end</span></pre></div></div>
415
+
416
+ </li>
417
+
418
+
419
+ <li id="section-24">
420
+ <div class="annotation">
421
+
422
+ <div class="pilwrap ">
423
+ <a class="pilcrow" href="#section-24">&#182;</a>
424
+ </div>
425
+ <p>Make a request to API using client_id and private_key</p>
426
+
427
+ </div>
428
+
429
+ <div class="content"><div class='highlight'><pre> files_list = <span class="constant">GroupDocs::Storage::Folder</span>.list!(<span class="string">'/'</span>, {})
103
430
 
104
431
  source_document = <span class="string">''</span>
105
432
  target_document = <span class="string">''</span></pre></div></div>
@@ -107,13 +434,13 @@
107
434
  </li>
108
435
 
109
436
 
110
- <li id="section-6">
437
+ <li id="section-25">
111
438
  <div class="annotation">
112
439
 
113
440
  <div class="pilwrap ">
114
- <a class="pilcrow" href="#section-6">&#182;</a>
441
+ <a class="pilcrow" href="#section-25">&#182;</a>
115
442
  </div>
116
- <p>get source and target documents by file ID</p>
443
+ <p>Get source and target documents by file ID</p>
117
444
 
118
445
  </div>
119
446
 
@@ -126,21 +453,30 @@
126
453
  <span class="keyword">end</span>
127
454
  <span class="keyword">end</span>
128
455
 
456
+
129
457
  <span class="keyword">unless</span> source_document.instance_of? <span class="constant">String</span> <span class="keyword">and</span> target_document.instance_of? <span class="constant">String</span>
130
458
 
131
- info = source_document.to_document.compare!(target_document.to_document, {<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})
132
- sleep(<span class="number">5</span>)</pre></div></div>
459
+ info = source_document.to_document.compare!(target_document.to_document, settings.callback)
460
+
461
+ i = <span class="number">0</span>
462
+
463
+ <span class="keyword">while</span> i&lt;<span class="number">5</span> <span class="keyword">do</span>
464
+ sleep(<span class="number">5</span>)
465
+ job = <span class="constant">GroupDocs::Job</span>.get!(info.id)
466
+ <span class="keyword">break</span> <span class="keyword">if</span> job.status == <span class="symbol">:archived</span>
467
+ i += <span class="number">1</span>
468
+ <span class="keyword">end</span></pre></div></div>
133
469
 
134
470
  </li>
135
471
 
136
472
 
137
- <li id="section-7">
473
+ <li id="section-26">
138
474
  <div class="annotation">
139
475
 
140
476
  <div class="pilwrap ">
141
- <a class="pilcrow" href="#section-7">&#182;</a>
477
+ <a class="pilcrow" href="#section-26">&#182;</a>
142
478
  </div>
143
- <p>get job by ID</p>
479
+ <p>Get job by ID</p>
144
480
 
145
481
  </div>
146
482
 
@@ -149,28 +485,28 @@
149
485
  </li>
150
486
 
151
487
 
152
- <li id="section-8">
488
+ <li id="section-27">
153
489
  <div class="annotation">
154
490
 
155
491
  <div class="pilwrap ">
156
- <a class="pilcrow" href="#section-8">&#182;</a>
492
+ <a class="pilcrow" href="#section-27">&#182;</a>
157
493
  </div>
158
- <p>get all job documents</p>
494
+ <p>Get all job documents</p>
159
495
 
160
496
  </div>
161
497
 
162
- <div class="content"><div class='highlight'><pre> documents = job.documents!({<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})</pre></div></div>
498
+ <div class="content"><div class='highlight'><pre> documents = job.documents!()</pre></div></div>
163
499
 
164
500
  </li>
165
501
 
166
502
 
167
- <li id="section-9">
503
+ <li id="section-28">
168
504
  <div class="annotation">
169
505
 
170
506
  <div class="pilwrap ">
171
- <a class="pilcrow" href="#section-9">&#182;</a>
507
+ <a class="pilcrow" href="#section-28">&#182;</a>
172
508
  </div>
173
- <p>get compared file giud</p>
509
+ <p>Get compared file giud</p>
174
510
 
175
511
  </div>
176
512
 
@@ -179,17 +515,55 @@
179
515
  </li>
180
516
 
181
517
 
182
- <li id="section-10">
518
+ <li id="section-29">
183
519
  <div class="annotation">
184
520
 
185
521
  <div class="pilwrap ">
186
- <a class="pilcrow" href="#section-10">&#182;</a>
522
+ <a class="pilcrow" href="#section-29">&#182;</a>
187
523
  </div>
188
- <p>construct result iframe</p>
524
+ <p>Get url from request</p>
189
525
 
190
526
  </div>
191
527
 
192
- <div class="content"><div class='highlight'><pre> iframe = <span class="string">"&lt;iframe src='https://apps.groupdocs.com/document-viewer/embed/<span class="subst">#{guid}</span>' frameborder='0' width='100%' height='600'&gt;&lt;/iframe&gt;"</span>
528
+ <div class="content"><div class='highlight'><pre> <span class="keyword">case</span> settings.base_path
529
+
530
+ <span class="keyword">when</span> <span class="string">'https://stage-api-groupdocs.dynabic.com'</span>
531
+ url = <span class="string">"http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/<span class="subst">#{guid}</span>"</span>
532
+ <span class="keyword">when</span> <span class="string">'https://dev-api-groupdocs.dynabic.com'</span>
533
+ url = <span class="string">"http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/<span class="subst">#{guid}</span>"</span>
534
+ <span class="keyword">else</span>
535
+ url = <span class="string">"https://apps.groupdocs.com/document-viewer/embed/<span class="subst">#{guid}</span>"</span>
536
+ <span class="keyword">end</span></pre></div></div>
537
+
538
+ </li>
539
+
540
+
541
+ <li id="section-30">
542
+ <div class="annotation">
543
+
544
+ <div class="pilwrap ">
545
+ <a class="pilcrow" href="#section-30">&#182;</a>
546
+ </div>
547
+ <p>Add the signature to url request</p>
548
+
549
+ </div>
550
+
551
+ <div class="content"><div class='highlight'><pre> iframe = <span class="constant">GroupDocs::Api::Request</span>.new(<span class="symbol">:path</span> =&gt; url).prepare_and_sign_url</pre></div></div>
552
+
553
+ </li>
554
+
555
+
556
+ <li id="section-31">
557
+ <div class="annotation">
558
+
559
+ <div class="pilwrap ">
560
+ <a class="pilcrow" href="#section-31">&#182;</a>
561
+ </div>
562
+ <p>Construct result iframe</p>
563
+
564
+ </div>
565
+
566
+ <div class="content"><div class='highlight'><pre> iframe = <span class="string">"&lt;iframe src='<span class="subst">#{iframe}</span>' frameborder='0' width='100%' height='600'&gt;&lt;/iframe&gt;"</span>
193
567
 
194
568
  <span class="keyword">end</span>
195
569
 
@@ -200,17 +574,17 @@
200
574
  </li>
201
575
 
202
576
 
203
- <li id="section-11">
577
+ <li id="section-32">
204
578
  <div class="annotation">
205
579
 
206
580
  <div class="pilwrap ">
207
- <a class="pilcrow" href="#section-11">&#182;</a>
581
+ <a class="pilcrow" href="#section-32">&#182;</a>
208
582
  </div>
209
- <p>set variables for template</p>
583
+ <p>Set variables for template</p>
210
584
 
211
585
  </div>
212
586
 
213
- <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample19</span>, <span class="symbol">:locals</span> =&gt; {<span class="symbol">:userId</span> =&gt; settings.client_id, <span class="symbol">:privateKey</span> =&gt; settings.private_key, <span class="symbol">:sourceFileId</span> =&gt; settings.sourceFileId, <span class="symbol">:targetFileId</span> =&gt; settings.targetFileId, <span class="symbol">:callbackUrl</span> =&gt; settings.callbackUrl, <span class="symbol">:iframe</span> =&gt; iframe, <span class="symbol">:err</span> =&gt; err}
587
+ <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample19</span>, <span class="symbol">:locals</span> =&gt; {<span class="symbol">:userId</span> =&gt; settings.client_id, <span class="symbol">:privateKey</span> =&gt; settings.private_key, <span class="symbol">:sourceFileId</span> =&gt; settings.sourceFileId, <span class="symbol">:targetFileId</span> =&gt; settings.targetFileId, <span class="symbol">:callback</span> =&gt; settings.callback, <span class="symbol">:iframe</span> =&gt; iframe, <span class="symbol">:err</span> =&gt; err}
214
588
  <span class="keyword">end</span></pre></div></div>
215
589
 
216
590
  </li>