groupdocs 1.2.8 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/api-samples/README.md +17 -6
- data/examples/api-samples/app.rb +0 -2
- data/examples/api-samples/public/GroupDocs_Signature_Demo.pdf +0 -0
- data/examples/api-samples/public/docs/docco.css +192 -0
- data/examples/api-samples/public/docs/envelope-sample.html +132 -0
- data/examples/api-samples/public/docs/sample1.html +26 -0
- data/examples/api-samples/public/docs/sample10.html +49 -0
- data/examples/api-samples/public/docs/sample11.html +87 -0
- data/examples/api-samples/public/docs/sample12.html +40 -0
- data/examples/api-samples/public/docs/sample13.html +41 -0
- data/examples/api-samples/public/docs/sample14.html +30 -0
- data/examples/api-samples/public/docs/sample15.html +27 -0
- data/examples/api-samples/public/docs/sample16.html +25 -0
- data/examples/api-samples/public/docs/sample17.html +37 -0
- data/examples/api-samples/public/docs/sample18.html +62 -0
- data/examples/api-samples/public/docs/sample2.html +30 -0
- data/examples/api-samples/public/docs/sample3.html +34 -0
- data/examples/api-samples/public/docs/sample4.html +41 -0
- data/examples/api-samples/public/docs/sample5.html +56 -0
- data/examples/api-samples/public/docs/sample6.html +48 -0
- data/examples/api-samples/public/docs/sample7.html +43 -0
- data/examples/api-samples/public/docs/sample8.html +54 -0
- data/examples/api-samples/public/docs/sample9.html +31 -0
- data/examples/api-samples/samples/envelope-sample.rb +132 -0
- data/examples/api-samples/samples/sample1.rb +10 -2
- data/examples/api-samples/samples/sample10.rb +17 -5
- data/examples/api-samples/samples/sample11.rb +86 -0
- data/examples/api-samples/samples/sample12.rb +39 -0
- data/examples/api-samples/samples/sample13.rb +40 -0
- data/examples/api-samples/samples/sample14.rb +29 -0
- data/examples/api-samples/samples/sample15.rb +26 -0
- data/examples/api-samples/samples/sample16.rb +24 -0
- data/examples/api-samples/samples/sample17.rb +36 -0
- data/examples/api-samples/samples/sample18.rb +61 -0
- data/examples/api-samples/samples/sample2.rb +14 -4
- data/examples/api-samples/samples/sample3.rb +14 -4
- data/examples/api-samples/samples/sample4.rb +12 -3
- data/examples/api-samples/samples/sample5.rb +13 -2
- data/examples/api-samples/samples/sample6.rb +18 -6
- data/examples/api-samples/samples/sample7.rb +9 -0
- data/examples/api-samples/samples/sample8.rb +17 -4
- data/examples/api-samples/samples/sample9.rb +10 -2
- data/examples/api-samples/views/envelope_sample.haml +73 -0
- data/examples/api-samples/views/index.haml +18 -0
- data/examples/api-samples/views/sample1.haml +21 -0
- data/examples/api-samples/views/sample10.haml +21 -0
- data/examples/api-samples/views/sample11.haml +141 -0
- data/examples/api-samples/views/sample12.haml +94 -0
- data/examples/api-samples/views/sample13.haml +90 -0
- data/examples/api-samples/views/sample14.haml +86 -0
- data/examples/api-samples/views/sample15.haml +75 -0
- data/examples/api-samples/views/sample16.haml +68 -0
- data/examples/api-samples/views/sample17.haml +80 -0
- data/examples/api-samples/views/sample18.haml +87 -0
- data/examples/api-samples/views/sample2.haml +21 -0
- data/examples/api-samples/views/sample3.haml +23 -2
- data/examples/api-samples/views/sample4.haml +21 -0
- data/examples/api-samples/views/sample5.haml +21 -0
- data/examples/api-samples/views/sample6.haml +22 -1
- data/examples/api-samples/views/sample7.haml +21 -0
- data/examples/api-samples/views/sample8.haml +22 -1
- data/examples/api-samples/views/sample9.haml +21 -0
- data/lib/groupdocs/job.rb +5 -3
- data/lib/groupdocs/user.rb +33 -0
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/job_spec.rb +5 -0
- data/spec/groupdocs/user_spec.rb +22 -0
- data/spec/support/json/update_account.json +10 -0
- metadata +45 -4
@@ -1,12 +1,23 @@
|
|
1
1
|
## Examples
|
2
2
|
|
3
|
-
###
|
4
|
-
Grab the copy of examples
|
3
|
+
### GroupDocs Ruby SDK Example App
|
5
4
|
|
5
|
+
####Grab the copy of examples from GitHub:
|
6
|
+
1) git clone git@github.com:groupdocs/groupdocs-ruby.git
|
7
|
+
2) cd to examples/api-samples or copy api-samples folder somethere
|
8
|
+
|
9
|
+
####Install bundler:
|
6
10
|
gem install bundler # unless it's already installed
|
7
|
-
|
8
|
-
|
9
|
-
bundle install
|
11
|
+
|
12
|
+
####Install dependecies:
|
13
|
+
bundle install
|
14
|
+
|
15
|
+
####Run the web app:
|
10
16
|
bundle exec ruby app.rb
|
11
17
|
|
12
|
-
Now open `http://localhost:4567` and try it!
|
18
|
+
####Now open `http://localhost:4567` and try it!
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
### Live Demo
|
23
|
+
See live demo for api samples [here](http://groupdocs-ruby-samples.herokuapp.com)
|
data/examples/api-samples/app.rb
CHANGED
Binary file
|
@@ -0,0 +1,192 @@
|
|
1
|
+
/*--------------------- Layout and Typography ----------------------------*/
|
2
|
+
body {
|
3
|
+
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
4
|
+
font-size: 15px;
|
5
|
+
line-height: 22px;
|
6
|
+
color: #252519;
|
7
|
+
margin: 0; padding: 0;
|
8
|
+
}
|
9
|
+
a {
|
10
|
+
color: #261a3b;
|
11
|
+
}
|
12
|
+
a:visited {
|
13
|
+
color: #261a3b;
|
14
|
+
}
|
15
|
+
p {
|
16
|
+
margin: 0 0 15px 0;
|
17
|
+
}
|
18
|
+
h1, h2, h3, h4, h5, h6 {
|
19
|
+
margin: 0px 0 15px 0;
|
20
|
+
}
|
21
|
+
h1 {
|
22
|
+
margin-top: 40px;
|
23
|
+
}
|
24
|
+
hr {
|
25
|
+
border: 0 none;
|
26
|
+
border-top: 1px solid #e5e5ee;
|
27
|
+
height: 1px;
|
28
|
+
margin: 20px 0;
|
29
|
+
}
|
30
|
+
#container {
|
31
|
+
position: relative;
|
32
|
+
}
|
33
|
+
#background {
|
34
|
+
position: fixed;
|
35
|
+
top: 0; left: 525px; right: 0; bottom: 0;
|
36
|
+
background: #f5f5ff;
|
37
|
+
border-left: 1px solid #e5e5ee;
|
38
|
+
z-index: -1;
|
39
|
+
}
|
40
|
+
#jump_to, #jump_page {
|
41
|
+
background: white;
|
42
|
+
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
|
43
|
+
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
|
44
|
+
font: 10px Arial;
|
45
|
+
text-transform: uppercase;
|
46
|
+
cursor: pointer;
|
47
|
+
text-align: right;
|
48
|
+
}
|
49
|
+
#jump_to, #jump_wrapper {
|
50
|
+
position: fixed;
|
51
|
+
right: 0; top: 0;
|
52
|
+
padding: 5px 10px;
|
53
|
+
}
|
54
|
+
#jump_wrapper {
|
55
|
+
padding: 0;
|
56
|
+
display: none;
|
57
|
+
}
|
58
|
+
#jump_to:hover #jump_wrapper {
|
59
|
+
display: block;
|
60
|
+
}
|
61
|
+
#jump_page {
|
62
|
+
padding: 5px 0 3px;
|
63
|
+
margin: 0 0 25px 25px;
|
64
|
+
}
|
65
|
+
#jump_page .source {
|
66
|
+
display: block;
|
67
|
+
padding: 5px 10px;
|
68
|
+
text-decoration: none;
|
69
|
+
border-top: 1px solid #eee;
|
70
|
+
}
|
71
|
+
#jump_page .source:hover {
|
72
|
+
background: #f5f5ff;
|
73
|
+
}
|
74
|
+
#jump_page .source:first-child {
|
75
|
+
}
|
76
|
+
table td {
|
77
|
+
border: 0;
|
78
|
+
outline: 0;
|
79
|
+
}
|
80
|
+
td.docs, th.docs {
|
81
|
+
max-width: 450px;
|
82
|
+
min-width: 450px;
|
83
|
+
min-height: 5px;
|
84
|
+
padding: 10px 25px 1px 50px;
|
85
|
+
overflow-x: hidden;
|
86
|
+
vertical-align: top;
|
87
|
+
text-align: left;
|
88
|
+
}
|
89
|
+
.docs pre {
|
90
|
+
margin: 15px 0 15px;
|
91
|
+
padding-left: 15px;
|
92
|
+
}
|
93
|
+
.docs p tt, .docs p code {
|
94
|
+
background: #f8f8ff;
|
95
|
+
border: 1px solid #dedede;
|
96
|
+
font-size: 12px;
|
97
|
+
padding: 0 0.2em;
|
98
|
+
}
|
99
|
+
.pilwrap {
|
100
|
+
position: relative;
|
101
|
+
}
|
102
|
+
.pilcrow {
|
103
|
+
font: 12px Arial;
|
104
|
+
text-decoration: none;
|
105
|
+
color: #454545;
|
106
|
+
position: absolute;
|
107
|
+
top: 3px; left: -20px;
|
108
|
+
padding: 1px 2px;
|
109
|
+
opacity: 0;
|
110
|
+
-webkit-transition: opacity 0.2s linear;
|
111
|
+
}
|
112
|
+
td.docs:hover .pilcrow {
|
113
|
+
opacity: 1;
|
114
|
+
}
|
115
|
+
td.code, th.code {
|
116
|
+
padding: 14px 15px 16px 25px;
|
117
|
+
width: 100%;
|
118
|
+
vertical-align: top;
|
119
|
+
background: #f5f5ff;
|
120
|
+
border-left: 1px solid #e5e5ee;
|
121
|
+
}
|
122
|
+
pre, tt, code {
|
123
|
+
font-size: 12px; line-height: 18px;
|
124
|
+
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
|
125
|
+
margin: 0; padding: 0;
|
126
|
+
}
|
127
|
+
|
128
|
+
|
129
|
+
/*---------------------- Syntax Highlighting -----------------------------*/
|
130
|
+
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
|
131
|
+
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
|
132
|
+
body .hll { background-color: #ffffcc }
|
133
|
+
body .c { color: #408080; font-style: italic } /* Comment */
|
134
|
+
body .err { border: 1px solid #FF0000 } /* Error */
|
135
|
+
body .k { color: #954121 } /* Keyword */
|
136
|
+
body .o { color: #666666 } /* Operator */
|
137
|
+
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
138
|
+
body .cp { color: #BC7A00 } /* Comment.Preproc */
|
139
|
+
body .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
140
|
+
body .cs { color: #408080; font-style: italic } /* Comment.Special */
|
141
|
+
body .gd { color: #A00000 } /* Generic.Deleted */
|
142
|
+
body .ge { font-style: italic } /* Generic.Emph */
|
143
|
+
body .gr { color: #FF0000 } /* Generic.Error */
|
144
|
+
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
145
|
+
body .gi { color: #00A000 } /* Generic.Inserted */
|
146
|
+
body .go { color: #808080 } /* Generic.Output */
|
147
|
+
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
148
|
+
body .gs { font-weight: bold } /* Generic.Strong */
|
149
|
+
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
150
|
+
body .gt { color: #0040D0 } /* Generic.Traceback */
|
151
|
+
body .kc { color: #954121 } /* Keyword.Constant */
|
152
|
+
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
|
153
|
+
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
|
154
|
+
body .kp { color: #954121 } /* Keyword.Pseudo */
|
155
|
+
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
|
156
|
+
body .kt { color: #B00040 } /* Keyword.Type */
|
157
|
+
body .m { color: #666666 } /* Literal.Number */
|
158
|
+
body .s { color: #219161 } /* Literal.String */
|
159
|
+
body .na { color: #7D9029 } /* Name.Attribute */
|
160
|
+
body .nb { color: #954121 } /* Name.Builtin */
|
161
|
+
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
162
|
+
body .no { color: #880000 } /* Name.Constant */
|
163
|
+
body .nd { color: #AA22FF } /* Name.Decorator */
|
164
|
+
body .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
165
|
+
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
166
|
+
body .nf { color: #0000FF } /* Name.Function */
|
167
|
+
body .nl { color: #A0A000 } /* Name.Label */
|
168
|
+
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
169
|
+
body .nt { color: #954121; font-weight: bold } /* Name.Tag */
|
170
|
+
body .nv { color: #19469D } /* Name.Variable */
|
171
|
+
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
172
|
+
body .w { color: #bbbbbb } /* Text.Whitespace */
|
173
|
+
body .mf { color: #666666 } /* Literal.Number.Float */
|
174
|
+
body .mh { color: #666666 } /* Literal.Number.Hex */
|
175
|
+
body .mi { color: #666666 } /* Literal.Number.Integer */
|
176
|
+
body .mo { color: #666666 } /* Literal.Number.Oct */
|
177
|
+
body .sb { color: #219161 } /* Literal.String.Backtick */
|
178
|
+
body .sc { color: #219161 } /* Literal.String.Char */
|
179
|
+
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
|
180
|
+
body .s2 { color: #219161 } /* Literal.String.Double */
|
181
|
+
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
182
|
+
body .sh { color: #219161 } /* Literal.String.Heredoc */
|
183
|
+
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
184
|
+
body .sx { color: #954121 } /* Literal.String.Other */
|
185
|
+
body .sr { color: #BB6688 } /* Literal.String.Regex */
|
186
|
+
body .s1 { color: #219161 } /* Literal.String.Single */
|
187
|
+
body .ss { color: #19469D } /* Literal.String.Symbol */
|
188
|
+
body .bp { color: #954121 } /* Name.Builtin.Pseudo */
|
189
|
+
body .vc { color: #19469D } /* Name.Variable.Class */
|
190
|
+
body .vg { color: #19469D } /* Name.Variable.Global */
|
191
|
+
body .vi { color: #19469D } /* Name.Variable.Instance */
|
192
|
+
body .il { color: #666666 } /* Literal.Number.Integer.Long */
|
@@ -0,0 +1,132 @@
|
|
1
|
+
<!DOCTYPE html> <html> <head> <title>envelope-sample.rb</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To … <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="envelope-sample.html"> envelope-sample.rb </a> <a class="source" href="sample1.html"> sample1.rb </a> <a class="source" href="sample10.html"> sample10.rb </a> <a class="source" href="sample11.html"> sample11.rb </a> <a class="source" href="sample12.html"> sample12.rb </a> <a class="source" href="sample13.html"> sample13.rb </a> <a class="source" href="sample14.html"> sample14.rb </a> <a class="source" href="sample15.html"> sample15.rb </a> <a class="source" href="sample16.html"> sample16.rb </a> <a class="source" href="sample17.html"> sample17.rb </a> <a class="source" href="sample18.html"> sample18.rb </a> <a class="source" href="sample2.html"> sample2.rb </a> <a class="source" href="sample3.html"> sample3.rb </a> <a class="source" href="sample4.html"> sample4.rb </a> <a class="source" href="sample5.html"> sample5.rb </a> <a class="source" href="sample6.html"> sample6.rb </a> <a class="source" href="sample7.html"> sample7.rb </a> <a class="source" href="sample8.html"> sample8.rb </a> <a class="source" href="sample9.html"> sample9.rb </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> envelope-sample.rb </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">¶</a> </div> <p>GET request</p> </td> <td class="code"> <div class="highlight"><pre><span class="n">get</span> <span class="s1">'/envelope-sample'</span> <span class="k">do</span>
|
2
|
+
<span class="n">haml</span> <span class="ss">:envelope_sample</span>
|
3
|
+
<span class="k">end</span>
|
4
|
+
|
5
|
+
|
6
|
+
<span class="n">post</span> <span class="s1">'/envelope-sample/sign'</span> <span class="k">do</span>
|
7
|
+
|
8
|
+
<span class="n">data</span> <span class="o">=</span> <span class="no">JSON</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">body</span><span class="o">.</span><span class="n">read</span><span class="p">)</span>
|
9
|
+
<span class="k">begin</span>
|
10
|
+
<span class="k">raise</span> <span class="s2">"Empty params!"</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">empty?</span>
|
11
|
+
|
12
|
+
|
13
|
+
<span class="n">outFile</span> <span class="o">=</span> <span class="no">File</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s2">"signed"</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span>
|
14
|
+
<span class="n">data</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">|</span>
|
15
|
+
<span class="n">outFile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="si">#{</span><span class="n">key</span><span class="si">}</span><span class="s2">: </span><span class="si">#{</span><span class="n">value</span><span class="si">}</span><span class="s2"> </span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>
|
16
|
+
<span class="k">end</span>
|
17
|
+
<span class="n">outFile</span><span class="o">.</span><span class="n">close</span>
|
18
|
+
<span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
|
19
|
+
<span class="n">err</span> <span class="o">=</span> <span class="n">e</span><span class="o">.</span><span class="n">message</span>
|
20
|
+
<span class="k">end</span>
|
21
|
+
<span class="k">end</span>
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
<span class="n">post</span> <span class="s1">'/envelope-sample/sign-and-download'</span> <span class="k">do</span>
|
26
|
+
<span class="n">data</span> <span class="o">=</span> <span class="no">JSON</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">body</span><span class="o">.</span><span class="n">read</span><span class="p">)</span>
|
27
|
+
<span class="k">begin</span>
|
28
|
+
<span class="k">raise</span> <span class="s2">"Empty params!"</span> <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">empty?</span>
|
29
|
+
<span class="no">GroupDocs</span><span class="o">.</span><span class="n">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">groupdocs</span><span class="o">|</span>
|
30
|
+
<span class="n">groupdocs</span><span class="o">.</span><span class="n">client_id</span> <span class="o">=</span> <span class="s1">''</span> <span class="c1"># Your client Client ID here</span>
|
31
|
+
<span class="n">groupdocs</span><span class="o">.</span><span class="n">private_key</span> <span class="o">=</span> <span class="s1">''</span> <span class="c1"># Your API Key here</span>
|
32
|
+
<span class="n">groupdocs</span><span class="o">.</span><span class="n">api_server</span> <span class="o">=</span> <span class="s1">'https://api.groupdocs.com'</span>
|
33
|
+
<span class="k">end</span>
|
34
|
+
<span class="n">data</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="o">|</span>
|
35
|
+
<span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s1">'SourceId'</span>
|
36
|
+
|
37
|
+
<span class="n">envelope</span> <span class="o">=</span> <span class="ss">GroupDocs</span><span class="p">:</span><span class="ss">:Signature</span><span class="o">::</span><span class="no">Envelope</span><span class="o">.</span><span class="n">new</span> <span class="nb">id</span><span class="p">:</span> <span class="n">value</span><span class="p">,</span>
|
38
|
+
<span class="nb">name</span><span class="p">:</span> <span class="n">value</span>
|
39
|
+
|
40
|
+
<span class="n">envelope</span><span class="o">.</span><span class="n">signed_documents!</span> <span class="s1">'.'</span>
|
41
|
+
<span class="k">end</span>
|
42
|
+
<span class="k">end</span>
|
43
|
+
<span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
|
44
|
+
<span class="n">err</span> <span class="o">=</span> <span class="n">e</span><span class="o">.</span><span class="n">message</span>
|
45
|
+
<span class="k">end</span>
|
46
|
+
<span class="k">end</span>
|
47
|
+
|
48
|
+
|
49
|
+
<span class="n">get</span> <span class="s1">'/envelope-sample/check'</span> <span class="k">do</span>
|
50
|
+
<span class="k">if</span> <span class="no">File</span><span class="o">.</span><span class="n">exist?</span><span class="p">(</span><span class="s1">'signed'</span><span class="p">)</span>
|
51
|
+
<span class="no">File</span><span class="o">.</span><span class="n">readlines</span><span class="p">(</span><span class="s1">'signed'</span><span class="p">)</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">line</span><span class="o">|</span>
|
52
|
+
<span class="k">end</span>
|
53
|
+
<span class="k">else</span>
|
54
|
+
<span class="s1">'Have not signed yet'</span>
|
55
|
+
<span class="k">end</span>
|
56
|
+
<span class="k">end</span>
|
57
|
+
|
58
|
+
|
59
|
+
<span class="n">post</span> <span class="s1">'/envelope-sample'</span> <span class="k">do</span>
|
60
|
+
<span class="n">set</span> <span class="ss">:client_id</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:client_id</span><span class="o">]</span>
|
61
|
+
<span class="n">set</span> <span class="ss">:private_key</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:private_key</span><span class="o">]</span>
|
62
|
+
|
63
|
+
<span class="k">begin</span>
|
64
|
+
<span class="k">raise</span> <span class="s2">"Please enter all required parameters"</span> <span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="o">.</span><span class="n">empty?</span> <span class="ow">or</span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="o">.</span><span class="n">empty?</span>
|
65
|
+
|
66
|
+
<span class="no">GroupDocs</span><span class="o">.</span><span class="n">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">groupdocs</span><span class="o">|</span>
|
67
|
+
<span class="n">groupdocs</span><span class="o">.</span><span class="n">client_id</span> <span class="o">=</span> <span class="n">params</span><span class="o">[</span><span class="ss">:client_id</span><span class="o">]</span>
|
68
|
+
<span class="n">groupdocs</span><span class="o">.</span><span class="n">private_key</span> <span class="o">=</span> <span class="n">params</span><span class="o">[</span><span class="ss">:private_key</span><span class="o">]</span>
|
69
|
+
<span class="n">groupdocs</span><span class="o">.</span><span class="n">api_server</span> <span class="o">=</span> <span class="s1">'https://api.groupdocs.com'</span>
|
70
|
+
<span class="k">end</span>
|
71
|
+
|
72
|
+
|
73
|
+
<span class="n">filepath</span> <span class="o">=</span> <span class="s2">"</span><span class="si">#{</span><span class="no">Dir</span><span class="o">.</span><span class="n">tmpdir</span><span class="si">}</span><span class="s2">/</span><span class="si">#{</span><span class="n">params</span><span class="o">[</span><span class="ss">:file</span><span class="o">][</span><span class="ss">:filename</span><span class="o">]</span><span class="si">}</span><span class="s2">"</span>
|
74
|
+
<span class="no">File</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span> <span class="s1">'wb'</span><span class="p">)</span> <span class="p">{</span> <span class="o">|</span><span class="n">f</span><span class="o">|</span> <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">params</span><span class="o">[</span><span class="ss">:file</span><span class="o">][</span><span class="ss">:tempfile</span><span class="o">].</span><span class="n">read</span><span class="p">)</span> <span class="p">}</span>
|
75
|
+
<span class="n">file</span> <span class="o">=</span> <span class="ss">GroupDocs</span><span class="p">:</span><span class="ss">:Storage</span><span class="o">::</span><span class="no">File</span><span class="o">.</span><span class="n">upload!</span><span class="p">(</span><span class="n">filepath</span><span class="p">,</span> <span class="p">{},</span> <span class="n">client_id</span><span class="p">:</span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="p">,</span> <span class="n">private_key</span><span class="p">:</span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="p">)</span>
|
76
|
+
<span class="n">document</span> <span class="o">=</span> <span class="n">file</span><span class="o">.</span><span class="n">to_document</span>
|
77
|
+
|
78
|
+
|
79
|
+
<span class="n">envelope</span> <span class="o">=</span> <span class="ss">GroupDocs</span><span class="p">:</span><span class="ss">:Signature</span><span class="o">::</span><span class="no">Envelope</span><span class="o">.</span><span class="n">new</span>
|
80
|
+
<span class="n">envelope</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s2">"Envelope"</span>
|
81
|
+
<span class="n">envelope</span><span class="o">.</span><span class="n">email_subject</span> <span class="o">=</span> <span class="s2">"Sing this!"</span>
|
82
|
+
<span class="n">envelope</span><span class="o">.</span><span class="n">create!</span>
|
83
|
+
|
84
|
+
|
85
|
+
<span class="n">envelope</span><span class="o">.</span><span class="n">add_document!</span> <span class="n">document</span>
|
86
|
+
|
87
|
+
|
88
|
+
<span class="n">document</span> <span class="o">=</span> <span class="n">envelope</span><span class="o">.</span><span class="n">documents!</span><span class="o">.</span><span class="n">first</span>
|
89
|
+
|
90
|
+
|
91
|
+
<span class="n">roles</span> <span class="o">=</span> <span class="ss">GroupDocs</span><span class="p">:</span><span class="ss">:Signature</span><span class="o">::</span><span class="no">Role</span><span class="o">.</span><span class="n">get!</span>
|
92
|
+
<span class="n">recipient</span> <span class="o">=</span> <span class="ss">GroupDocs</span><span class="p">:</span><span class="ss">:Signature</span><span class="o">::</span><span class="no">Recipient</span><span class="o">.</span><span class="n">new</span>
|
93
|
+
<span class="n">recipient</span><span class="o">.</span><span class="n">email</span> <span class="o">=</span> <span class="s1">'john@smith.com'</span>
|
94
|
+
<span class="n">recipient</span><span class="o">.</span><span class="n">first_name</span> <span class="o">=</span> <span class="s1">'John'</span>
|
95
|
+
<span class="n">recipient</span><span class="o">.</span><span class="n">last_name</span> <span class="o">=</span> <span class="s1">'Smith'</span>
|
96
|
+
<span class="n">recipient</span><span class="o">.</span><span class="n">role_id</span> <span class="o">=</span> <span class="n">roles</span><span class="o">.</span><span class="n">detect</span> <span class="p">{</span> <span class="o">|</span><span class="n">role</span><span class="o">|</span> <span class="n">role</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s2">"Signer"</span> <span class="p">}</span><span class="o">.</span><span class="n">id</span>
|
97
|
+
<span class="n">envelope</span><span class="o">.</span><span class="n">add_recipient!</span> <span class="n">recipient</span>
|
98
|
+
|
99
|
+
|
100
|
+
<span class="n">recipient</span> <span class="o">=</span> <span class="n">envelope</span><span class="o">.</span><span class="n">recipients!</span><span class="o">.</span><span class="n">first</span>
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
field = GroupDocs::Signature::Field.get!.detect { |f| f.type == :single<em>line }
|
106
|
+
field.name = 'City'
|
107
|
+
field.location = { location</em>x: 0.3, location<em>y: 0.2, page: 1 }
|
108
|
+
envelope.add</em>field! field, document, recipient</p> </td> <td class="code"> <div class="highlight"><pre>
|
109
|
+
|
110
|
+
|
111
|
+
field = GroupDocs::Signature::Field.get!.detect { |f| f.type == :signature }
|
112
|
+
field.location = { location<em>x: 0.3, location</em>y: 0.3, page: 1 }
|
113
|
+
envelope.add_field! field, document, recipient</p> </td> <td class="code"> <div class="highlight"><pre>
|
114
|
+
|
115
|
+
|
116
|
+
<span class="n">webhook</span> <span class="o">=</span> <span class="s1">'http://groupdocs-ruby-samples.herokuapp.com/envelope-sample/sign'</span>
|
117
|
+
|
118
|
+
|
119
|
+
<span class="n">envelope</span><span class="o">.</span><span class="n">send!</span> <span class="n">webhook</span>
|
120
|
+
|
121
|
+
|
122
|
+
<span class="n">url</span> <span class="o">=</span> <span class="s2">"https://apps.groupdocs.com/signature/signembed/</span><span class="si">#{</span><span class="n">envelope</span><span class="o">.</span><span class="n">id</span><span class="si">}</span><span class="s2">/</span><span class="si">#{</span><span class="n">recipient</span><span class="o">.</span><span class="n">id</span><span class="si">}</span><span class="s2">"</span>
|
123
|
+
<span class="n">iframe</span> <span class="o">=</span> <span class="s2">"<iframe src='</span><span class="si">#{</span><span class="n">url</span><span class="si">}</span><span class="s2">' frameborder='0' width='720' height='600'></iframe>"</span>
|
124
|
+
|
125
|
+
<span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
|
126
|
+
<span class="n">err</span> <span class="o">=</span> <span class="n">e</span><span class="o">.</span><span class="n">message</span>
|
127
|
+
<span class="k">end</span>
|
128
|
+
|
129
|
+
<span class="n">haml</span> <span class="ss">:envelope_sample</span><span class="p">,</span> <span class="ss">:locals</span> <span class="o">=></span> <span class="p">{</span> <span class="ss">:client_id</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="p">,</span> <span class="ss">:private_key</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="p">,</span> <span class="ss">:err</span> <span class="o">=></span> <span class="n">err</span><span class="p">,</span> <span class="ss">:iframe</span> <span class="o">=></span> <span class="n">iframe</span><span class="p">}</span>
|
130
|
+
<span class="k">end</span>
|
131
|
+
|
132
|
+
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html> <html> <head> <title>sample1.rb</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To … <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="envelope-sample.html"> envelope-sample.rb </a> <a class="source" href="sample1.html"> sample1.rb </a> <a class="source" href="sample10.html"> sample10.rb </a> <a class="source" href="sample11.html"> sample11.rb </a> <a class="source" href="sample12.html"> sample12.rb </a> <a class="source" href="sample13.html"> sample13.rb </a> <a class="source" href="sample14.html"> sample14.rb </a> <a class="source" href="sample15.html"> sample15.rb </a> <a class="source" href="sample16.html"> sample16.rb </a> <a class="source" href="sample17.html"> sample17.rb </a> <a class="source" href="sample18.html"> sample18.rb </a> <a class="source" href="sample2.html"> sample2.rb </a> <a class="source" href="sample3.html"> sample3.rb </a> <a class="source" href="sample4.html"> sample4.rb </a> <a class="source" href="sample5.html"> sample5.rb </a> <a class="source" href="sample6.html"> sample6.rb </a> <a class="source" href="sample7.html"> sample7.rb </a> <a class="source" href="sample8.html"> sample8.rb </a> <a class="source" href="sample9.html"> sample9.rb </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> sample1.rb </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">¶</a> </div> <p>GET request</p> </td> <td class="code"> <div class="highlight"><pre><span class="n">get</span> <span class="s1">'/sample1'</span> <span class="k">do</span>
|
2
|
+
<span class="n">haml</span> <span class="ss">:sample1</span>
|
3
|
+
<span class="k">end</span>
|
4
|
+
|
5
|
+
|
6
|
+
<span class="n">post</span> <span class="s1">'/sample1'</span> <span class="k">do</span>
|
7
|
+
|
8
|
+
<span class="n">set</span> <span class="ss">:client_id</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:client_id</span><span class="o">]</span>
|
9
|
+
<span class="n">set</span> <span class="ss">:private_key</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:private_key</span><span class="o">]</span>
|
10
|
+
|
11
|
+
<span class="k">begin</span>
|
12
|
+
|
13
|
+
<span class="k">raise</span> <span class="s2">"Please enter all required parameters"</span> <span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="o">.</span><span class="n">empty?</span> <span class="ow">or</span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="o">.</span><span class="n">empty?</span>
|
14
|
+
|
15
|
+
|
16
|
+
<span class="n">user</span> <span class="o">=</span> <span class="ss">GroupDocs</span><span class="p">:</span><span class="ss">:User</span><span class="o">.</span><span class="n">get!</span><span class="p">({</span><span class="ss">:client_id</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="p">,</span> <span class="ss">:private_key</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="p">})</span>
|
17
|
+
|
18
|
+
<span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
|
19
|
+
<span class="n">err</span> <span class="o">=</span> <span class="n">e</span><span class="o">.</span><span class="n">message</span>
|
20
|
+
<span class="k">end</span>
|
21
|
+
|
22
|
+
|
23
|
+
<span class="n">haml</span> <span class="ss">:sample1</span><span class="p">,</span> <span class="ss">:locals</span> <span class="o">=></span> <span class="p">{</span> <span class="ss">:userId</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="p">,</span> <span class="ss">:privateKey</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="p">,</span> <span class="ss">:user</span> <span class="o">=></span> <span class="n">user</span><span class="p">,</span> <span class="ss">:err</span> <span class="o">=></span> <span class="n">err</span> <span class="p">}</span>
|
24
|
+
<span class="k">end</span>
|
25
|
+
|
26
|
+
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<!DOCTYPE html> <html> <head> <title>sample10.rb</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To … <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="envelope-sample.html"> envelope-sample.rb </a> <a class="source" href="sample1.html"> sample1.rb </a> <a class="source" href="sample10.html"> sample10.rb </a> <a class="source" href="sample11.html"> sample11.rb </a> <a class="source" href="sample12.html"> sample12.rb </a> <a class="source" href="sample13.html"> sample13.rb </a> <a class="source" href="sample14.html"> sample14.rb </a> <a class="source" href="sample15.html"> sample15.rb </a> <a class="source" href="sample16.html"> sample16.rb </a> <a class="source" href="sample17.html"> sample17.rb </a> <a class="source" href="sample18.html"> sample18.rb </a> <a class="source" href="sample2.html"> sample2.rb </a> <a class="source" href="sample3.html"> sample3.rb </a> <a class="source" href="sample4.html"> sample4.rb </a> <a class="source" href="sample5.html"> sample5.rb </a> <a class="source" href="sample6.html"> sample6.rb </a> <a class="source" href="sample7.html"> sample7.rb </a> <a class="source" href="sample8.html"> sample8.rb </a> <a class="source" href="sample9.html"> sample9.rb </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> sample10.rb </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">¶</a> </div> <p>GET request</p> </td> <td class="code"> <div class="highlight"><pre><span class="n">get</span> <span class="s1">'/sample10'</span> <span class="k">do</span>
|
2
|
+
<span class="n">haml</span> <span class="ss">:sample10</span>
|
3
|
+
<span class="k">end</span>
|
4
|
+
|
5
|
+
|
6
|
+
<span class="n">post</span> <span class="s1">'/sample10'</span> <span class="k">do</span>
|
7
|
+
|
8
|
+
<span class="n">set</span> <span class="ss">:client_id</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:client_id</span><span class="o">]</span>
|
9
|
+
<span class="n">set</span> <span class="ss">:private_key</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:private_key</span><span class="o">]</span>
|
10
|
+
<span class="n">set</span> <span class="ss">:guid</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:guid</span><span class="o">]</span>
|
11
|
+
<span class="n">set</span> <span class="ss">:email</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:email</span><span class="o">]</span>
|
12
|
+
|
13
|
+
<span class="k">begin</span>
|
14
|
+
|
15
|
+
<span class="k">raise</span> <span class="s2">"Please enter all required parameters"</span> <span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="o">.</span><span class="n">empty?</span> <span class="ow">or</span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="o">.</span><span class="n">empty?</span> <span class="ow">or</span> <span class="n">settings</span><span class="o">.</span><span class="n">guid</span><span class="o">.</span><span class="n">empty?</span> <span class="ow">or</span> <span class="n">settings</span><span class="o">.</span><span class="n">email</span><span class="o">.</span><span class="n">empty?</span>
|
16
|
+
|
17
|
+
|
18
|
+
<span class="n">files_list</span> <span class="o">=</span> <span class="ss">GroupDocs</span><span class="p">:</span><span class="ss">:Storage</span><span class="o">::</span><span class="no">Folder</span><span class="o">.</span><span class="n">list!</span><span class="p">(</span><span class="s1">'/'</span><span class="p">,</span> <span class="p">{},</span> <span class="p">{</span> <span class="ss">:client_id</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="p">,</span> <span class="ss">:private_key</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="p">})</span>
|
19
|
+
|
20
|
+
<span class="nb">name</span> <span class="o">=</span> <span class="kp">nil</span>
|
21
|
+
<span class="n">doc</span> <span class="o">=</span> <span class="kp">nil</span>
|
22
|
+
<span class="n">files_list</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">element</span><span class="o">|</span>
|
23
|
+
<span class="k">if</span> <span class="n">element</span><span class="o">.</span><span class="n">class</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">'::'</span><span class="p">)</span><span class="o">.</span><span class="n">last</span> <span class="o">==</span> <span class="s1">'Folder'</span>
|
24
|
+
<span class="k">next</span>
|
25
|
+
<span class="k">end</span>
|
26
|
+
|
27
|
+
|
28
|
+
<span class="k">if</span> <span class="n">element</span><span class="o">.</span><span class="n">guid</span> <span class="o">==</span> <span class="n">settings</span><span class="o">.</span><span class="n">guid</span>
|
29
|
+
<span class="nb">name</span> <span class="o">=</span> <span class="n">element</span><span class="o">.</span><span class="n">name</span>
|
30
|
+
<span class="n">doc</span> <span class="o">=</span> <span class="n">element</span>
|
31
|
+
<span class="k">end</span>
|
32
|
+
<span class="k">end</span>
|
33
|
+
|
34
|
+
|
35
|
+
<span class="n">shared</span> <span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span class="n">to_document</span><span class="o">.</span><span class="n">sharers_set!</span><span class="p">(</span><span class="n">settings</span><span class="o">.</span><span class="n">email</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">),</span> <span class="p">{</span> <span class="ss">:client_id</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="p">,</span> <span class="ss">:private_key</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="p">});</span>
|
36
|
+
|
37
|
+
|
38
|
+
<span class="k">if</span> <span class="n">shared</span>
|
39
|
+
<span class="n">shared_emails</span> <span class="o">=</span> <span class="n">settings</span><span class="o">.</span><span class="n">email</span>
|
40
|
+
<span class="k">end</span>
|
41
|
+
<span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
|
42
|
+
<span class="n">err</span> <span class="o">=</span> <span class="n">e</span><span class="o">.</span><span class="n">message</span>
|
43
|
+
<span class="k">end</span>
|
44
|
+
|
45
|
+
|
46
|
+
<span class="n">haml</span> <span class="ss">:sample10</span><span class="p">,</span> <span class="ss">:locals</span> <span class="o">=></span> <span class="p">{</span> <span class="ss">:client_id</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">client_id</span><span class="p">,</span> <span class="ss">:private_key</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">private_key</span><span class="p">,</span> <span class="ss">:guid</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">guid</span><span class="p">,</span> <span class="ss">:email</span><span class="o">=></span><span class="n">settings</span><span class="o">.</span><span class="n">email</span><span class="p">,</span> <span class="ss">:shared</span> <span class="o">=></span> <span class="n">shared_emails</span><span class="p">,</span> <span class="ss">:err</span> <span class="o">=></span> <span class="n">err</span> <span class="p">}</span>
|
47
|
+
<span class="k">end</span>
|
48
|
+
|
49
|
+
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
|