examples/api-samples/public/docs/sample33.html in groupdocs-1.5.8 vs examples/api-samples/public/docs/sample33.html in groupdocs-1.5.9
- old
+ new
@@ -57,11 +57,11 @@
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">¶</a>
</div>
- <p>set variables</p>
+ <p>Set variables</p>
</div>
<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>]
@@ -83,23 +83,42 @@
</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? <span class="keyword">or</span> settings.url_1.empty? <span class="keyword">or</span> settings.url_2.empty? <span class="keyword">or</span> settings.url_3.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>
+ <div class="content"><div class='highlight'><pre> raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> settings.client_id.empty? <span class="keyword">or</span> settings.private_key.empty? <span class="keyword">or</span> settings.url_1.empty? <span class="keyword">or</span> settings.url_2.empty? <span class="keyword">or</span> settings.url_3.empty?</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">¶</a>
</div>
+ <p>Prepare base path</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.base_path.empty?
+ base_path = <span class="string">'https://api.groupdocs.com'</span>
+ <span class="keyword">elsif</span> settings.base_path.match(<span class="string">'/v2.0'</span>)
+ base_path = settings.base_path.split(<span class="string">'/v2.0'</span>)[<span class="number">0</span>]
+ <span class="keyword">else</span>
+ base_path = settings.base_path
+ <span class="keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-6">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-6">¶</a>
+ </div>
<p>Configure your access to API server</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="constant">GroupDocs</span>.configure <span class="keyword">do</span> |groupdocs|
@@ -107,76 +126,77 @@
groupdocs.private_key = settings.private_key</pre></div></div>
</li>
- <li id="section-6">
+ <li id="section-7">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-6">¶</a>
+ <a class="pilcrow" href="#section-7">¶</a>
</div>
<p>Optionally specify API server and version</p>
</div>
- <div class="content"><div class='highlight'><pre> groupdocs.api_server = settings.base_path <span class="comment"># default is 'https://api.groupdocs.com'</span>
+ <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="comment"># default is 'https://api.groupdocs.com'</span>
+
<span class="keyword">end</span></pre></div></div>
</li>
- <li id="section-7">
+ <li id="section-8">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-7">¶</a>
+ <a class="pilcrow" href="#section-8">¶</a>
</div>
<p>Create Array from variables</p>
</div>
<div class="content"><div class='highlight'><pre> url = [settings.url_1, settings.url_2, settings.url_3 ]</pre></div></div>
</li>
- <li id="section-8">
+ <li id="section-9">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-8">¶</a>
+ <a class="pilcrow" href="#section-9">¶</a>
</div>
<p>Create Hash with the options for job. :status=> -1 means the Draft status of the job</p>
</div>
<div class="content"><div class='highlight'><pre> options = {<span class="symbol">:actions</span> => [<span class="symbol">:convert</span>, <span class="symbol">:combine</span>], <span class="symbol">:out_formats</span> => [<span class="string">'pdf'</span>], <span class="symbol">:status</span> => -<span class="number">1</span>, <span class="symbol">:name</span> => <span class="string">'sample'</span>}</pre></div></div>
</li>
- <li id="section-9">
+ <li id="section-10">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-9">¶</a>
+ <a class="pilcrow" href="#section-10">¶</a>
</div>
<p>Create Job with provided options with Draft status (Sheduled job)</p>
</div>
<div class="content"><div class='highlight'><pre> job = <span class="constant">GroupDocs::Job</span>.create!(options)</pre></div></div>
</li>
- <li id="section-10">
+ <li id="section-11">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-10">¶</a>
+ <a class="pilcrow" href="#section-11">¶</a>
</div>
<p>Upload documents to GroupDocs Storage by url and add the documents to previously created Job</p>
</div>
@@ -186,15 +206,15 @@
<span class="keyword">end</span></pre></div></div>
</li>
- <li id="section-11">
+ <li id="section-12">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-11">¶</a>
+ <a class="pilcrow" href="#section-12">¶</a>
</div>
<p>Update the Job with new status. :status => '0' mean Active status of the job (Start the job)</p>
</div>
@@ -210,15 +230,15 @@
<span class="keyword">end</span></pre></div></div>
</li>
- <li id="section-12">
+ <li id="section-13">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-12">¶</a>
+ <a class="pilcrow" href="#section-13">¶</a>
</div>
<p>Get the document into Pdf format</p>
</div>
@@ -227,74 +247,103 @@
document = file[<span class="symbol">:outputs</span>]</pre></div></div>
</li>
- <li id="section-13">
+ <li id="section-14">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-13">¶</a>
+ <a class="pilcrow" href="#section-14">¶</a>
</div>
<p>Set iframe with document GUID or raise an error</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="keyword">if</span> document</pre></div></div>
</li>
- <li id="section-14">
+ <li id="section-15">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-14">¶</a>
+ <a class="pilcrow" href="#section-15">¶</a>
</div>
- <p>Get url from request</p>
+ <p>Prepare to sign url</p>
</div>
- <div class="content"><div class='highlight'><pre> <span class="keyword">case</span> settings.base_path
-
+ <div class="content"><div class='highlight'><pre> iframe = <span class="string">"/document-viewer/embed/<span class="subst">#{document[<span class="number">0</span>].guid}</span>"</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-16">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-16">¶</a>
+ </div>
+ <p>Construct result string</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> url = <span class="constant">GroupDocs::Api::Request</span>.new(<span class="symbol">:path</span> => iframe).prepare_and_sign_url</pre></div></div>
+
+ </li>
+
+
+ <li id="section-17">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-17">¶</a>
+ </div>
+ <p>Generate iframe URL</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="keyword">case</span> 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/document-viewer/embed/<span class="subst">#{document[<span class="number">0</span>].guid}</span>"</span>
+ iframe = <span class="string">"https://stage-api-groupdocs.dynabic.com<span class="subst">#{url}</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/document-viewer/embed/<span class="subst">#{document[<span class="number">0</span>].guid}</span>"</span>
+ iframe = <span class="string">"https://dev-apps.groupdocs.com<span class="subst">#{url}</span>"</span>
<span class="keyword">else</span>
- url = <span class="string">"https://apps.groupdocs.com/document-viewer/embed/<span class="subst">#{document[<span class="number">0</span>].guid}</span>"</span>
+ iframe = <span class="string">"https://apps.groupdocs.com<span class="subst">#{url}</span>"</span>
<span class="keyword">end</span></pre></div></div>
</li>
- <li id="section-15">
+ <li id="section-18">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-15">¶</a>
+ <a class="pilcrow" href="#section-18">¶</a>
</div>
- <p>Add the signature in url</p>
+ <p>Make iframe</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
- iframe = <span class="string">"<iframe width='100%' height='600' frameborder='0' src='<span class="subst">#{iframe}</span>'></iframe>"</span>
+ <div class="content"><div class='highlight'><pre> iframe = <span class="string">"<iframe id='downloadframe' src='<span class="subst">#{iframe}</span>' width='800' height='1000'></iframe>"</span>
+
<span class="keyword">else</span>
raise <span class="string">'File was not converted'</span>
<span class="keyword">end</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-16">
+ <li id="section-19">
<div class="annotation">
<div class="pilwrap ">
- <a class="pilcrow" href="#section-16">¶</a>
+ <a class="pilcrow" href="#section-19">¶</a>
</div>
<p>Set variables for template</p>
</div>