examples/api-samples/public/docs/sample35.html in groupdocs-1.5.8 vs examples/api-samples/public/docs/sample35.html in groupdocs-1.5.9
- old
+ new
@@ -83,28 +83,32 @@
</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">if</span> settings.path.empty? <span class="keyword">then</span> settings.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?</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">¶</a>
</div>
- <p>clean version if it contains</p>
+ <p>Prepare base path</p>
</div>
- <div class="content"><div class='highlight'><pre> path = settings.path.gsub(<span class="regexp">/\/v2.0/</span>, <span class="string">''</span>)</pre></div></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">
@@ -128,15 +132,15 @@
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">¶</a>
</div>
- <p>optionally specify API server and version</p>
+ <p>Optionally specify API server and version</p>
</div>
- <div class="content"><div class='highlight'><pre> groupdocs.api_server = path <span class="comment"># default is 'https://api.groupdocs.com' https://dev-api-groupdocs.dynabic.com/v2.0</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>
@@ -376,28 +380,32 @@
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">:path</span>, params[<span class="symbol">:basePath</span>]
set <span class="symbol">:file_id</span>, params[<span class="symbol">:fileId</span>]
- <span class="keyword">begin</span>
-
- <span class="keyword">if</span> settings.path.empty? <span class="keyword">then</span> settings.path == <span class="string">'https://api.groupdocs.com'</span> <span class="keyword">end</span></pre></div></div>
+ <span class="keyword">begin</span></pre></div></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">¶</a>
</div>
- <p>clean version if it contains</p>
+ <p>Prepare base path</p>
</div>
- <div class="content"><div class='highlight'><pre> path = settings.path.gsub(<span class="regexp">/\/v2.0/</span>, <span class="string">''</span>)</pre></div></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-22">
@@ -421,16 +429,15 @@
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">¶</a>
</div>
- <p>optionally specify API server and version</p>
+ <p>Optionally specify API server and version</p>
</div>
- <div class="content"><div class='highlight'><pre> groupdocs.api_server = path <span class="comment"># default is 'https://api.groupdocs.com'</span>
- groupdocs.api_version = <span class="string">'2.0'</span> <span class="comment"># default is '2.0'</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>
@@ -636,21 +643,77 @@
</div>
<p>Set converted document GUID</p>
</div>
- <div class="content"><div class='highlight'><pre> guid = document[<span class="symbol">:inputs</span>][<span class="number">0</span>].outputs[<span class="number">0</span>].guid
-
- <span class="keyword">case</span> path
-
- <span class="keyword">when</span> <span class="string">'https://stage-api-groupdocs.dynabic.com'</span>
- iframe = <span class="string">"<iframe width='100%' height='600' frameborder='0' src='http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/<span class="subst">#{guid}</span>'></iframe>"</span>
- <span class="keyword">when</span> <span class="string">'https://dev-api-groupdocs.dynabic.com'</span>
- iframe = <span class="string">"<iframe width='100%' height='600' frameborder='0' src='http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/<span class="subst">#{guid}</span>'></iframe>"</span>
- <span class="keyword">else</span>
- iframe = <span class="string">"<iframe width='100%' height='600' frameborder='0' src='https://apps.groupdocs.com/document-viewer/embed/<span class="subst">#{guid}</span>'></iframe>"</span>
- <span class="keyword">end</span>
-
+ <div class="content"><div class='highlight'><pre> guid = document[<span class="symbol">:inputs</span>][<span class="number">0</span>].outputs[<span class="number">0</span>].guid</pre></div></div>
+
+ </li>
+
+
+ <li id="section-35">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-35">¶</a>
+ </div>
+ <p>Prepare to sign url</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> iframe = <span class="string">"/document-viewer/embed/<span class="subst">#{guid}</span>"</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-36">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-36">¶</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-37">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-37">¶</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>
+ 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>
+ iframe = <span class="string">"https://dev-apps.groupdocs.com<span class="subst">#{url}</span>"</span>
+ <span class="keyword">else</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-38">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-38">¶</a>
+ </div>
+ <p>Make iframe</p>
+
+ </div>
+
+ <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">rescue</span> <span class="constant">Exception</span> => e
err = e.message
<span class="keyword">end</span>