groupdocs 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.travis.yml +0 -1
  2. data/README.md +2 -0
  3. data/examples/api-samples/public/docs/annotation-sample.html +167 -57
  4. data/examples/api-samples/public/docs/docco.css +459 -151
  5. data/examples/api-samples/public/docs/envelope-sample.html +373 -131
  6. data/examples/api-samples/public/docs/sample1.html +126 -26
  7. data/examples/api-samples/public/docs/sample10.html +213 -50
  8. data/examples/api-samples/public/docs/sample11.html +319 -87
  9. data/examples/api-samples/public/docs/sample12.html +165 -40
  10. data/examples/api-samples/public/docs/sample13.html +166 -41
  11. data/examples/api-samples/public/docs/sample14.html +142 -30
  12. data/examples/api-samples/public/docs/sample15.html +127 -27
  13. data/examples/api-samples/public/docs/sample16.html +125 -25
  14. data/examples/api-samples/public/docs/sample17.html +188 -37
  15. data/examples/api-samples/public/docs/sample18.html +614 -157
  16. data/examples/api-samples/public/docs/sample19.html +221 -59
  17. data/examples/api-samples/public/docs/sample2.html +142 -30
  18. data/examples/api-samples/public/docs/sample20.html +176 -51
  19. data/examples/api-samples/public/docs/sample21.html +287 -66
  20. data/examples/api-samples/public/docs/sample22.html +224 -53
  21. data/examples/api-samples/public/docs/sample23.html +256 -0
  22. data/examples/api-samples/public/docs/sample24.html +143 -0
  23. data/examples/api-samples/public/docs/sample25.html +429 -0
  24. data/examples/api-samples/public/docs/sample26.html +113 -0
  25. data/examples/api-samples/public/docs/sample27.html +433 -0
  26. data/examples/api-samples/public/docs/sample28.html +185 -0
  27. data/examples/api-samples/public/docs/sample29.html +175 -0
  28. data/examples/api-samples/public/docs/sample3.html +172 -34
  29. data/examples/api-samples/public/docs/sample30.html +144 -0
  30. data/examples/api-samples/public/docs/sample31.html +734 -0
  31. data/examples/api-samples/public/docs/sample4.html +204 -52
  32. data/examples/api-samples/public/docs/sample5.html +241 -63
  33. data/examples/api-samples/public/docs/sample6.html +209 -48
  34. data/examples/api-samples/public/docs/sample7.html +155 -43
  35. data/examples/api-samples/public/docs/sample8.html +235 -62
  36. data/examples/api-samples/public/docs/sample9.html +200 -49
  37. data/examples/api-samples/public/templates/merge_field1_doc.docx +0 -0
  38. data/examples/api-samples/public/templates/merge_field2_doc.docx +0 -0
  39. data/examples/api-samples/samples/sample23.rb +54 -0
  40. data/examples/api-samples/samples/sample24.rb +30 -0
  41. data/examples/api-samples/samples/sample25.rb +4 -4
  42. data/examples/api-samples/samples/sample26.rb +25 -0
  43. data/examples/api-samples/samples/sample27.rb +100 -0
  44. data/examples/api-samples/samples/sample28.rb +47 -0
  45. data/examples/api-samples/samples/sample29.rb +52 -0
  46. data/examples/api-samples/samples/sample30.rb +39 -0
  47. data/examples/api-samples/samples/sample31.rb +204 -0
  48. data/examples/api-samples/samples/sample5.rb +5 -3
  49. data/examples/api-samples/samples/sample6.rb +2 -0
  50. data/examples/api-samples/views/_others_samples.haml +12 -0
  51. data/examples/api-samples/views/index.haml +12 -0
  52. data/examples/api-samples/views/layout.haml +1 -0
  53. data/examples/api-samples/views/sample1.haml +3 -2
  54. data/examples/api-samples/views/sample10.haml +3 -2
  55. data/examples/api-samples/views/sample11.haml +4 -0
  56. data/examples/api-samples/views/sample12.haml +4 -0
  57. data/examples/api-samples/views/sample13.haml +4 -0
  58. data/examples/api-samples/views/sample14.haml +4 -0
  59. data/examples/api-samples/views/sample15.haml +4 -0
  60. data/examples/api-samples/views/sample16.haml +4 -0
  61. data/examples/api-samples/views/sample17.haml +4 -0
  62. data/examples/api-samples/views/sample19.haml +4 -0
  63. data/examples/api-samples/views/sample2.haml +3 -2
  64. data/examples/api-samples/views/sample20.haml +4 -0
  65. data/examples/api-samples/views/sample21.haml +4 -0
  66. data/examples/api-samples/views/sample22.haml +4 -0
  67. data/examples/api-samples/views/sample23.haml +87 -0
  68. data/examples/api-samples/views/sample24.haml +44 -0
  69. data/examples/api-samples/views/sample26.haml +54 -0
  70. data/examples/api-samples/views/sample27.haml +122 -0
  71. data/examples/api-samples/views/sample28.haml +47 -0
  72. data/examples/api-samples/views/sample29.haml +70 -0
  73. data/examples/api-samples/views/sample3.haml +3 -2
  74. data/examples/api-samples/views/sample30.haml +46 -0
  75. data/examples/api-samples/views/sample31.haml +114 -0
  76. data/examples/api-samples/views/sample4.haml +3 -2
  77. data/examples/api-samples/views/sample5.haml +3 -2
  78. data/examples/api-samples/views/sample6.haml +3 -2
  79. data/examples/api-samples/views/sample7.haml +3 -2
  80. data/examples/api-samples/views/sample8.haml +3 -2
  81. data/examples/api-samples/views/sample9.haml +3 -2
  82. data/examples/viewer/Gemfile +1 -1
  83. data/groupdocs.gemspec +3 -3
  84. data/lib/groupdocs/datasource.rb +22 -0
  85. data/lib/groupdocs/document.rb +493 -43
  86. data/lib/groupdocs/document/annotation.rb +73 -0
  87. data/lib/groupdocs/job.rb +82 -1
  88. data/lib/groupdocs/post.rb +83 -0
  89. data/lib/groupdocs/questionnaire.rb +41 -0
  90. data/lib/groupdocs/signature.rb +342 -0
  91. data/lib/groupdocs/signature/envelope.rb +56 -0
  92. data/lib/groupdocs/signature/form.rb +47 -5
  93. data/lib/groupdocs/signature/shared/field_methods.rb +37 -0
  94. data/lib/groupdocs/storage/file.rb +83 -0
  95. data/lib/groupdocs/subscription.rb +218 -0
  96. data/lib/groupdocs/user.rb +422 -1
  97. data/lib/groupdocs/version.rb +1 -1
  98. data/spec/groupdocs/job_spec.rb +4 -5
  99. data/spec/groupdocs/user_spec.rb +157 -0
  100. data/spec/support/json/annotation_resize.json +11 -0
  101. data/spec/support/json/annotation_text_color.json +10 -0
  102. data/spec/support/json/annotation_text_info.json +11 -0
  103. data/spec/support/json/document_content_get.json +8 -0
  104. data/spec/support/json/document_edit_lock_get.json +10 -0
  105. data/spec/support/json/document_editlock_remove.json +8 -0
  106. data/spec/support/json/document_page_html_urls_get.json +14 -0
  107. data/spec/support/json/document_password_set.json +19 -0
  108. data/spec/support/json/document_representations.json +25 -0
  109. data/spec/support/json/document_shared_documents_get.json +32 -0
  110. data/spec/support/json/document_tags_get.json +9 -0
  111. data/spec/support/json/document_tags_remove.json +8 -0
  112. data/spec/support/json/document_tags_set.json +8 -0
  113. data/spec/support/json/document_user_status_set.json +12 -0
  114. data/spec/support/json/job_documents.json +103 -35
  115. data/spec/support/json/job_xml_get.json +30 -0
  116. data/spec/support/json/jobs_documents.json +40 -0
  117. data/spec/support/json/user_get_profile.json +73 -0
  118. metadata +49 -177
