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
@@ -2,7 +2,7 @@
2
2
 
3
3
  <html>
4
4
  <head>
5
- <title>sample4.rb</title>
5
+ <title>sample04.rb</title>
6
6
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
7
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
8
8
  <link rel="stylesheet" media="all" href="docco.css" />
@@ -15,7 +15,7 @@
15
15
 
16
16
  <li id="title">
17
17
  <div class="annotation">
18
- <h1>sample4.rb</h1>
18
+ <h1>sample04.rb</h1>
19
19
  </div>
20
20
  </li>
21
21
 
@@ -31,8 +31,8 @@
31
31
 
32
32
  </div>
33
33
 
34
- <div class="content"><div class='highlight'><pre>get <span class="string">'/sample4'</span> <span class="keyword">do</span>
35
- haml <span class="symbol">:sample4</span>
34
+ <div class="content"><div class='highlight'><pre>get <span class="string">'/sample04'</span> <span class="keyword">do</span>
35
+ haml <span class="symbol">:sample04</span>
36
36
  <span class="keyword">end</span></pre></div></div>
37
37
 
38
38
  </li>
@@ -48,7 +48,7 @@
48
48
 
49
49
  </div>
50
50
 
51
- <div class="content"><div class='highlight'><pre>post <span class="string">'/sample4'</span> <span class="keyword">do</span></pre></div></div>
51
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample04'</span> <span class="keyword">do</span></pre></div></div>
52
52
 
53
53
  </li>
54
54
 
@@ -59,15 +59,15 @@
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 variables</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">:file_id</span>, params[<span class="symbol">:file_id</span>]
69
- set <span class="symbol">:source</span>, params[<span class="symbol">:source</span>]
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">:file_id</span>, params[<span class="symbol">:fileId</span>]
70
69
  set <span class="symbol">:url</span>, params[<span class="symbol">:url</span>]
70
+ set <span class="symbol">:base_path</span>, params[<span class="symbol">:basePath</span>]
71
71
 
72
72
  <span class="keyword">begin</span></pre></div></div>
73
73
 
@@ -80,11 +80,13 @@
80
80
  <div class="pilwrap ">
81
81
  <a class="pilcrow" href="#section-4">&#182;</a>
82
82
  </div>
83
- <p>check required variables</p>
83
+ <p>Check required variables</p>
84
84
 
85
85
  </div>
86
86
 
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?</pre></div></div>
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.file_id.empty?
88
+
89
+ <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>
88
90
 
89
91
  </li>
90
92
 
@@ -95,15 +97,13 @@
95
97
  <div class="pilwrap ">
96
98
  <a class="pilcrow" href="#section-5">&#182;</a>
97
99
  </div>
98
- <p>get file GUID</p>
100
+ <p>Configure your access to API server</p>
99
101
 
100
102
  </div>
101
103
 
102
- <div class="content"><div class='highlight'><pre> file = <span class="keyword">nil</span>
103
- <span class="keyword">case</span> settings.source
104
- <span class="keyword">when</span> <span class="string">'guid'</span>
105
- file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> =&gt; settings.file_id})
106
- <span class="keyword">when</span> <span class="string">'local'</span></pre></div></div>
104
+ <div class="content"><div class='highlight'><pre> <span class="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs|
105
+ groupdocs.client_id = settings.client_id
106
+ groupdocs.private_key = settings.private_key</pre></div></div>
107
107
 
108
108
  </li>
109
109
 
@@ -114,11 +114,12 @@
114
114
  <div class="pilwrap ">
115
115
  <a class="pilcrow" href="#section-6">&#182;</a>
116
116
  </div>
117
- <p>construct path</p>
117
+ <p>Optionally specify API server and version</p>
118
118
 
119
119
  </div>
120
120
 
121
- <div class="content"><div class='highlight'><pre> filepath = <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>
121
+ <div class="content"><div class='highlight'><pre> groupdocs.api_server = settings.base_path <span class="comment"># default is 'https://api.groupdocs.com'</span>
122
+ <span class="keyword">end</span></pre></div></div>
122
123
 
