examples/api-samples/public/docs/sample31.html in groupdocs-1.5.7 vs examples/api-samples/public/docs/sample31.html in groupdocs-1.5.8
- old
+ new
@@ -284,20 +284,21 @@
</div>
<p>set variables</p>
</div>
- <div class="content"><div class='highlight'><pre> set <span class="symbol">:client_id</span>, params[<span class="symbol">:client_id</span>]
- set <span class="symbol">:private_key</span>, params[<span class="symbol">:private_key</span>]
- set <span class="symbol">:template_guid</span>, params[<span class="symbol">:template_guid</span>]
+ <div class="content"><div class='highlight'><pre> set <span class="symbol">:client_id</span>, params[<span class="symbol">:clientId</span>]
+ set <span class="symbol">:private_key</span>, params[<span class="symbol">:privateKey</span>]
+ set <span class="symbol">:template_guid</span>, params[<span class="symbol">:templateGuid</span>]
set <span class="symbol">:name</span>, params[<span class="symbol">:name</span>]
set <span class="symbol">:country</span>, params[<span class="symbol">:country</span>]
set <span class="symbol">:city</span>, params[<span class="symbol">:city</span>]
set <span class="symbol">:street</span>, params[<span class="symbol">:street</span>]
set <span class="symbol">:email</span>, params[<span class="symbol">:email</span>]
set <span class="symbol">:callback</span>, params[<span class="symbol">:callback</span>]
- set <span class="symbol">:last_name</span>, params[<span class="symbol">:last_name</span>]</pre></div></div>
+ set <span class="symbol">:last_name</span>, params[<span class="symbol">:lastName</span>]
+ set <span class="symbol">:base_path</span>, params[<span class="symbol">:basePath</span>]</pre></div></div>
</li>
<li id="section-17">
@@ -344,329 +345,331 @@
</div>
<p>check required variables</p>
</div>
- <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>
+ <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">if</span> settings.base_path.empty? <span class="keyword">then</span> settings.base_path = <span class="string">'https://api.groupdocs.com'</span> <span class="keyword">end</span></pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">¶</a>
</div>
- <p>Write client and private key to the file for callback job</p>
+ <p>Configure your access to API server</p>
</div>
- <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.callback[<span class="number">0</span>]
- out_file = <span class="constant">File</span>.new(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/user_info.txt"</span>, <span class="string">'w'</span>)</pre></div></div>
+ <div class="content"><div class='highlight'><pre> <span class="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs|
+ groupdocs.client_id = settings.client_id
+ groupdocs.private_key = settings.private_key</pre></div></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">¶</a>
</div>
- <p>white space is required</p>
+ <p>Optionally specify API server and version</p>
</div>
- <div class="content"><div class='highlight'><pre> out_file.write(<span class="string">"<span class="subst">#{settings.client_id}</span> "</span>)
- out_file.write(<span class="string">"<span class="subst">#{settings.private_key}</span>"</span>)
- out_file.close
- <span class="keyword">end</span>
-
- file = <span class="keyword">nil</span></pre></div></div>
+ <div class="content"><div class='highlight'><pre> groupdocs.api_server = settings.base_path <span class="comment"># default is 'https://api.groupdocs.com'</span>
+ <span class="keyword">end</span></pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">¶</a>
</div>
- <p>Create instance of File</p>
+ <p>Write client and private key to the file for callback job</p>
</div>
- <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> => settings.template_guid})</pre></div></div>
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.callback[<span class="number">0</span>]
+ out_file = <span class="constant">File</span>.new(<span class="string">"<span class="subst">#{<span class="constant">File</span>.dirname(__FILE_<span class="number">_</span>)}</span>/../public/user_info.txt"</span>, <span class="string">'w'</span>)</pre></div></div>
</li>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">¶</a>
</div>
- <p>Raise exception if something went wrong</p>
+ <p>white space is required</p>
</div>
- <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>
+ <div class="content"><div class='highlight'><pre> out_file.write(<span class="string">"<span class="subst">#{settings.client_id}</span> "</span>)
+ out_file.write(<span class="string">"<span class="subst">#{settings.private_key}</span>"</span>)
+ out_file.close
+ <span class="keyword">end</span>
+ <span class="keyword">if</span> settings.last_name.empty?
+ settings.last_name = <span class="string">'test'</span>
+ <span class="keyword">end</span>
+ file = <span class="keyword">nil</span></pre></div></div>
</li>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">¶</a>
</div>
- <p>Make GroupDocs::Storage::Document instance</p>
+ <p>Create instance of File</p>
</div>
- <div class="content"><div class='highlight'><pre> document = file.to_document</pre></div></div>
+ <div class="content"><div class='highlight'><pre> file = <span class="constant">GroupDocs::Storage::File</span>.new({<span class="symbol">:guid</span> => settings.template_guid})</pre></div></div>
</li>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">¶</a>
</div>
- <p>Create datasource with fields</p>
+ <p>Raise exception if something went wrong</p>
</div>
- <div class="content"><div class='highlight'><pre> datasource = <span class="constant">GroupDocs::DataSource</span>.new</pre></div></div>
+ <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>
</li>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">¶</a>
</div>
- <p>Get arry of document's fields</p>
+ <p>Make GroupDocs::Storage::Document instance</p>
</div>
- <div class="content"><div class='highlight'><pre> enteredData = {<span class="string">"email"</span> => settings.email, <span class="string">"name"</span> => settings.name, <span class="string">"last_name"</span> => settings.last_name, <span class="string">"country"</span>=> settings.country, <span class="string">"city"</span> => settings.city, <span class="string">"street"</span> => settings.street}</pre></div></div>
+ <div class="content"><div class='highlight'><pre> document = file.to_document</pre></div></div>
</li>
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">¶</a>
</div>
- <p>Create Field instance and fill the fields</p>
+ <p>Create datasource with fields</p>
</div>
- <div class="content"><div class='highlight'><pre> datasource.fields = enteredData.map { |key, value| <span class="constant">GroupDocs::DataSource::Field</span>.new(<span class="symbol">name:</span> key, <span class="symbol">type:</span> <span class="symbol">:text</span>, <span class="symbol">values:</span> <span class="constant">Array</span>.new() << value) }</pre></div></div>
+ <div class="content"><div class='highlight'><pre> datasource = <span class="constant">GroupDocs::DataSource</span>.new</pre></div></div>
</li>
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">¶</a>
</div>
- <p>Adds datasource.</p>
+ <p>Get arry of document's fields</p>
</div>
- <div class="content"><div class='highlight'><pre> datasource.add!({<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})</pre></div></div>
+ <div class="content"><div class='highlight'><pre> enteredData = {<span class="string">"email"</span> => settings.email, <span class="string">"name"</span> => settings.name, <span class="string">"last_name"</span> => settings.last_name, <span class="string">"country"</span>=> settings.country, <span class="string">"city"</span> => settings.city, <span class="string">"street"</span> => settings.street}</pre></div></div>
</li>
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">¶</a>
</div>
- <p>Creates new job to merge datasource into document.</p>
+ <p>Create Field instance and fill the fields</p>
</div>
- <div class="content"><div class='highlight'><pre> job = document.datasource!(datasource, {<span class="symbol">:new_type</span> => <span class="string">"pdf"</span>}, {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})
- sleep <span class="number">10</span> <span class="comment"># wait for merge and convert</span></pre></div></div>
+ <div class="content"><div class='highlight'><pre> datasource.fields = enteredData.map { |key, value| <span class="constant">GroupDocs::DataSource::Field</span>.new(<span class="symbol">name:</span> key, <span class="symbol">type:</span> <span class="symbol">:text</span>, <span class="symbol">values:</span> <span class="constant">Array</span>.new() << value) }</pre></div></div>
</li>
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">¶</a>
</div>
- <p>Returns an hash of input and output documents associated to job.</p>
+ <p>Adds datasource.</p>
</div>
- <div class="content"><div class='highlight'><pre> jobInfo = job.documents!({<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})</pre></div></div>
+ <div class="content"><div class='highlight'><pre> datasource.add!()</pre></div></div>
</li>
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">¶</a>
</div>
- <p>Create envelope using user id and entered by user name</p>
+ <p>Creates new job to merge datasource into document.</p>
</div>
- <div class="content"><div class='highlight'><pre> envelope = <span class="constant">GroupDocs::Signature::Envelope</span>.new
- envelope.name = jobInfo[<span class="symbol">:inputs</span>][<span class="number">0</span>].outputs[<span class="number">0</span>].name
- envelope.create!({}, {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})</pre></div></div>
+ <div class="content"><div class='highlight'><pre> job = document.datasource!(datasource, {<span class="symbol">:new_type</span> => <span class="string">"pdf"</span>})
+ sleep <span class="number">10</span> <span class="comment"># wait for merge and convert</span></pre></div></div>
</li>
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">¶</a>
</div>
- <p>Add uploaded document to envelope</p>
+ <p>Returns an hash of input and output documents associated to job.</p>
</div>
- <div class="content"><div class='highlight'><pre> envelope.add_document!(document, {}, {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})</pre></div></div>
+ <div class="content"><div class='highlight'><pre> jobInfo = job.documents!()</pre></div></div>
</li>
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">¶</a>
</div>
- <p>Get role list for current user</p>
+ <p>Creates new document to envelope</p>
</div>
- <div class="content"><div class='highlight'><pre> roles = <span class="constant">GroupDocs::Signature::Role</span>.get!({}, {<span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key})</pre></div></div>
+ <div class="content"><div class='highlight'><pre> document = jobInfo[<span class="symbol">:inputs</span>][<span class="number">0</span>].outputs[<span class="number">0</span>].to_document</pre></div></div>
</li>
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">¶</a>
</div>
- <p>Create new recipient</p>
+ <p>Creates envelope using user id and entered by user name</p>
</div>
- <div class="content"><div class='highlight'><pre> recipient = <span class="constant">GroupDocs::Signature::Recipient</span>.new
- recipient.email = <span class="string">'test@test.com'</span>
- recipient.first_name = <span class="string">'test'</span>
- recipient.last_name = <span class="string">'test'</span>
- recipient.role_id = roles.detect { |role| role.name == <span class="string">'Signer'</span> }.id</pre></div></div>
+ <div class="content"><div class='highlight'><pre> envelope = <span class="constant">GroupDocs::Signature::Envelope</span>.new
+ envelope.name = jobInfo[<span class="symbol">:inputs</span>][<span class="number">0</span>].outputs[<span class="number">0</span>].name
+ envelope.create!({})</pre></div></div>
</li>
<li id="section-35">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-35">¶</a>
</div>
- <p>Add recipient to envelope</p>
+ <p>Adds uploaded document to envelope</p>
</div>
- <div class="content"><div class='highlight'><pre> envelope.add_recipient!(recipient, {<span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key})</pre></div></div>
+ <div class="content"><div class='highlight'><pre> envelope.add_document!(document, {})</pre></div></div>
</li>
<li id="section-36">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-36">¶</a>
</div>
- <p>Get field</p>
+ <p>Get role list for current user</p>
</div>
- <div class="content"><div class='highlight'><pre> fieldGet = <span class="constant">GroupDocs::Signature::Field</span>.get!({},{<span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key}).detect { |f| f.type == <span class="symbol">:signature</span> }
- fieldGet.location = { <span class="symbol">location_x:</span> <span class="number">0</span>.<span class="number">15</span>,
- <span class="symbol">location_y:</span> <span class="number">0</span>.<span class="number">73</span>,
- <span class="symbol">location_width:</span> <span class="number">150</span>,
- <span class="symbol">location_height:</span> <span class="number">50</span>,
- <span class="symbol">page:</span> <span class="number">1</span> }</pre></div></div>
+ <div class="content"><div class='highlight'><pre> roles = <span class="constant">GroupDocs::Signature::Role</span>.get!({})</pre></div></div>
</li>
<li id="section-37">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-37">¶</a>
</div>
- <p>Get document</p>
+ <p>Creates new recipient</p>
</div>
- <div class="content"><div class='highlight'><pre> documentGet = envelope.documents!({}, {<span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key}).first</pre></div></div>
+ <div class="content"><div class='highlight'><pre> recipient = <span class="constant">GroupDocs::Signature::Recipient</span>.new
+ recipient.email = settings.email
+ recipient.first_name = settings.name
+ recipient.last_name = settings.last_name
+ recipient.role_id = roles.detect { |role| role.name == <span class="string">'Signer'</span> }.id</pre></div></div>
</li>
<li id="section-38">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-38">¶</a>
</div>
- <p>Get recipients</p>
+ <p>Adds recipient to envelope</p>
</div>
- <div class="content"><div class='highlight'><pre> recipientGet = envelope.recipients!({},{<span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key}).first</pre></div></div>
+ <div class="content"><div class='highlight'><pre> envelope.add_recipient!(recipient)</pre></div></div>
</li>
<li id="section-39">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-39">¶</a>
</div>
- <p>Add field to envelope</p>
+ <p>Get recipients</p>
</div>
- <div class="content"><div class='highlight'><pre> addField = envelope.add_field!(fieldGet, documentGet, recipientGet, {}, {<span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key})</pre></div></div>
+ <div class="content"><div class='highlight'><pre> recipientGet = envelope.recipients!({}).first</pre></div></div>
</li>
<li id="section-40">
@@ -677,39 +680,77 @@
</div>
<p>Send envelope</p>
</div>
- <div class="content"><div class='highlight'><pre> envelope.send!(settings.callback, {<span class="symbol">client_id:</span> settings.client_id, <span class="symbol">private_key:</span> settings.private_key})</pre></div></div>
+ <div class="content"><div class='highlight'><pre> envelope.send!({<span class="symbol">:callbackUrl</span> => settings.callback})</pre></div></div>
</li>
<li id="section-41">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-41">¶</a>
</div>
+ <p>Get url from request</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="keyword">case</span> settings.base_path
+
+ <span class="keyword">when</span> <span class="string">'https://stage-api-groupdocs.dynabic.com'</span>
+ url = <span class="string">"http://stage-apps-groupdocs.dynabic.com/signature2/signembed/<span class="subst">#{envelope.id}</span>/<span class="subst">#{recipientGet.id}</span>"</span>
+ <span class="keyword">when</span> <span class="string">'https://dev-api-groupdocs.dynabic.com'</span>
+ url = <span class="string">"http://dev-apps-groupdocs.dynabic.com/signature2/signembed/<span class="subst">#{envelope.id}</span>/<span class="subst">#{recipientGet.id}</span>"</span>
+ <span class="keyword">else</span>
+ url = <span class="string">"https://apps.groupdocs.com/signature2/signembed/<span class="subst">#{envelope.id}</span>/<span class="subst">#{recipientGet.id}</span>"</span>
+ <span class="keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-42">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-42">¶</a>
+ </div>
+ <p>Add the signature in url</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> iframe = <span class="constant">GroupDocs::Api::Request</span>.new(<span class="symbol">:path</span> => url).prepare_and_sign_url</pre></div></div>
+
+ </li>
+
+
+ <li id="section-43">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-43">¶</a>
+ </div>
<p>Make iframe</p>
</div>
- <div class="content"><div class='highlight'><pre> iframe = <span class="string">"<iframe src='https://apps.groupdocs.com/signature/signembed/<span class="subst">#{envelope.id}</span>/<span class="subst">#{recipientGet.id}</span>' frameborder='0' width='720' height='600'></iframe>"</span>
+ <div class="content"><div class='highlight'><pre> iframe = <span class="string">"<iframe src='<span class="subst">#{iframe}</span>' frameborder='0' width='720' height='600'></iframe>"</span>
<span class="keyword">rescue</span> <span class="constant">Exception</span> => e
err = e.message
<span class="keyword">end</span></pre></div></div>
</li>
- <li id="section-42">
+ <li id="section-44">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-42">¶</a>
+ <a class="pilcrow" href="#section-44">¶</a>
</div>
<p>set variables for template</p>
</div>