@@ -0,0 +1,143 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>sample24.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>sample24.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">'/sample24'</span> <span class="keyword">do</span>
35
+ haml <span class="symbol">:sample24</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">'/sample24'</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">:client_id</span>]
67
+ set <span class="symbol">:private_key</span>, params[<span class="symbol">:private_key</span>]
68
+ set <span class="symbol">:url</span>, params[<span class="symbol">:url</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.client_id.empty? <span class="keyword">or</span> settings.private_key.empty? <span class="keyword">or</span> settings.url.<span class="keyword">nil</span>?</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>upload web file</p>
97
+
98
+ </div>
99
+
100
+ <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload_web!(settings.url, {<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})</pre></div></div>
101
+
102
+ </li>
103
+
104
+
105
+ <li id="section-6">
106
+ <div class="annotation">
107
+
108
+ <div class="pilwrap ">
109
+ <a class="pilcrow" href="#section-6">&#182;</a>
110
+ </div>
111
+ <p>construct result messages</p>
112
+
113
+ </div>
114
+
115
+ <div class="content"><div class='highlight'><pre> message = <span class="string">"&lt;p&gt;File was uploaded to GroupDocs. Here you can see your &lt;strong&gt; file in the GroupDocs Embedded Viewer.&lt;/p&gt;"</span>
116
+ iframe = <span class="string">"&lt;iframe src='https://apps.groupdocs.com/document-viewer/Embed/<span class="subst">#{file.guid}</span>' frameborder='0' width='720' height='600'&gt;&lt;/iframe&gt;"</span>
117
+
118
+ <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e
119
+ err = e.message
120
+ <span class="keyword">end</span></pre></div></div>
121
+
122
+ </li>
123
+
124
+
125
+ <li id="section-7">
126
+ <div class="annotation">
127
+
128
+ <div class="pilwrap ">
129
+ <a class="pilcrow" href="#section-7">&#182;</a>
130
+ </div>
131
+ <p>set variables for template</p>
132
+
133
+ </div>
134
+
135
+ <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample24</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">:iframe</span> =&gt; iframe, <span class="symbol">:message</span> =&gt; message, <span class="symbol">:err</span> =&gt; err}
136
+ <span class="keyword">end</span></pre></div></div>
137
+
138
+ </li>
139
+
140
+ </ul>
141
+ </div>
142
+ </body>
143
+ </html>
@@ -0,0 +1,429 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <title>sample25.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>sample25.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">'/sample25'</span> <span class="keyword">do</span>
35
+ haml <span class="symbol">:sample25</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">'/sample25'</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">:client_id</span>]
67
+ set <span class="symbol">:private_key</span>, params[<span class="symbol">:private_key</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>]</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>Set download path</p>
82
+
83
+ </div>
84
+
85
+ <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>
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>Remove all files from download directory or create folder if it not there</p>
97
+
98
+ </div>
99
+
100
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> <span class="constant">File</span>.directory?(downloads_path)
101
+ <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> }
102
+ <span class="keyword">else</span>
103
+ <span class="constant">Dir::</span>mkdir(downloads_path)
104
+ <span class="keyword">end</span>
105
+
106
+ <span class="keyword">begin</span></pre></div></div>
107
+
108
+ </li>
109
+
110
+
111
+ <li id="section-6">
112
+ <div class="annotation">
113
+
114
+ <div class="pilwrap ">
115
+ <a class="pilcrow" href="#section-6">&#182;</a>
116
+ </div>
117
+ <p>Check required variables</p>
118
+
119
+ </div>
120
+
121
+ <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>
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>get document by file GUID</p>
133
+
134
+ </div>
135
+
136
+ <div class="content"><div class='highlight'><pre> <span class="keyword">case</span> settings.source
137
+ <span class="keyword">when</span> <span class="string">'guid'</span></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 instance of File</p>
149
+
150
+ </div>
151
+
152
+ <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})
153
+ <span class="keyword">when</span> <span class="string">'local'</span></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 path</p>
165
+
166
+ </div>
167
+
168
+ <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>
169
+
170
+ </li>
171
+
172
+
173
+ <li id="section-10">
174
+ <div class="annotation">
175
+
176
+ <div class="pilwrap ">
177
+ <a class="pilcrow" href="#section-10">&#182;</a>
178
+ </div>
179
+ <p>Open file</p>
180
+
181
+ </div>
182
+
183
+ <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>
184
+
185
+ </li>
186
+
187
+
188
+ <li id="section-11">
189
+ <div class="annotation">
190
+
191
+ <div class="pilwrap ">
192
+ <a class="pilcrow" href="#section-11">&#182;</a>
193
+ </div>
194
+ <p>Make a request to API using client_id and private_key</p>
195
+
196
+ </div>
197
+
198
+ <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload!(file_path, {}, {<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})
199
+ <span class="keyword">when</span> <span class="string">'url'</span></pre></div></div>
200
+
201
+ </li>
202
+
203
+
204
+ <li id="section-12">
205
+ <div class="annotation">
206
+
207
+ <div class="pilwrap ">
208
+ <a class="pilcrow" href="#section-12">&#182;</a>
209
+ </div>
210
+ <p>Upload file from defined url</p>
211
+
212
+ </div>
213
+
214
+ <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.upload_web!(settings.url, {<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})
215
+ <span class="keyword">else</span>
216
+ raise <span class="string">'Wrong GUID source.'</span>
217
+ <span class="keyword">end</span></pre></div></div>
218
+
219
+ </li>
220
+
221
+
222
+ <li id="section-13">
223
+ <div class="annotation">
224
+
225
+ <div class="pilwrap ">
226
+ <a class="pilcrow" href="#section-13">&#182;</a>
227
+ </div>
228
+ <p>Raise exception if something went wrong</p>
229
+
230
+ </div>
231
+
232
+ <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>
233
+
234
+ </li>
235
+
236
+
237
+ <li id="section-14">
238
+ <div class="annotation">
239
+
240
+ <div class="pilwrap ">
241
+ <a class="pilcrow" href="#section-14">&#182;</a>
242
+ </div>
243
+ <p>Make GroupDocs::Storage::Document instance</p>
244
+
245
+ </div>
246
+
247
+ <div class="content"><div class='highlight'><pre> document = file.to_document</pre></div></div>
248
+
249
+ </li>
250
+
251
+
252
+ <li id="section-15">
253
+ <div class="annotation">
254
+
255
+ <div class="pilwrap ">
256
+ <a class="pilcrow" href="#section-15">&#182;</a>
257
+ </div>
258
+ <p>Create datasource with fields</p>
259
+
260
+ </div>
261
+
262
+ <div class="content"><div class='highlight'><pre> datasource = <span class="constant">GroupDocs::DataSource</span>.new</pre></div></div>
263
+
264
+ </li>
265
+
266
+
267
+ <li id="section-16">
268
+ <div class="annotation">
269
+
270
+ <div class="pilwrap ">
271
+ <a class="pilcrow" href="#section-16">&#182;</a>
272
+ </div>
273
+ <p>Get arry of document&#39;s fields</p>
274
+
275
+ </div>
276
+
277
+ <div class="content"><div class='highlight'><pre> fields = document.fields!({<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})</pre></div></div>
278
+
279
+ </li>
280
+
281
+
282
+ <li id="section-17">
283
+ <div class="annotation">
284
+
285
+ <div class="pilwrap ">
286
+ <a class="pilcrow" href="#section-17">&#182;</a>
287
+ </div>
288
+ <p>Create Field instance and fill the fields</p>
289
+
290
+ </div>
291
+
292
+ <div class="content"><div class='highlight'><pre> datasource.fields = fields.map { |field| <span class="constant">GroupDocs::DataSource::Field</span>.new(<span class="symbol">name:</span> field.name, <span class="symbol">type:</span> <span class="symbol">:text</span>, <span class="symbol">values:</span> <span class="string">%w(value1 value2)</span>) }</pre></div></div>
293
+
294
+ </li>
295
+
296
+
297
+ <li id="section-18">
298
+ <div class="annotation">
299
+
300
+ <div class="pilwrap ">
301
+ <a class="pilcrow" href="#section-18">&#182;</a>
302
+ </div>
303
+ <p>Adds datasource.</p>
304
+
305
+ </div>
306
+
307
+ <div class="content"><div class='highlight'><pre> datasource.add!({<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})</pre></div></div>
308
+
309
+ </li>
310
+
311
+
312
+ <li id="section-19">
313
+ <div class="annotation">
314
+
315
+ <div class="pilwrap ">
316
+ <a class="pilcrow" href="#section-19">&#182;</a>
317
+ </div>
318
+ <p>Creates new job to merge datasource into document.</p>
319
+
320
+ </div>
321
+
322
+ <div class="content"><div class='highlight'><pre> job = document.datasource!(datasource, {<span class="symbol">:new_type</span> =&gt; <span class="string">'pdf'</span>}, {<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})
323
+ sleep <span class="number">10</span> <span class="comment"># wait for merge and convert</span></pre></div></div>
324
+
325
+ </li>
326
+
327
+
328
+ <li id="section-20">
329
+ <div class="annotation">
330
+
331
+ <div class="pilwrap ">
332
+ <a class="pilcrow" href="#section-20">&#182;</a>
333
+ </div>
334
+ <p>Returns an hash of input and output documents associated to job.</p>
335
+
336
+ </div>
337
+
338
+ <div class="content"><div class='highlight'><pre> document = job.documents!({<span class="symbol">:client_id</span> =&gt; settings.client_id, <span class="symbol">:private_key</span> =&gt; settings.private_key})</pre></div></div>
339
+
340
+ </li>
341
+
342
+
343
+ <li id="section-21">
344
+ <div class="annotation">
345
+
346
+ <div class="pilwrap ">
347
+ <a class="pilcrow" href="#section-21">&#182;</a>
348
+ </div>
349
+ <p>Download file</p>
350
+
351
+ </div>
352
+
353
+ <div class="content"><div class='highlight'><pre> document[<span class="symbol">:inputs</span>][<span class="number">0</span>].outputs[<span class="number">0</span>].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})</pre></div></div>
354
+
355
+ </li>
356
+
357
+
358
+ <li id="section-22">
359
+ <div class="annotation">
360
+
361
+ <div class="pilwrap ">
362
+ <a class="pilcrow" href="#section-22">&#182;</a>
363
+ </div>
364
+ <p>Set converted document GUID</p>
365
+
366
+ </div>
367
+
368
+ <div class="content"><div class='highlight'><pre> guid = document[<span class="symbol">:inputs</span>][<span class="number">0</span>].outputs[<span class="number">0</span>].guid</pre></div></div>
369
+
370
+ </li>
371
+
372
+
373
+ <li id="section-23">
374
+ <div class="annotation">
375
+
376
+ <div class="pilwrap ">
377
+ <a class="pilcrow" href="#section-23">&#182;</a>
378
+ </div>
379
+ <p>Set converted document Name</p>
380
+
381
+ </div>
382
+
383
+ <div class="content"><div class='highlight'><pre> file_name = document[<span class="symbol">:inputs</span>][<span class="number">0</span>].outputs[<span class="number">0</span>].name</pre></div></div>
384
+
385
+ </li>
386
+
387
+
388
+ <li id="section-24">
389
+ <div class="annotation">
390
+
391
+ <div class="pilwrap ">
392
+ <a class="pilcrow" href="#section-24">&#182;</a>
393
+ </div>
394
+ <p>Set iframe with document GUID or raise an error</p>
395
+
396
+ </div>
397
+
398
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> guid
399
+ iframe = <span class="string">"&lt;iframe width='100%' height='600' frameborder='0' src='https://apps.groupdocs.com/document-viewer/embed/<span class="subst">#{guid}</span>'&gt;&lt;/iframe&gt;"</span>
400
+ <span class="keyword">else</span>
401
+ raise <span class="string">'File was not converted'</span>
402
+ <span class="keyword">end</span>
403
+
404
+ <span class="keyword">rescue</span> <span class="constant">Exception</span> =&gt; e
405
+ err = e.message
406
+ <span class="keyword">end</span></pre></div></div>
407
+
408
+ </li>
409
+
410
+
411
+ <li id="section-25">
412
+ <div class="annotation">
413
+
414
+ <div class="pilwrap ">
415
+ <a class="pilcrow" href="#section-25">&#182;</a>
416
+ </div>
417
+ <p>set variables for template</p>
418
+
419
+ </div>
420
+
421
+ <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample25</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">:iframe</span> =&gt; iframe, <span class="symbol">:file_name</span> =&gt; file_name, <span class="symbol">:err</span> =&gt; err}
422
+ <span class="keyword">end</span></pre></div></div>
423
+
424
+ </li>
425
+
426
+ </ul>
427
+ </div>
428
+ </body>
429
+ </html>