123
124
  </li>
124
125
 
@@ -129,11 +130,11 @@
129
130
  <div class="pilwrap ">
130
131
  <a class="pilcrow" href="#section-7">&#182;</a>
131
132
  </div>
132
- <p>open file</p>
133
+ <p>Get file GUID</p>
133
134
 
134
135
  </div>
135
136
 
136
- <div class="content"><div class='highlight'><pre> <span class="constant">File</span>.open(filepath, <span class="string">'wb'</span>) { |f| f.write(params[<span class="symbol">:file</span>][<span class="symbol">:tempfile</span>].read) }</pre></div></div>
137
+ <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}).to_document</pre></div></div>
137
138
 
138
139
  </li>
139
140
 
@@ -144,19 +145,12 @@
144
145
  <div class="pilwrap ">
145
146
  <a class="pilcrow" href="#section-8">&#182;</a>
146
147
  </div>
147
- <p>make a request to API using client_id and private_key</p>
148
+ <p>Obtaining all Metadata for file</p>
148
149
 
149
150
  </div>
150
151
 
151
- <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload!(filepath, {}, <span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key)
152
- <span class="keyword">when</span> <span class="string">'url'</span>
153
- file = <span class="constant">GroupDocs::Storage::File</span>.upload_web!(settings.url, <span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key)
154
- <span class="keyword">else</span>
155
- raise <span class="string">'Wrong GUID source.'</span>
156
- <span class="keyword">end</span>
157
-
158
- pp file
159
- pp file.name</pre></div></div>
152
+ <div class="content"><div class='highlight'><pre> document = file.metadata!
153
+ file = document.last_view.document.file</pre></div></div>
160
154
 
161
155
  </li>
162
156
 
@@ -167,11 +161,11 @@
167
161
  <div class="pilwrap ">
168
162
  <a class="pilcrow" href="#section-9">&#182;</a>
169
163
  </div>
170
- <p>download file</p>
164
+ <p>Download file</p>
171
165
 
172
166
  </div>
173
167
 
