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
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDNiNDcxMmRkODIxNmRmNWI2NzQyMDZlOTZmMjRlY2JlMWFhZDQwYg==
5
- data.tar.gz: !binary |-
6
- NjBjZDY1MDQ0MWUzOWZhNTBmNDFhZGVjYmM5YjI2NTlmNWFjOTlhOQ==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- NDVmYjZkNDE0MTdjNWI5NTRlNTY5YTU0NGYzZTcxMjAxYTQ4MzZiNmNlOTE1
10
- ZjcwZDYxNGFhOTNjZWQ1MzY5NzZjODU5MTAzZTJlZGE1MWI2Y2RkNTEwYzg3
11
- YzNjOGQ4NGVjMTBhZWFiN2RlNGY0YjU3ZDU4MTBlNDc5NjBjNTk=
12
- data.tar.gz: !binary |-
13
- ZDI4OGM4ZjM2NTIzMmNjYjA0Yzk1NDkwNmUyMjI1OGQ4ZTcwYTcwNDc2MTc5
14
- MDhiMmQxNDA0YjRmZGUwODQ1ZDdlMWM5ODExODRmNmRmY2Q3OTg0YmY1ZmI5
15
- ZWE1MmUyNDY1ODYyYTU4OTk4Y2U4ZTFlMTRkNGIyNDQ3MDZmYzA=
@@ -1,200 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <title>sample9.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>sample9.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">'/sample9'</span> <span class="keyword">do</span>
35
- haml <span class="symbol">:sample9</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">'/sample9'</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">:file_id</span>, params[<span class="symbol">:fileId</span>]
67
- set <span class="symbol">:width</span>, params[<span class="symbol">:width</span>]
68
- set <span class="symbol">:height</span>, params[<span class="symbol">:height</span>]
69
-
70
- <span class="keyword">begin</span></pre></div></div>
71
-
72
- </li>
73
-
74
-
75
- <li id="section-4">
76
- <div class="annotation">
77
-
78
- <div class="pilwrap ">
79
- <a class="pilcrow" href="#section-4">&#182;</a>
80
- </div>
81
- <p>check required variables</p>
82
-
83
- </div>
84
-
85
- <div class="content"><div class='highlight'><pre> raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> settings.guid.empty? <span class="keyword">or</span> settings.width.empty? <span class="keyword">or</span> settings.height.empty?</pre></div></div>
86
-
87
- </li>
88
-
89
-
90
- <li id="section-5">
91
- <div class="annotation">
92
-
93
- <div class="pilwrap ">
94
- <a class="pilcrow" href="#section-5">&#182;</a>
95
- </div>
96
- <p>get document by file GUID</p>
97
-
98
- </div>
99
-
100
- <div class="content"><div class='highlight'><pre> file = <span class="keyword">nil</span>
101
- <span class="keyword">case</span> settings.source
102
- <span class="keyword">when</span> <span class="string">'guid'</span>
103
- file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> =&gt; settings.file_id})
104
- <span class="keyword">when</span> <span class="string">'local'</span></pre></div></div>
105
-
106
- </li>
107
-
108
-
109
- <li id="section-6">
110
- <div class="annotation">
111
-
112
- <div class="pilwrap ">
113
- <a class="pilcrow" href="#section-6">&#182;</a>
114
- </div>
115
- <p>construct path</p>
116
-
117
- </div>
118
-
119
- <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>
120
-
121
- </li>
122
-
123
-
124
- <li id="section-7">
125
- <div class="annotation">
126
-
127
- <div class="pilwrap ">
128
- <a class="pilcrow" href="#section-7">&#182;</a>
129
- </div>
130
- <p>open file</p>
131
-
132
- </div>
133
-
134
- <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>
135
-
136
- </li>
137
-
138
-
139
- <li id="section-8">
140
- <div class="annotation">
141
-
142
- <div class="pilwrap ">
143
- <a class="pilcrow" href="#section-8">&#182;</a>
144
- </div>
145
- <p>make a request to API using client_id and private_key</p>
146
-
147
- </div>
148
-
149
- <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)
150
- <span class="keyword">when</span> <span class="string">'url'</span>
151
- 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)
152
- <span class="keyword">else</span>
153
- raise <span class="string">'Wrong GUID source.'</span>
154
- <span class="keyword">end</span></pre></div></div>
155
-
156
- </li>
157
-
158
-
159
- <li id="section-9">
160
- <div class="annotation">
161
-
162
- <div class="pilwrap ">
163
- <a class="pilcrow" href="#section-9">&#182;</a>
164
- </div>
165
- <p>construct result string</p>
166
-
167
- </div>
168
-
169
- <div class="content"><div class='highlight'><pre> v_url = <span class="string">"https://apps.groupdocs.com/document-viewer/embed/<span class="subst">#{file.guid}</span>?frameborder='0' width='<span class="subst">#{settings.width}</span>' height='<span class="subst">#{settings.height}</span>'"</span>
170
-
171
- <span class="keyword">if</span> v_url
172
- v_url = v_url
173
- <span class="keyword">end</span>
174
-
175
- <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e
176
- err = e.message
177
- <span class="keyword">end</span></pre></div></div>
178
-
179
- </li>
180
-
181
-
182
- <li id="section-10">
183
- <div class="annotation">
184
-
185
- <div class="pilwrap ">
186
- <a class="pilcrow" href="#section-10">&#182;</a>
187
- </div>
188
- <p>set variables for template</p>
189
-
190
- </div>
191
-
192
- <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample9</span>, <span class="symbol">:locals</span> =&gt; {<span class="symbol">:guid</span> =&gt; settings.guid, <span class="symbol">:width</span> =&gt; settings.width, <span class="symbol">:height</span> =&gt; settings.height, <span class="symbol">:v_url</span> =&gt; v_url, <span class="symbol">:err</span> =&gt; err}
193
- <span class="keyword">end</span></pre></div></div>
194
-
195
- </li>
196
-
197
- </ul>
198
- </div>
199
- </body>
200
- </html>
@@ -1,25 +0,0 @@
1
- # GET request
2
- get '/sample1' do
3
- haml :sample1
4
- end
5
-
6
- # POST request
7
- post '/sample1' do
8
- # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
11
-
12
- begin
13
- # check required variables
14
- raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
15
-
16
- # make a request to API using client_id and private_key
17
- user = GroupDocs::User.get!({:client_id => settings.client_id, :private_key => settings.private_key})
18
-
19
- rescue Exception => e
20
- err = e.message
21
- end
22
-
23
- # set variables for template
24
- haml :sample1, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :user => user, :err => err}
25
- end
@@ -1,29 +0,0 @@
1
- # GET request
2
- get '/sample2' do
3
- haml :sample2
4
- end
5
-
6
- # POST request
7
- post '/sample2' do
8
- # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
11
-
12
- begin
13
- # check required variables
14
- raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
15
-
16
- # make a request to API using client_id and private_key
17
- files_list = GroupDocs::Storage::Folder.list!('/', {}, {:client_id => settings.client_id, :private_key => settings.private_key})
18
-
19
- # construct list of files
20
- filelist = ''
21
- files_list.each { |element| filelist << "#{element.name}<br />" }
22
-
23
- rescue Exception => e
24
- err = e.message
25
- end
26
-
27
- # set variables for template
28
- haml :sample2, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :filelist => filelist, :err => err}
29
- end
@@ -1,33 +0,0 @@
1
- # GET request
2
- get '/sample3' do
3
- haml :sample3
4
- end
5
-
6
- # POST request
7
- post '/sample3' do
8
- # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
11
-
12
- begin
13
- # check required variables
14
- raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
15
-
16
- # construct path
17
- filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
18
- # open file
19
- File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
20
- # make a request to API using client_id and private_key
21
- file = GroupDocs::Storage::File.upload!(filepath, {}, client_id: settings.client_id, private_key: settings.private_key)
22
-
23
- # result massages
24
- massage = "<p>File was uploaded to GroupDocs. Here you can see your <strong>#{params[:file][:filename]}</strong> file in the GroupDocs Embedded Viewer.</p>"
25
- iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/Embed/#{file.guid}' frameborder='0' width='720' height='600'></iframe>"
26
-
27
- rescue Exception => e
28
- err = e.message
29
- end
30
-
31
- # set variables for template
32
- haml :sample3, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :massage => massage, :err => err}
33
- end
@@ -1,51 +0,0 @@
1
- # GET request
2
- get '/sample4' do
3
- haml :sample4
4
- end
5
-
6
- # POST request
7
- post '/sample4' do
8
- # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
11
- set :file_id, params[:file_id]
12
- set :source, params[:source]
13
- set :url, params[:url]
14
-
15
- begin
16
- # check required variables
17
- raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
18
-
19
- # get file GUID
20
- file = nil
21
- case settings.source
22
- when 'guid'
23
- file = GroupDocs::Storage::File.new({:guid => settings.file_id})
24
- when 'local'
25
- # construct path
26
- filepath = "#{Dir.tmpdir}/#{params[:file][:filename]}"
27
- # open file
28
- File.open(filepath, 'wb') { |f| f.write(params[:file][:tempfile].read) }
29
- # make a request to API using client_id and private_key
30
- file = GroupDocs::Storage::File.upload!(filepath, {}, client_id: settings.client_id, private_key: settings.private_key)
31
- when 'url'
32
- file = GroupDocs::Storage::File.upload_web!(settings.url, client_id: settings.client_id, private_key: settings.private_key)
33
- else
34
- raise 'Wrong GUID source.'
35
- end
36
-
37
- pp file
38
- pp file.name
39
- # download file
40
- dowloaded_file = file.download!("#{File.dirname(__FILE__)}/../public/downloads", {:client_id => settings.client_id, :private_key => settings.private_key})
41
- unless dowloaded_file.empty?
42
- massage = "<font color='green'>File was downloaded to the <font color='blue'>#{dowloaded_file}</font> folder</font> <br />"
43
- end
44
-
45
- rescue Exception => e
46
- err = e.message
47
- end
48
-
49
- # set variables for template
50
- haml :sample4, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :file_id => settings.file_id, :massage => massage, :err => err}
51
- end
@@ -1,49 +0,0 @@
1
- # GET request
2
- get '/sample6' do
3
- haml :sample6
4
- end
5
-
6
- # POST request
7
- post '/sample6' do
8
- # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
11
-
12
- begin
13
- # check required variables
14
- raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
15
-
16
- # construct file path and open file
17
- file_one_path = "#{Dir.tmpdir}/#{params[:document][:filename]}"
18
- File.open(file_one_path, 'wb') { |f| f.write(params[:document][:tempfile].read) }
19
-
20
- # create new file
21
- file_one = GroupDocs::Storage::File.new(name: params[:document][:filename], local_path: file_one_path)
22
- document_one = file_one.to_document
23
-
24
- # construct signature path and open file
25
- signature_one_path = "#{Dir.tmpdir}/#{params[:signature][:filename]}"
26
- File.open(signature_one_path, 'wb') { |f| f.write(params[:signature][:tempfile].read) }
27
-
28
-
29
- # add signature to file using API
30
- signature_one = GroupDocs::Signature.new(name: 'Test', image_path: signature_one_path)
31
- signature_one.position = {top: 0.1, left: 0.07, width: 50, height: 50}
32
-
33
- #raise signature_one.to_yaml
34
- # make a request to API using client_id and private_key
35
- signed_documents = GroupDocs::Document.sign_documents!([document_one], [signature_one], {}, {:client_id => settings.client_id, :private_key => settings.private_key})
36
- guid = signed_documents.first.file.guid
37
-
38
- # generate result
39
- if signed_documents
40
- iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/Embed/#{guid}' frameborder='0' width='720' height='600'></iframe>"
41
- end
42
-
43
- rescue Exception => e
44
- err = e.message
45
- end
46
-
47
- # set variables for template
48
- haml :sample6, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :iframe => iframe, :err => err}
49
- end
@@ -1,42 +0,0 @@
1
- # GET request
2
- get '/sample7' do
3
- haml :sample7
4
- end
5
-
6
- # POST request
7
- post '/sample7' do
8
- # set variables
9
- set :client_id, params[:client_id]
10
- set :private_key, params[:private_key]
11
-
12
- begin
13
- # check required variables
14
- raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
15
-
16
- # make a request to API using client_id and private_key
17
- files_list = GroupDocs::Storage::Folder.list!('/', {:extended => true}, {:client_id => settings.client_id, :private_key => settings.private_key})
18
-
19
- # construct result string
20
- thumbnails = ''
21
- files_list.each do |element|
22
- if element.class.name.split('::').last == 'Folder'
23
- next
24
- end
25
-
26
- if element.thumbnail
27
- name = element.name
28
- thumbnails += "<p><img src='data:image/png;base64,#{element.thumbnail}', width='40px', height='40px'> #{name}</p>"
29
- end
30
- end
31
-
32
- unless thumbnails.empty?
33
- set :thumbnails, thumbnails
34
- end
35
-
36
- rescue Exception => e
37
- err = e.message
38
- end
39
-
40
- # set variables for template
41
- haml :sample7, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :thumbnailList => thumbnails, :err => err}
42
- end