groupdocs 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/README.md +2 -0
- data/examples/api-samples/public/docs/annotation-sample.html +167 -57
- data/examples/api-samples/public/docs/docco.css +459 -151
- data/examples/api-samples/public/docs/envelope-sample.html +373 -131
- data/examples/api-samples/public/docs/sample1.html +126 -26
- data/examples/api-samples/public/docs/sample10.html +213 -50
- data/examples/api-samples/public/docs/sample11.html +319 -87
- data/examples/api-samples/public/docs/sample12.html +165 -40
- data/examples/api-samples/public/docs/sample13.html +166 -41
- data/examples/api-samples/public/docs/sample14.html +142 -30
- data/examples/api-samples/public/docs/sample15.html +127 -27
- data/examples/api-samples/public/docs/sample16.html +125 -25
- data/examples/api-samples/public/docs/sample17.html +188 -37
- data/examples/api-samples/public/docs/sample18.html +614 -157
- data/examples/api-samples/public/docs/sample19.html +221 -59
- data/examples/api-samples/public/docs/sample2.html +142 -30
- data/examples/api-samples/public/docs/sample20.html +176 -51
- data/examples/api-samples/public/docs/sample21.html +287 -66
- data/examples/api-samples/public/docs/sample22.html +224 -53
- data/examples/api-samples/public/docs/sample23.html +256 -0
- data/examples/api-samples/public/docs/sample24.html +143 -0
- data/examples/api-samples/public/docs/sample25.html +429 -0
- data/examples/api-samples/public/docs/sample26.html +113 -0
- data/examples/api-samples/public/docs/sample27.html +433 -0
- data/examples/api-samples/public/docs/sample28.html +185 -0
- data/examples/api-samples/public/docs/sample29.html +175 -0
- data/examples/api-samples/public/docs/sample3.html +172 -34
- data/examples/api-samples/public/docs/sample30.html +144 -0
- data/examples/api-samples/public/docs/sample31.html +734 -0
- data/examples/api-samples/public/docs/sample4.html +204 -52
- data/examples/api-samples/public/docs/sample5.html +241 -63
- data/examples/api-samples/public/docs/sample6.html +209 -48
- data/examples/api-samples/public/docs/sample7.html +155 -43
- data/examples/api-samples/public/docs/sample8.html +235 -62
- data/examples/api-samples/public/docs/sample9.html +200 -49
- data/examples/api-samples/public/templates/merge_field1_doc.docx +0 -0
- data/examples/api-samples/public/templates/merge_field2_doc.docx +0 -0
- data/examples/api-samples/samples/sample23.rb +54 -0
- data/examples/api-samples/samples/sample24.rb +30 -0
- data/examples/api-samples/samples/sample25.rb +4 -4
- data/examples/api-samples/samples/sample26.rb +25 -0
- data/examples/api-samples/samples/sample27.rb +100 -0
- data/examples/api-samples/samples/sample28.rb +47 -0
- data/examples/api-samples/samples/sample29.rb +52 -0
- data/examples/api-samples/samples/sample30.rb +39 -0
- data/examples/api-samples/samples/sample31.rb +204 -0
- data/examples/api-samples/samples/sample5.rb +5 -3
- data/examples/api-samples/samples/sample6.rb +2 -0
- data/examples/api-samples/views/_others_samples.haml +12 -0
- data/examples/api-samples/views/index.haml +12 -0
- data/examples/api-samples/views/layout.haml +1 -0
- data/examples/api-samples/views/sample1.haml +3 -2
- data/examples/api-samples/views/sample10.haml +3 -2
- data/examples/api-samples/views/sample11.haml +4 -0
- data/examples/api-samples/views/sample12.haml +4 -0
- data/examples/api-samples/views/sample13.haml +4 -0
- data/examples/api-samples/views/sample14.haml +4 -0
- data/examples/api-samples/views/sample15.haml +4 -0
- data/examples/api-samples/views/sample16.haml +4 -0
- data/examples/api-samples/views/sample17.haml +4 -0
- data/examples/api-samples/views/sample19.haml +4 -0
- data/examples/api-samples/views/sample2.haml +3 -2
- data/examples/api-samples/views/sample20.haml +4 -0
- data/examples/api-samples/views/sample21.haml +4 -0
- data/examples/api-samples/views/sample22.haml +4 -0
- data/examples/api-samples/views/sample23.haml +87 -0
- data/examples/api-samples/views/sample24.haml +44 -0
- data/examples/api-samples/views/sample26.haml +54 -0
- data/examples/api-samples/views/sample27.haml +122 -0
- data/examples/api-samples/views/sample28.haml +47 -0
- data/examples/api-samples/views/sample29.haml +70 -0
- data/examples/api-samples/views/sample3.haml +3 -2
- data/examples/api-samples/views/sample30.haml +46 -0
- data/examples/api-samples/views/sample31.haml +114 -0
- data/examples/api-samples/views/sample4.haml +3 -2
- data/examples/api-samples/views/sample5.haml +3 -2
- data/examples/api-samples/views/sample6.haml +3 -2
- data/examples/api-samples/views/sample7.haml +3 -2
- data/examples/api-samples/views/sample8.haml +3 -2
- data/examples/api-samples/views/sample9.haml +3 -2
- data/examples/viewer/Gemfile +1 -1
- data/groupdocs.gemspec +3 -3
- data/lib/groupdocs/datasource.rb +22 -0
- data/lib/groupdocs/document.rb +493 -43
- data/lib/groupdocs/document/annotation.rb +73 -0
- data/lib/groupdocs/job.rb +82 -1
- data/lib/groupdocs/post.rb +83 -0
- data/lib/groupdocs/questionnaire.rb +41 -0
- data/lib/groupdocs/signature.rb +342 -0
- data/lib/groupdocs/signature/envelope.rb +56 -0
- data/lib/groupdocs/signature/form.rb +47 -5
- data/lib/groupdocs/signature/shared/field_methods.rb +37 -0
- data/lib/groupdocs/storage/file.rb +83 -0
- data/lib/groupdocs/subscription.rb +218 -0
- data/lib/groupdocs/user.rb +422 -1
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/job_spec.rb +4 -5
- data/spec/groupdocs/user_spec.rb +157 -0
- data/spec/support/json/annotation_resize.json +11 -0
- data/spec/support/json/annotation_text_color.json +10 -0
- data/spec/support/json/annotation_text_info.json +11 -0
- data/spec/support/json/document_content_get.json +8 -0
- data/spec/support/json/document_edit_lock_get.json +10 -0
- data/spec/support/json/document_editlock_remove.json +8 -0
- data/spec/support/json/document_page_html_urls_get.json +14 -0
- data/spec/support/json/document_password_set.json +19 -0
- data/spec/support/json/document_representations.json +25 -0
- data/spec/support/json/document_shared_documents_get.json +32 -0
- data/spec/support/json/document_tags_get.json +9 -0
- data/spec/support/json/document_tags_remove.json +8 -0
- data/spec/support/json/document_tags_set.json +8 -0
- data/spec/support/json/document_user_status_set.json +12 -0
- data/spec/support/json/job_documents.json +103 -35
- data/spec/support/json/job_xml_get.json +30 -0
- data/spec/support/json/jobs_documents.json +40 -0
- data/spec/support/json/user_get_profile.json +73 -0
- metadata +49 -177
@@ -1,26 +1,126 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
<
|
7
|
-
|
8
|
-
<
|
9
|
-
|
10
|
-
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
<
|
25
|
-
|
26
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>sample1.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>sample1.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">¶</a>
|
29
|
+
</div>
|
30
|
+
<p>GET request</p>
|
31
|
+
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="content"><div class='highlight'><pre>get <span class="string">'/sample1'</span> <span class="keyword">do</span>
|
35
|
+
haml <span class="symbol">:sample1</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">¶</a>
|
46
|
+
</div>
|
47
|
+
<p>POST request</p>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="content"><div class='highlight'><pre>post <span class="string">'/sample1'</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">¶</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
|
+
|
69
|
+
<span class="keyword">begin</span></pre></div></div>
|
70
|
+
|
71
|
+
</li>
|
72
|
+
|
73
|
+
|
74
|
+
<li id="section-4">
|
75
|
+
<div class="annotation">
|
76
|
+
|
77
|
+
<div class="pilwrap ">
|
78
|
+
<a class="pilcrow" href="#section-4">¶</a>
|
79
|
+
</div>
|
80
|
+
<p>check required variables</p>
|
81
|
+
|
82
|
+
</div>
|
83
|
+
|
84
|
+
<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>
|
85
|
+
|
86
|
+
</li>
|
87
|
+
|
88
|
+
|
89
|
+
<li id="section-5">
|
90
|
+
<div class="annotation">
|
91
|
+
|
92
|
+
<div class="pilwrap ">
|
93
|
+
<a class="pilcrow" href="#section-5">¶</a>
|
94
|
+
</div>
|
95
|
+
<p>make a request to API using client_id and private_key</p>
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
<div class="content"><div class='highlight'><pre> user = <span class="constant">GroupDocs::User</span>.get!({<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})
|
100
|
+
|
101
|
+
<span class="keyword">rescue</span> <span class="constant">Exception</span> => e
|
102
|
+
err = e.message
|
103
|
+
<span class="keyword">end</span></pre></div></div>
|
104
|
+
|
105
|
+
</li>
|
106
|
+
|
107
|
+
|
108
|
+
<li id="section-6">
|
109
|
+
<div class="annotation">
|
110
|
+
|
111
|
+
<div class="pilwrap ">
|
112
|
+
<a class="pilcrow" href="#section-6">¶</a>
|
113
|
+
</div>
|
114
|
+
<p>set variables for template</p>
|
115
|
+
|
116
|
+
</div>
|
117
|
+
|
118
|
+
<div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample1</span>, <span class="symbol">:locals</span> => {<span class="symbol">:userId</span> => settings.client_id, <span class="symbol">:privateKey</span> => settings.private_key, <span class="symbol">:user</span> => user, <span class="symbol">:err</span> => err}
|
119
|
+
<span class="keyword">end</span></pre></div></div>
|
120
|
+
|
121
|
+
</li>
|
122
|
+
|
123
|
+
</ul>
|
124
|
+
</div>
|
125
|
+
</body>
|
126
|
+
</html>
|
@@ -1,50 +1,213 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
<
|
7
|
-
|
8
|
-
<
|
9
|
-
|
10
|
-
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
<
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>sample10.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>sample10.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">¶</a>
|
29
|
+
</div>
|
30
|
+
<p>GET request</p>
|
31
|
+
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="content"><div class='highlight'><pre>get <span class="string">'/sample10'</span> <span class="keyword">do</span>
|
35
|
+
haml <span class="symbol">:sample10</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">¶</a>
|
46
|
+
</div>
|
47
|
+
<p>POST request</p>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="content"><div class='highlight'><pre>post <span class="string">'/sample10'</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">¶</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">:guid</span>, params[<span class="symbol">:fileId</span>]
|
69
|
+
set <span class="symbol">:email</span>, params[<span class="symbol">:email</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">¶</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? <span class="keyword">or</span> settings.guid.empty? <span class="keyword">or</span> settings.email.empty?</pre></div></div>
|
87
|
+
|
88
|
+
</li>
|
89
|
+
|
90
|
+
|
91
|
+
<li id="section-5">
|
92
|
+
<div class="annotation">
|
93
|
+
|
94
|
+
<div class="pilwrap ">
|
95
|
+
<a class="pilcrow" href="#section-5">¶</a>
|
96
|
+
</div>
|
97
|
+
<p>get document by file GUID</p>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
<div class="content"><div class='highlight'><pre> file = <span class="keyword">nil</span>
|
102
|
+
<span class="keyword">case</span> settings.source
|
103
|
+
<span class="keyword">when</span> <span class="string">'guid'</span>
|
104
|
+
file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> => settings.guid})
|
105
|
+
<span class="keyword">when</span> <span class="string">'local'</span></pre></div></div>
|
106
|
+
|
107
|
+
</li>
|
108
|
+
|
109
|
+
|
110
|
+
<li id="section-6">
|
111
|
+
<div class="annotation">
|
112
|
+
|
113
|
+
<div class="pilwrap ">
|
114
|
+
<a class="pilcrow" href="#section-6">¶</a>
|
115
|
+
</div>
|
116
|
+
<p>construct path</p>
|
117
|
+
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<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
|
+
|
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">¶</a>
|
130
|
+
</div>
|
131
|
+
<p>open file</p>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<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>
|
136
|
+
|
137
|
+
</li>
|
138
|
+
|
139
|
+
|
140
|
+
<li id="section-8">
|
141
|
+
<div class="annotation">
|
142
|
+
|
143
|
+
<div class="pilwrap ">
|
144
|
+
<a class="pilcrow" href="#section-8">¶</a>
|
145
|
+
</div>
|
146
|
+
<p>make a request to API using client_id and private_key</p>
|
147
|
+
|
148
|
+
</div>
|
149
|
+
|
150
|
+
<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)
|
151
|
+
<span class="keyword">when</span> <span class="string">'url'</span>
|
152
|
+
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)
|
153
|
+
<span class="keyword">else</span>
|
154
|
+
raise <span class="string">'Wrong GUID source.'</span>
|
155
|
+
<span class="keyword">end</span></pre></div></div>
|
156
|
+
|
157
|
+
</li>
|
158
|
+
|
159
|
+
|
160
|
+
<li id="section-9">
|
161
|
+
<div class="annotation">
|
162
|
+
|
163
|
+
<div class="pilwrap ">
|
164
|
+
<a class="pilcrow" href="#section-9">¶</a>
|
165
|
+
</div>
|
166
|
+
<p>Share document. Make a request to API using client_id and private_key</p>
|
167
|
+
|
168
|
+
</div>
|
169
|
+
|
170
|
+
<div class="content"><div class='highlight'><pre> shared = file.to_document.sharers_set!(settings.email.split(<span class="string">' '</span>), {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})</pre></div></div>
|
171
|
+
|
172
|
+
</li>
|
173
|
+
|
174
|
+
|
175
|
+
<li id="section-10">
|
176
|
+
<div class="annotation">
|
177
|
+
|
178
|
+
<div class="pilwrap ">
|
179
|
+
<a class="pilcrow" href="#section-10">¶</a>
|
180
|
+
</div>
|
181
|
+
<p>result</p>
|
182
|
+
|
183
|
+
</div>
|
184
|
+
|
185
|
+
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> shared
|
186
|
+
shared_emails = settings.email
|
187
|
+
<span class="keyword">end</span>
|
188
|
+
<span class="keyword">rescue</span> <span class="constant">Exception</span> => e
|
189
|
+
err = e.message
|
190
|
+
<span class="keyword">end</span></pre></div></div>
|
191
|
+
|
192
|
+
</li>
|
193
|
+
|
194
|
+
|
195
|
+
<li id="section-11">
|
196
|
+
<div class="annotation">
|
197
|
+
|
198
|
+
<div class="pilwrap ">
|
199
|
+
<a class="pilcrow" href="#section-11">¶</a>
|
200
|
+
</div>
|
201
|
+
<p>set variables for template</p>
|
202
|
+
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample10</span>, <span class="symbol">:locals</span> => {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key, <span class="symbol">:guid</span> => settings.guid, <span class="symbol">:email</span> => settings.email, <span class="symbol">:shared</span> => shared_emails, <span class="symbol">:err</span> => err}
|
206
|
+
<span class="keyword">end</span></pre></div></div>
|
207
|
+
|
208
|
+
</li>
|
209
|
+
|
210
|
+
</ul>
|
211
|
+
</div>
|
212
|
+
</body>
|
213
|
+
</html>
|
@@ -1,87 +1,319 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
<
|
7
|
-
|
8
|
-
<
|
9
|
-
|
10
|
-
|
11
|
-
<
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>sample11.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>sample11.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">¶</a>
|
29
|
+
</div>
|
30
|
+
<p>GET request</p>
|
31
|
+
|
32
|
+
</div>
|
33
|
+
|
34
|
+
<div class="content"><div class='highlight'><pre>get <span class="string">'/sample11'</span> <span class="keyword">do</span>
|
35
|
+
haml <span class="symbol">:sample11</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">¶</a>
|
46
|
+
</div>
|
47
|
+
<p>POST request</p>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<div class="content"><div class='highlight'><pre>post <span class="string">'/sample11'</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">¶</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">:file_id</span>, params[<span class="symbol">:fileId</span>]
|
69
|
+
set <span class="symbol">:annotation_type</span>, params[<span class="symbol">:annotation_type</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">¶</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? <span class="keyword">or</span> settings.file_id.empty? <span class="keyword">or</span> settings.annotation_type.empty?</pre></div></div>
|
87
|
+
|
88
|
+
</li>
|
89
|
+
|
90
|
+
|
91
|
+
<li id="section-5">
|
92
|
+
<div class="annotation">
|
93
|
+
|
94
|
+
<div class="pilwrap ">
|
95
|
+
<a class="pilcrow" href="#section-5">¶</a>
|
96
|
+
</div>
|
97
|
+
<p>annotation types</p>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
<div class="content"><div class='highlight'><pre> types = {<span class="symbol">:text</span> => <span class="number">0</span>, <span class="symbol">:area</span> => <span class="number">1</span>, <span class="symbol">:point</span> => <span class="number">2</span>}</pre></div></div>
|
102
|
+
|
103
|
+
</li>
|
104
|
+
|
105
|
+
|
106
|
+
<li id="section-6">
|
107
|
+
<div class="annotation">
|
108
|
+
|
109
|
+
<div class="pilwrap ">
|
110
|
+
<a class="pilcrow" href="#section-6">¶</a>
|
111
|
+
</div>
|
112
|
+
<p>required parameters</p>
|
113
|
+
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<div class="content"><div class='highlight'><pre> all_params = all_params = [<span class="string">'annotation_type'</span>, <span class="string">'box_x'</span>, <span class="string">'box_y'</span>, <span class="string">'text'</span>]</pre></div></div>
|
117
|
+
|
118
|
+
</li>
|
119
|
+
|
120
|
+
|
121
|
+
<li id="section-7">
|
122
|
+
<div class="annotation">
|
123
|
+
|
124
|
+
<div class="pilwrap ">
|
125
|
+
<a class="pilcrow" href="#section-7">¶</a>
|
126
|
+
</div>
|
127
|
+
<p>added required parameters depends on annotation type ['text' or 'area']</p>
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.annotation_type == <span class="string">'text'</span>
|
132
|
+
all_params = all_params | [<span class="string">'box_width'</span>, <span class="string">'box_height'</span>, <span class="string">'annotationPosition_x'</span>, <span class="string">'annotationPosition_y'</span>]
|
133
|
+
<span class="keyword">elsif</span> settings.annotation_type == <span class="string">'area'</span>
|
134
|
+
all_params = all_params | [<span class="string">'box_width'</span>, <span class="string">'box_height'</span>]
|
135
|
+
<span class="keyword">end</span></pre></div></div>
|
136
|
+
|
137
|
+
</li>
|
138
|
+
|
139
|
+
|
140
|
+
<li id="section-8">
|
141
|
+
<div class="annotation">
|
142
|
+
|
143
|
+
<div class="pilwrap ">
|
144
|
+
<a class="pilcrow" href="#section-8">¶</a>
|
145
|
+
</div>
|
146
|
+
<p>checking required parameters</p>
|
147
|
+
|
148
|
+
</div>
|
149
|
+
|
150
|
+
<div class="content"><div class='highlight'><pre> all_params.each <span class="keyword">do</span> |param|
|
151
|
+
raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> params[param].empty?
|
152
|
+
<span class="keyword">end</span></pre></div></div>
|
153
|
+
|
154
|
+
</li>
|
155
|
+
|
156
|
+
|
157
|
+
<li id="section-9">
|
158
|
+
<div class="annotation">
|
159
|
+
|
160
|
+
<div class="pilwrap ">
|
161
|
+
<a class="pilcrow" href="#section-9">¶</a>
|
162
|
+
</div>
|
163
|
+
<p>make a request to API using client_id and private_key</p>
|
164
|
+
|
165
|
+
</div>
|
166
|
+
|
167
|
+
<div class="content"><div class='highlight'><pre> files_list = <span class="constant">GroupDocs::Storage::Folder</span>.list!(<span class="string">'/'</span>, {}, {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})
|
168
|
+
document = <span class="string">''</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">¶</a>
|
178
|
+
</div>
|
179
|
+
<p>get document by file ID</p>
|
180
|
+
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<div class="content"><div class='highlight'><pre> files_list.each <span class="keyword">do</span> |element|
|
184
|
+
<span class="keyword">if</span> element.respond_to?(<span class="string">'guid'</span>) == <span class="keyword">true</span> <span class="keyword">and</span> element.guid == settings.file_id
|
185
|
+
document = element
|
186
|
+
<span class="keyword">end</span>
|
187
|
+
<span class="keyword">end</span>
|
188
|
+
|
189
|
+
<span class="keyword">unless</span> document.instance_of? <span class="constant">String</span></pre></div></div>
|
190
|
+
|
191
|
+
</li>
|
192
|
+
|
193
|
+
|
194
|
+
<li id="section-11">
|
195
|
+
<div class="annotation">
|
196
|
+
|
197
|
+
<div class="pilwrap ">
|
198
|
+
<a class="pilcrow" href="#section-11">¶</a>
|
199
|
+
</div>
|
200
|
+
<p>start create new annotation</p>
|
201
|
+
|
202
|
+
</div>
|
203
|
+
|
204
|
+
<div class="content"><div class='highlight'><pre> annotation = <span class="constant">GroupDocs::Document::Annotation</span>.new(<span class="symbol">document:</span> document.to_document)
|
205
|
+
annotation.type = types[settings.annotation_type]</pre></div></div>
|
206
|
+
|
207
|
+
</li>
|
208
|
+
|
209
|
+
|
210
|
+
<li id="section-12">
|
211
|
+
<div class="annotation">
|
212
|
+
|
213
|
+
<div class="pilwrap ">
|
214
|
+
<a class="pilcrow" href="#section-12">¶</a>
|
215
|
+
</div>
|
216
|
+
<p>construct requestBody depends on annotation type
|
217
|
+
text annotation</p>
|
218
|
+
|
219
|
+
</div>
|
220
|
+
|
221
|
+
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.annotation_type == <span class="string">'text'</span>
|
222
|
+
annotation.box = {<span class="symbol">x:</span> params[<span class="string">'box_x'</span>], <span class="symbol">y:</span> params[<span class="string">'box_y'</span>], <span class="symbol">width:</span> params[<span class="string">'box_width'</span>], <span class="symbol">height:</span> params[<span class="string">'box_height'</span>]}
|
223
|
+
annotation.annotationPosition = {<span class="symbol">x:</span> params[<span class="string">'annotationPosition_x'</span>], <span class="symbol">y:</span> params[<span class="string">'annotationPosition_y'</span>]}</pre></div></div>
|
224
|
+
|
225
|
+
</li>
|
226
|
+
|
227
|
+
|
228
|
+
<li id="section-13">
|
229
|
+
<div class="annotation">
|
230
|
+
|
231
|
+
<div class="pilwrap ">
|
232
|
+
<a class="pilcrow" href="#section-13">¶</a>
|
233
|
+
</div>
|
234
|
+
<p>area annotation</p>
|
235
|
+
|
236
|
+
</div>
|
237
|
+
|
238
|
+
<div class="content"><div class='highlight'><pre> <span class="keyword">elsif</span> settings.annotation_type == <span class="string">'area'</span>
|
239
|
+
annotation.box = {<span class="symbol">x:</span> params[<span class="string">'box_x'</span>], <span class="symbol">y:</span> params[<span class="string">'box_y'</span>], <span class="symbol">width:</span> params[<span class="string">'box_width'</span>], <span class="symbol">height:</span> params[<span class="string">'box_height'</span>]}
|
240
|
+
annotation.annotationPosition = {<span class="symbol">x:</span> <span class="number">0</span>, <span class="symbol">y:</span> <span class="number">0</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">¶</a>
|
250
|
+
</div>
|
251
|
+
<p>point annotation</p>
|
252
|
+
|
253
|
+
</div>
|
254
|
+
|
255
|
+
<div class="content"><div class='highlight'><pre> <span class="keyword">elsif</span> settings.annotation_type == <span class="string">'point'</span>
|
256
|
+
annotation.box = {<span class="symbol">x:</span> params[<span class="string">'box_x'</span>], <span class="symbol">y:</span> params[<span class="string">'box_y'</span>], <span class="symbol">width:</span> <span class="number">0</span>, <span class="symbol">height:</span> <span class="number">0</span>}
|
257
|
+
annotation.annotationPosition = {<span class="symbol">x:</span> <span class="number">0</span>, <span class="symbol">y:</span> <span class="number">0</span>}
|
258
|
+
<span class="keyword">end</span></pre></div></div>
|
259
|
+
|
260
|
+
</li>
|
261
|
+
|
262
|
+
|
263
|
+
<li id="section-15">
|
264
|
+
<div class="annotation">
|
265
|
+
|
266
|
+
<div class="pilwrap ">
|
267
|
+
<a class="pilcrow" href="#section-15">¶</a>
|
268
|
+
</div>
|
269
|
+
<p>call create method</p>
|
270
|
+
|
271
|
+
</div>
|
272
|
+
|
273
|
+
<div class="content"><div class='highlight'><pre> annotation.create!({<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})</pre></div></div>
|
274
|
+
|
275
|
+
</li>
|
276
|
+
|
277
|
+
|
278
|
+
<li id="section-16">
|
279
|
+
<div class="annotation">
|
280
|
+
|
281
|
+
<div class="pilwrap ">
|
282
|
+
<a class="pilcrow" href="#section-16">¶</a>
|
283
|
+
</div>
|
284
|
+
<p>add annotation reply</p>
|
285
|
+
|
286
|
+
</div>
|
287
|
+
|
288
|
+
<div class="content"><div class='highlight'><pre> reply = <span class="constant">GroupDocs::Document::Annotation::Reply</span>.new(<span class="symbol">annotation:</span> annotation)
|
289
|
+
reply.text = params[<span class="string">'text'</span>]
|
290
|
+
reply.create!({<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})
|
291
|
+
|
292
|
+
<span class="keyword">end</span>
|
293
|
+
|
294
|
+
<span class="keyword">rescue</span> <span class="constant">Exception</span> => e
|
295
|
+
err = e.message
|
296
|
+
<span class="keyword">end</span></pre></div></div>
|
297
|
+
|
298
|
+
</li>
|
299
|
+
|
300
|
+
|
301
|
+
<li id="section-17">
|
302
|
+
<div class="annotation">
|
303
|
+
|
304
|
+
<div class="pilwrap ">
|
305
|
+
<a class="pilcrow" href="#section-17">¶</a>
|
306
|
+
</div>
|
307
|
+
<p>set variables for template</p>
|
308
|
+
|
309
|
+
</div>
|
310
|
+
|
311
|
+
<div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample11</span>, <span class="symbol">:locals</span> => {<span class="symbol">:userId</span> => settings.client_id, <span class="symbol">:privateKey</span> => settings.private_key, <span class="symbol">:fileId</span> => settings.file_id, <span class="symbol">:annotationType</span> => settings.annotation_type, <span class="symbol">:annotationId</span> => (<span class="keyword">defined</span>? annotation.id) ? annotation.id <span class="symbol">:</span> <span class="keyword">nil</span>, <span class="symbol">:annotationText</span> => params[<span class="string">'text'</span>], <span class="symbol">:err</span> => err}
|
312
|
+
<span class="keyword">end</span></pre></div></div>
|
313
|
+
|
314
|
+
</li>
|
315
|
+
|
316
|
+
</ul>
|
317
|
+
</div>
|
318
|
+
</body>
|
319
|
+
</html>
|