174
- <div class="content"><div class='highlight'><pre> dowloaded_file = file.download!(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/downloads"</span>, {<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})
168
+ <div class="content"><div class='highlight'><pre> dowloaded_file = file.download!(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/downloads"</span>)
175
169
  <span class="keyword">unless</span> dowloaded_file.empty?
176
170
  massage = <span class="string">"&lt;font color='green'&gt;File was downloaded to the &lt;font color='blue'&gt;<span class="subst">#{dowloaded_file}</span>&lt;/font&gt; folder&lt;/font&gt; &lt;br /&gt;"</span>
177
171
  <span class="keyword">end</span>
@@ -189,11 +183,11 @@
189
183
  <div class="pilwrap ">
190
184
  <a class="pilcrow" href="#section-10">&#182;</a>
191
185
  </div>
192
- <p>set variables for template</p>
186
+ <p>Set variables for template</p>
193
187
 
194
188
  </div>
195
189
 
196
- <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample4</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">:file_id</span> =&gt; settings.file_id, <span class="symbol">:massage</span> =&gt; massage, <span class="symbol">:err</span> =&gt; err}
190
+ <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample04</span>, <span class="symbol">:locals</span> =&gt; {<span class="symbol">:clientId</span> =&gt; settings.client_id, <span class="symbol">:privateKey</span> =&gt; settings.private_key, <span class="symbol">:fileId</span> =&gt; settings.file_id, <span class="symbol">:massage</span> =&gt; massage, <span class="symbol">:err</span> =&gt; err}
197
191
  <span class="keyword">end</span></pre></div></div>
198
192
 
199
193
  </li>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <html>
4
4
  <head>
5
- <title>sample5.rb</title>
5
+ <title>sample05.rb</title>
6
6
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
7
7
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
8
8
  <link rel="stylesheet" media="all" href="docco.css" />
@@ -15,7 +15,7 @@
15
15
 
16
16
  <li id="title">
17
17
  <div class="annotation">
18
- <h1>sample5.rb</h1>
18
+ <h1>sample05.rb</h1>
19
19
  </div>
20
20
  </li>
21
21
 
@@ -31,8 +31,8 @@
31
31
 
32
32
  </div>
33
33
 
34
- <div class="content"><div class='highlight'><pre>get <span class="string">'/sample5'</span> <span class="keyword">do</span>
35
- haml <span class="symbol">:sample5</span>
34
+ <div class="content"><div class='highlight'><pre>get <span class="string">'/sample05'</span> <span class="keyword">do</span>
35
+ haml <span class="symbol">:sample05</span>
36
36
  <span class="keyword">end</span></pre></div></div>
37
37
 
38
38
  </li>
@@ -48,7 +48,7 @@
48
48
 
49
49
  </div>
50
50
 
51
- <div class="content"><div class='highlight'><pre>post <span class="string">'/sample5'</span> <span class="keyword">do</span></pre></div></div>
51
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample05'</span> <span class="keyword">do</span></pre></div></div>
52
52
 
53
53
  </li>
54
54
 
@@ -63,14 +63,15 @@
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">:file_id</span>, params[<span class="symbol">:fileId</span>]
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">:file_id</span>, params[<span class="symbol">:srcPath</span>]
69
69
  set <span class="symbol">:url</span>, params[<span class="symbol">:url</span>]
70
70
  set <span class="symbol">:copy</span>, params[<span class="symbol">:copy</span>]
71
71
  set <span class="symbol">:move</span>, params[<span class="symbol">:move</span>]
72
- set <span class="symbol">:dest_path</span>, params[<span class="symbol">:dest_path</span>]
72
+ set <span class="symbol">:dest_path</span>, params[<span class="symbol">:destPath</span>]
73
73
  set <span class="symbol">:source</span>, params[<span class="symbol">:source</span>]
74
+ set <span class="symbol">:base_path</span>, params[<span class="symbol">:basePath</span>]
74
75
 
75
76
  <span class="keyword">begin</span></pre></div></div>
76
77
 
@@ -89,7 +90,7 @@
89
90
 
90
91
  <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?
91
92
 
92
- file = <span class="keyword">nil</span></pre></div></div>
93
+ <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>
93
94
 
94
95
  </li>
95
96
 
@@ -100,23 +101,59 @@
100
101
  <div class="pilwrap ">
101
102
  <a class="pilcrow" href="#section-5">&#182;</a>
102
103
  </div>
104
+ <p>Configure your access to API server</p>
105
+
106
+ </div>
107
+
108
+ <div class="content"><div class='highlight'><pre> <span class="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs|
109
+ groupdocs.client_id = settings.client_id
110
+ groupdocs.private_key = settings.private_key</pre></div></div>
111
+
112
+ </li>
113
+
114
+
115
+ <li id="section-6">
116
+ <div class="annotation">
117
+
118
+ <div class="pilwrap ">
119
+ <a class="pilcrow" href="#section-6">&#182;</a>
120
+ </div>
121
+ <p>Optionally specify API server and version</p>
122
+
123
+ </div>
124
+
125
+ <div class="content"><div class='highlight'><pre> groupdocs.api_server = settings.base_path <span class="comment"># default is 'https://api.groupdocs.com'</span>
126
+ <span class="keyword">end</span>
127
+
128
+ file = <span class="keyword">nil</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>
103
139
  <p>get document by file GUID</p>
104
140
 
105
141
  </div>
106
142
 
107
143
  <div class="content"><div class='highlight'><pre> <span class="keyword">case</span> settings.source
108
144
  <span class="keyword">when</span> <span class="string">'guid'</span>
109
- file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> =&gt; settings.file_id})
145
+ file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> =&gt; settings.file_id}).to_document.metadata!()
146
+ file = file.last_view.document.file
110
147
  <span class="keyword">when</span> <span class="string">'local'</span></pre></div></div>
