groupdocs 1.5.8 → 1.5.9

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