examples/api-samples/public/docs/sample07.html in groupdocs-2.2.0 vs examples/api-samples/public/docs/sample07.html in groupdocs-2.3.0

- old
+ new

@@ -1,209 +1,209 @@ -<!DOCTYPE html> - -<html> -<head> - <title>sample07.rb</title> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"> - <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> - <link rel="stylesheet" media="all" href="docco.css" /> -</head> -<body> - <div id="container"> - <div id="background"></div> - - <ul class="sections"> - - <li id="title"> - <div class="annotation"> - <h1>sample07.rb</h1> - </div> - </li> - - - - <li id="section-1"> - <div class="annotation"> - - <div class="pilwrap "> - <a class="pilcrow" href="#section-1">&#182;</a> - </div> - <p>GET request</p> - - </div> - - <div class="content"><div class='highlight'><pre>get <span class="hljs-string">'/sample-7-how-to-create-a-list-of-thumbnails-for-a-document'</span> <span class="hljs-keyword">do</span> - haml <span class="hljs-symbol">:sample07</span> -<span class="hljs-keyword">end</span></pre></div></div> - - </li> - - - <li id="section-2"> - <div class="annotation"> - - <div class="pilwrap "> - <a class="pilcrow" href="#section-2">&#182;</a> - </div> - <p>POST request</p> - - </div> - - <div class="content"><div class='highlight'><pre>post <span class="hljs-string">'/sample-7-how-to-create-a-list-of-thumbnails-for-a-document'</span> <span class="hljs-keyword">do</span></pre></div></div> - - </li> - - - <li id="section-3"> - <div class="annotation"> - - <div class="pilwrap "> - <a class="pilcrow" href="#section-3">&#182;</a> - </div> - <p>Set variables</p> - - </div> - - <div class="content"><div class='highlight'><pre> set <span class="hljs-symbol">:client_id</span>, params[<span class="hljs-symbol">:clientId</span>] - set <span class="hljs-symbol">:private_key</span>, params[<span class="hljs-symbol">:privateKey</span>] - set <span class="hljs-symbol">:base_path</span>, params[<span class="hljs-symbol">:basePath</span>] - - <span class="hljs-keyword">begin</span></pre></div></div> - - </li> - - - <li id="section-4"> - <div class="annotation"> - - <div class="pilwrap "> - <a class="pilcrow" href="#section-4">&#182;</a> - </div> - <p>Check required variables</p> - - </div> - - <div class="content"><div class='highlight'><pre> raise <span class="hljs-string">'Please enter all required parameters'</span> <span class="hljs-keyword">if</span> settings.client_id.empty? <span class="hljs-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">&#182;</a> - </div> - <p>Prepare base path</p> - - </div> - - <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> settings.base_path.empty? - base_path = <span class="hljs-string">'https://api.groupdocs.com'</span> - <span class="hljs-keyword">elsif</span> settings.base_path.match(<span class="hljs-string">'/v2.0'</span>) - base_path = settings.base_path.split(<span class="hljs-string">'/v2.0'</span>)[<span class="hljs-number">0</span>] - <span class="hljs-keyword">else</span> - base_path = settings.base_path - <span class="hljs-keyword">end</span></pre></div></div> - - </li> - - - <li id="section-6"> - <div class="annotation"> - - <div class="pilwrap "> - <a class="pilcrow" href="#section-6">&#182;</a> - </div> - <p>Configure your access to API server</p> - - </div> - - <div class="content"><div class='highlight'><pre> <span class="hljs-constant">GroupDocs</span>.configure <span class="hljs-keyword">do</span> |groupdocs| - groupdocs.client_id = settings.client_id - groupdocs.private_key = settings.private_key</pre></div></div> - - </li> - - - <li id="section-7"> - <div class="annotation"> - - <div class="pilwrap "> - <a class="pilcrow" href="#section-7">&#182;</a> - </div> - <p>Optionally specify API server and version</p> - - </div> - - <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="hljs-comment"># default is 'https://api.groupdocs.com'</span> - <span class="hljs-keyword">end</span></pre></div></div> - - </li> - - - <li id="section-8"> - <div class="annotation"> - - <div class="pilwrap "> - <a class="pilcrow" href="#section-8">&#182;</a> - </div> - <p>Make a request to API using client_id and private_key</p> - - </div> - - <div class="content"><div class='highlight'><pre> files_list = <span class="hljs-constant">GroupDocs::Storage::Folder</span>.list!(<span class="hljs-string">'/'</span>, {<span class="hljs-symbol">:extended</span> =&gt; <span class="hljs-keyword">true</span>}, {<span class="hljs-symbol">:client_id</span> =&gt; settings.client_id, <span class="hljs-symbol">:private_key</span> =&gt; settings.private_key})</pre></div></div> - - </li> - - - <li id="section-9"> - <div class="annotation"> - - <div class="pilwrap "> - <a class="pilcrow" href="#section-9">&#182;</a> - </div> - <p>Construct result string</p> - - </div> - - <div class="content"><div class='highlight'><pre> thumbnails = <span class="hljs-string">''</span> - files_list.each <span class="hljs-keyword">do</span> |element| - <span class="hljs-keyword">if</span> element.<span class="hljs-keyword">class</span>.name.split(<span class="hljs-string">'::'</span>).last == <span class="hljs-string">'Folder'</span> - <span class="hljs-keyword">next</span> - <span class="hljs-keyword">end</span> - <span class="hljs-keyword">if</span> element.thumbnail - name = element.name - thumbnails += <span class="hljs-string">"&lt;img src='data:image/png;base64,<span class="hljs-subst">#{element.thumbnail}</span>', width='40px', height='40px'&gt; <span class="hljs-subst">#{name}</span>"</span> - <span class="hljs-keyword">end</span> - <span class="hljs-keyword">end</span> - - <span class="hljs-keyword">unless</span> thumbnails.empty? - set <span class="hljs-symbol">:thumbnails</span>, thumbnails - <span class="hljs-keyword">end</span> - - <span class="hljs-keyword">rescue</span> <span class="hljs-constant">Exception</span> =&gt; e - err = e.message - <span class="hljs-keyword">end</span></pre></div></div> - - </li> - - - <li id="section-10"> - <div class="annotation"> - - <div class="pilwrap "> - <a class="pilcrow" href="#section-10">&#182;</a> - </div> - <p>Set variables for template</p> - - </div> - - <div class="content"><div class='highlight'><pre> haml <span class="hljs-symbol">:sample07</span>, <span class="hljs-symbol">:locals</span> =&gt; {<span class="hljs-symbol">:clientId</span> =&gt; settings.client_id, <span class="hljs-symbol">:privateKey</span> =&gt; settings.private_key, <span class="hljs-symbol">:thumbnailList</span> =&gt; thumbnails, <span class="hljs-symbol">:err</span> =&gt; err} -<span class="hljs-keyword">end</span></pre></div></div> - - </li> - - </ul> - </div> -</body> -</html> +<!DOCTYPE html> + +<html> +<head> + <title>sample07.rb</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8"> + <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> + <link rel="stylesheet" media="all" href="docco.css" /> +</head> +<body> + <div id="container"> + <div id="background"></div> + + <ul class="sections"> + + <li id="title"> + <div class="annotation"> + <h1>sample07.rb</h1> + </div> + </li> + + + + <li id="section-1"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-1">&#182;</a> + </div> + <p>GET request</p> + + </div> + + <div class="content"><div class='highlight'><pre>get <span class="hljs-string">'/sample-7-how-to-create-a-list-of-thumbnails-for-a-document'</span> <span class="hljs-keyword">do</span> + haml <span class="hljs-symbol">:sample07</span> +<span class="hljs-keyword">end</span></pre></div></div> + + </li> + + + <li id="section-2"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-2">&#182;</a> + </div> + <p>POST request</p> + + </div> + + <div class="content"><div class='highlight'><pre>post <span class="hljs-string">'/sample-7-how-to-create-a-list-of-thumbnails-for-a-document'</span> <span class="hljs-keyword">do</span></pre></div></div> + + </li> + + + <li id="section-3"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-3">&#182;</a> + </div> + <p>Set variables</p> + + </div> + + <div class="content"><div class='highlight'><pre> set <span class="hljs-symbol">:client_id</span>, params[<span class="hljs-symbol">:clientId</span>] + set <span class="hljs-symbol">:private_key</span>, params[<span class="hljs-symbol">:privateKey</span>] + set <span class="hljs-symbol">:base_path</span>, params[<span class="hljs-symbol">:basePath</span>] + + <span class="hljs-keyword">begin</span></pre></div></div> + + </li> + + + <li id="section-4"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-4">&#182;</a> + </div> + <p>Check required variables</p> + + </div> + + <div class="content"><div class='highlight'><pre> raise <span class="hljs-string">'Please enter all required parameters'</span> <span class="hljs-keyword">if</span> settings.client_id.empty? <span class="hljs-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">&#182;</a> + </div> + <p>Prepare base path</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> settings.base_path.empty? + base_path = <span class="hljs-string">'https://api.groupdocs.com'</span> + <span class="hljs-keyword">elsif</span> settings.base_path.match(<span class="hljs-string">'/v2.0'</span>) + base_path = settings.base_path.split(<span class="hljs-string">'/v2.0'</span>)[<span class="hljs-number">0</span>] + <span class="hljs-keyword">else</span> + base_path = settings.base_path + <span class="hljs-keyword">end</span></pre></div></div> + + </li> + + + <li id="section-6"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-6">&#182;</a> + </div> + <p>Configure your access to API server</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-constant">GroupDocs</span>.configure <span class="hljs-keyword">do</span> |groupdocs| + groupdocs.client_id = settings.client_id + groupdocs.private_key = settings.private_key</pre></div></div> + + </li> + + + <li id="section-7"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-7">&#182;</a> + </div> + <p>Optionally specify API server and version</p> + + </div> + + <div class="content"><div class='highlight'><pre> groupdocs.api_server = base_path <span class="hljs-comment"># default is 'https://api.groupdocs.com'</span> + <span class="hljs-keyword">end</span></pre></div></div> + + </li> + + + <li id="section-8"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-8">&#182;</a> + </div> + <p>Make a request to API using client_id and private_key</p> + + </div> + + <div class="content"><div class='highlight'><pre> files_list = <span class="hljs-constant">GroupDocs::Storage::Folder</span>.list!(<span class="hljs-string">'/'</span>, {<span class="hljs-symbol">:extended</span> =&gt; <span class="hljs-keyword">true</span>}, {<span class="hljs-symbol">:client_id</span> =&gt; settings.client_id, <span class="hljs-symbol">:private_key</span> =&gt; settings.private_key})</pre></div></div> + + </li> + + + <li id="section-9"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-9">&#182;</a> + </div> + <p>Construct result string</p> + + </div> + + <div class="content"><div class='highlight'><pre> thumbnails = <span class="hljs-string">''</span> + files_list.each <span class="hljs-keyword">do</span> |element| + <span class="hljs-keyword">if</span> element.<span class="hljs-keyword">class</span>.name.split(<span class="hljs-string">'::'</span>).last == <span class="hljs-string">'Folder'</span> + <span class="hljs-keyword">next</span> + <span class="hljs-keyword">end</span> + <span class="hljs-keyword">if</span> element.thumbnail + name = element.name + thumbnails += <span class="hljs-string">"&lt;img src='data:image/png;base64,<span class="hljs-subst">#{element.thumbnail}</span>', width='40px', height='40px'&gt; <span class="hljs-subst">#{name}</span>"</span> + <span class="hljs-keyword">end</span> + <span class="hljs-keyword">end</span> + + <span class="hljs-keyword">unless</span> thumbnails.empty? + set <span class="hljs-symbol">:thumbnails</span>, thumbnails + <span class="hljs-keyword">end</span> + + <span class="hljs-keyword">rescue</span> <span class="hljs-constant">Exception</span> =&gt; e + err = e.message + <span class="hljs-keyword">end</span></pre></div></div> + + </li> + + + <li id="section-10"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-10">&#182;</a> + </div> + <p>Set variables for template</p> + + </div> + + <div class="content"><div class='highlight'><pre> haml <span class="hljs-symbol">:sample07</span>, <span class="hljs-symbol">:locals</span> =&gt; {<span class="hljs-symbol">:clientId</span> =&gt; settings.client_id, <span class="hljs-symbol">:privateKey</span> =&gt; settings.private_key, <span class="hljs-symbol">:thumbnailList</span> =&gt; thumbnails, <span class="hljs-symbol">:err</span> =&gt; err} +<span class="hljs-keyword">end</span></pre></div></div> + + </li> + + </ul> + </div> +</body> +</html>