111
148
 
112
149
  </li>
113
150
 
114
151
 
115
- <li id="section-6">
152
+ <li id="section-8">
116
153
  <div class="annotation">
117
154
 
118
155
  <div class="pilwrap ">
119
- <a class="pilcrow" href="#section-6">&#182;</a>
156
+ <a class="pilcrow" href="#section-8">&#182;</a>
120
157
  </div>
121
158
  <p>construct path</p>
122
159
 
@@ -127,11 +164,11 @@
127
164
  </li>
128
165
 
129
166
 
130
- <li id="section-7">
167
+ <li id="section-9">
131
168
  <div class="annotation">
132
169
 
133
170
  <div class="pilwrap ">
134
- <a class="pilcrow" href="#section-7">&#182;</a>
171
+ <a class="pilcrow" href="#section-9">&#182;</a>
135
172
  </div>
136
173
  <p>open file</p>
137
174
 
@@ -142,19 +179,19 @@
142
179
  </li>
143
180
 
144
181
 
145
- <li id="section-8">
182
+ <li id="section-10">
146
183
  <div class="annotation">
147
184
 
148
185
  <div class="pilwrap ">
149
- <a class="pilcrow" href="#section-8">&#182;</a>
186
+ <a class="pilcrow" href="#section-10">&#182;</a>
150
187
  </div>
151
188
  <p>make a request to API using client_id and private_key</p>
152
189
 
153
190
  </div>
154
191
 
155
- <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload!(filepath, {}, <span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key)
192
+ <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload!(filepath, {})
156
193
  <span class="keyword">when</span> <span class="string">'url'</span>
157
- file = <span class="constant">GroupDocs::Storage::File</span>.upload_web!(settings.url, <span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key)
194
+ file = <span class="constant">GroupDocs::Storage::File</span>.upload_web!(settings.url)
158
195
  <span class="keyword">else</span>
159
196
  raise <span class="string">'Wrong GUID source.'</span>
160
197
  <span class="keyword">end</span></pre></div></div>
@@ -162,11 +199,11 @@
162
199
  </li>
163
200
 
164
201
 
165
- <li id="section-9">
202
+ <li id="section-11">
166
203
  <div class="annotation">
167
204
 
168
205
  <div class="pilwrap ">
169
- <a class="pilcrow" href="#section-9">&#182;</a>
206
+ <a class="pilcrow" href="#section-11">&#182;</a>
170
207
  </div>
171
208
  <p>raise files_list.to_yaml
172
209
  copy file using request to API</p>
@@ -174,43 +211,43 @@ copy file using request to API</p>
174
211
  </div>
175
212
 
176
213
  <div class="content"><div class='highlight'><pre> <span class="keyword">unless</span> settings.copy.<span class="keyword">nil</span>?
177
- file = file.copy!(settings.dest_path, {}, {<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})
214
+ file = file.copy!(settings.dest_path, {})
178
215
  button = settings.copy
179
216
  <span class="keyword">end</span></pre></div></div>
180
217
 
181
218
  </li>
182
219
 
183
220
 
184
- <li id="section-10">
221
+ <li id="section-12">
185
222
  <div class="annotation">
186
223
 
187
224
  <div class="pilwrap ">
188
- <a class="pilcrow" href="#section-10">&#182;</a>
225
+ <a class="pilcrow" href="#section-12">&#182;</a>
189
226
  </div>
190
227
  <p>move file using request to API</p>
191
228
 
192
229
  </div>
193
230
 
194
231
  <div class="content"><div class='highlight'><pre> <span class="keyword">unless</span> settings.move.<span class="keyword">nil</span>?
195
- file = file.move!(settings.dest_path, {}, {<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})
232
+ file = file.move!(settings.dest_path, {})
196
233
  button = settings.move
197
234
  <span class="keyword">end</span></pre></div></div>
198
235
 
199
236
  </li>
200
237
 
201
238
 
202
- <li id="section-11">
239
+ <li id="section-13">
203
240
  <div class="annotation">
204
241
 
205
242
  <div class="pilwrap ">
206
- <a class="pilcrow" href="#section-11">&#182;</a>
243
+ <a class="pilcrow" href="#section-13">&#182;</a>
207
244
  </div>
208
245
  <p>result message</p>
209
246
 
210
247
  </div>
211
248
 
212
249
  <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> file
213
- massage = <span class="string">"File was <span class="subst">#{button}</span>'ed to the <span class="subst">#{settings.dest_path}</span> folder"</span>
250
+ massage = <span class="string">"File was <span class="subst">#{button}</span>'ed to the &lt;font color=\"blue\"&gt;<span class="subst">#{settings.dest_path}</span>&lt;/font&gt; folder"</span>
214
251
  <span class="keyword">end</span>
215
252
 
216
253
  <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e
@@ -220,17 +257,17 @@ copy file using request to API</p>
220
257
  </li>
221
258
 
222
259
 
223
- <li id="section-12">
260
+ <li id="section-14">
224
261
  <div class="annotation">
225
262
 
226
263
  <div class="pilwrap ">
227
- <a class="pilcrow" href="#section-12">&#182;</a>
264
+ <a class="pilcrow" href="#section-14">&#182;</a>
228
265
  </div>
229
266
  <p>set variables for template</p>
230
267
 
231
268
  </div>
232
269
 
233
- <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample5</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">:file_id</span> =&gt; settings.file_id, <span class="symbol">:dest_path</span> =&gt; settings.dest_path, <span class="symbol">:massage</span> =&gt; massage, <span class="symbol">:err</span> =&gt; err}
270
+ <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample05</span>, <span class="symbol">:locals</span> =&gt; {<span class="symbol">:clientId</span> =&gt; settings.client_id, <span class="symbol">:privateKey</span> =&gt; settings.private_key, <span class="symbol">:fileId</span> =&gt; settings.file_id, <span class="symbol">:destPath</span> =&gt; settings.dest_path, <span class="symbol">:massage</span> =&gt; massage, <span class="symbol">:err</span> =&gt; err}
234
271
  <span class="keyword">end</span></pre></div></div>
235
272
 
236
273
  </li>
@@ -0,0 +1,299 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>sample06.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>sample06.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">'/sample06'</span> <span class="keyword">do</span>
35
+ haml <span class="symbol">:sample06</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>POST request</p>
48
+
49
+ </div>
50
+
51
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample06'</span> <span class="keyword">do</span></pre></div></div>
52
+
53
+ </li>
54
+
55
+
56
+ <li id="section-3">
57
+ <div class="annotation">
58
+
59
+ <div class="pilwrap ">
60
+ <a class="pilcrow" href="#section-3">&#182;</a>
61
+ </div>
62
+ <p>set variables</p>
63
+
64
+ </div>
65
+
66
+ <div class="content"><div class='highlight'><pre> set <span class="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">:base_path</span>, params[<span class="symbol">:basePath</span>]
69
+ <span class="keyword">require</span> <span class="string">'net/http'</span>
70
+
71
+ <span class="keyword">begin</span></pre></div></div>
72
+
73
+ </li>
74
+
75
+
76
+ <li id="section-4">
77
+ <div class="annotation">
78
+
79
+ <div class="pilwrap ">
80
+ <a class="pilcrow" href="#section-4">&#182;</a>
81
+ </div>
82
+ <p>Check required variables</p>
83
+
84
+ </div>
85
+
86
+ <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?
87
+
88
+ <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>
89
+
90
+ </li>
91
+
92
+
93
+ <li id="section-5">
94
+ <div class="annotation">
95
+
96
+ <div class="pilwrap ">
97
+ <a class="pilcrow" href="#section-5">&#182;</a>
98
+ </div>
99
+ <p>Configure your access to API server</p>
100
+
101
+ </div>
102
+
103
+ <div class="content"><div class='highlight'><pre> <span class="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs|
104
+ groupdocs.client_id = settings.client_id
105
+ groupdocs.private_key = settings.private_key</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>Optionally specify API server and version</p>
117
+
118
+ </div>
119
+
120
+ <div class="content"><div class='highlight'><pre> groupdocs.api_server = settings.base_path <span class="comment"># default is 'https://api.groupdocs.com'</span>
121
+ <span class="keyword">end</span></pre></div></div>
122
+
123
+ </li>
124
+
125
+
126
+ <li id="section-7">
127
+ <div class="annotation">
128
+
129
+ <div class="pilwrap ">
130
+ <a class="pilcrow" href="#section-7">&#182;</a>
131
+ </div>
132
+ <p>Construct file path and open file</p>
133
+
134
+ </div>
135
+
136
+ <div class="content"><div class='highlight'><pre> file_one_path = <span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/<span class="subst">#{params[<span class="symbol">:fiDocument</span>][<span class="symbol">:filename</span>]}</span>"</span>
137
+ <span class="constant">File</span>.open(file_one_path, <span class="string">'wb'</span>) { |f| f.write(params[<span class="symbol">:fiDocument</span>][<span class="symbol">:tempfile</span>].read) }</pre></div></div>
138
+
139
+ </li>
140
+
141
+
142
+ <li id="section-8">
143
+ <div class="annotation">
144
+
145
+ <div class="pilwrap ">
146
+ <a class="pilcrow" href="#section-8">&#182;</a>
147
+ </div>
148
+ <p>Create new file</p>
149
+
150
+ </div>
151
+
152
+ <div class="content"><div class='highlight'><pre> file_one = <span class="constant">GroupDocs::Storage::File</span>.new(<span class="symbol">name:</span> params[<span class="symbol">:fiDocument</span>][<span class="symbol">:filename</span>], <span class="symbol">local_path:</span> file_one_path)
153
+ document_one = file_one.to_document</pre></div></div>
154
+
155
+ </li>
156
+
157
+
158
+ <li id="section-9">
159
+ <div class="annotation">
160
+
161
+ <div class="pilwrap ">
162
+ <a class="pilcrow" href="#section-9">&#182;</a>
163
+ </div>
164
+ <p>Construct signature path and open file</p>
165
+
166
+ </div>
167
+
168
+ <div class="content"><div class='highlight'><pre> signature_one_path = <span class="string">"<span class="subst">#{<span class="constant">Dir</span>.tmpdir}</span>/<span class="subst">#{params[<span class="symbol">:fiSignature</span>][<span class="symbol">:filename</span>]}</span>"</span>
169
+ <span class="constant">File</span>.open(signature_one_path, <span class="string">'wb'</span>) { |f| f.write(params[<span class="symbol">:fiSignature</span>][<span class="symbol">:tempfile</span>].read) }</pre></div></div>
170
+
171
+ </li>
172
+
173
+
174
+ <li id="section-10">
175
+ <div class="annotation">
176
+
177
+ <div class="pilwrap ">
178
+ <a class="pilcrow" href="#section-10">&#182;</a>
179
+ </div>
180
+ <p>Add signature to file using API</p>
181
+
182
+ </div>
183
+
184
+ <div class="content"><div class='highlight'><pre> signature_one = <span class="constant">GroupDocs::Signature</span>.new(<span class="symbol">name:</span> params[<span class="symbol">:fiSignature</span>][<span class="symbol">:filename</span>], <span class="symbol">image_path:</span> signature_one_path)
185
+ signature_one.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>
186
+
187
+ </li>
188
+
189
+
190
+ <li id="section-11">
191
+ <div class="annotation">
192
+
193
+ <div class="pilwrap ">
194
+ <a class="pilcrow" href="#section-11">&#182;</a>
195
+ </div>
196
+ <p>Make a request to API using client_id and private_key</p>
197
+
198
+ </div>
199
+
200
+ <div class="content"><div class='highlight'><pre> signed_documents = <span class="constant">GroupDocs::Document</span>.sign_documents!([document_one], [signature_one], {})
201
+ sleep(<span class="number">5</span>)</pre></div></div>
202
+
203
+ </li>
204
+
205
+
206
+ <li id="section-12">
207
+ <div class="annotation">
208
+
209
+ <div class="pilwrap ">
210
+ <a class="pilcrow" href="#section-12">&#182;</a>
211
+ </div>
212
+ <p>Get the document guid</p>
213
+
214
+ </div>
215
+
216
+ <div class="content"><div class='highlight'><pre> document = <span class="constant">GroupDocs::Signature</span>.sign_document_status!(signed_documents)</pre></div></div>
217
+
218
+ </li>
219
+
220
+
221
+ <li id="section-13">
222
+ <div class="annotation">
223
+
224
+ <div class="pilwrap ">
225
+ <a class="pilcrow" href="#section-13">&#182;</a>
226
+ </div>
227
+ <p>Create request from servers</p>
228
+
229
+ </div>
230
+
231
+ <div class="content"><div class='highlight'><pre> <span class="keyword">case</span> settings.base_path
232
+
233
+ <span class="keyword">when</span> <span class="string">'https://stage-api-groupdocs.dynabic.com'</span>
234
+ url = <span class="string">"http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/<span class="subst">#{document.guid}</span>"</span>
235
+
236
+ <span class="keyword">when</span> <span class="string">'https://dev-api-groupdocs.dynabic.com'</span>
237
+ url = <span class="string">"http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/<span class="subst">#{document.guid}</span>"</span>
238
+ <span class="keyword">else</span>
239
+ url = <span class="string">"https://apps.groupdocs.com/document-viewer/embed/<span class="subst">#{document.guid}</span>"</span>
240
+ <span class="keyword">end</span></pre></div></div>
241
+
242
+ </li>
243
+
244
+
245
+ <li id="section-14">
246
+ <div class="annotation">
247
+
248
+ <div class="pilwrap ">
249
+ <a class="pilcrow" href="#section-14">&#182;</a>
250
+ </div>
251
+ <p>Add the signature to url request</p>
252
+
253
+ </div>
254
+
255
+ <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>
256
+
257
+ </li>
258
+
259
+
260
+ <li id="section-15">
261
+ <div class="annotation">
262
+
263
+ <div class="pilwrap ">
264
+ <a class="pilcrow" href="#section-15">&#182;</a>
265
+ </div>
266
+ <p>Generate result</p>
267
+
268
+ </div>
269
+
270
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> signed_documents
271
+ iframe = <span class="string">"&lt;iframe src='<span class="subst">#{iframe}</span>' frameborder='0' width='720' height='600'&gt;&lt;/iframe&gt;"</span>
272
+ <span class="keyword">end</span>
273
+
274
+ <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e
275
+ err = e.message
276
+ <span class="keyword">end</span></pre></div></div>
277
+
278
+ </li>
279
+
280
+
281
+ <li id="section-16">
282
+ <div class="annotation">
283
+
284
+ <div class="pilwrap ">
285
+ <a class="pilcrow" href="#section-16">&#182;</a>
286
+ </div>
287
+ <p>Set variables for template</p>
288
+
289
+ </div>
290
+
291
+ <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample06</span>, <span class="symbol">:locals</span> =&gt; {<span class="symbol">:clientId</span> =&gt; settings.client_id, <span class="symbol">:privateKey</span> =&gt; settings.private_key, <span class="symbol">:iframe</span> =&gt; iframe, <span class="symbol">:err</span> =&gt; err}
292
+ <span class="keyword">end</span></pre></div></div>
293
+
294
+ </li>
295
+
296
+ </ul>
297
+ </div>
298
+ </body>
299
+ </html>