examples/api-samples/public/docs/sample11.html in groupdocs-1.5.3 vs examples/api-samples/public/docs/sample11.html in groupdocs-1.5.4
- old
+ new
@@ -1,87 +1,319 @@
-<!DOCTYPE html> <html> <head> <title>sample11.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="annotation-sample.html"> annotation-sample.rb </a> <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="sample19.html"> sample19.rb </a> <a class="source" href="sample2.html"> sample2.rb </a> <a class="source" href="sample20.html"> sample20.rb </a> <a class="source" href="sample21.html"> sample21.rb </a> <a class="source" href="sample22.html"> sample22.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> sample11.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">'/sample11'</span> <span class="k">do</span>
- <span class="n">haml</span> <span class="ss">:sample11</span>
-<span class="k">end</span>
-
-
</pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">¶</a> </div> <p>POST request</p> </td> <td class="code"> <div class="highlight"><pre>
-<span class="n">post</span> <span class="s1">'/sample11'</span> <span class="k">do</span>
-
</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">¶</a> </div> <p>set variables</p> </td> <td class="code"> <div class="highlight"><pre>
- <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>
- <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>
- <span class="n">set</span> <span class="ss">:file_id</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:fileId</span><span class="o">]</span>
- <span class="n">set</span> <span class="ss">:annotation_type</span><span class="p">,</span> <span class="n">params</span><span class="o">[</span><span class="ss">:annotation_type</span><span class="o">]</span>
-
- <span class="k">begin</span>
-
</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">¶</a> </div> <p>check required variables</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="k">raise</span> <span class="s1">'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">file_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">annotation_type</span><span class="o">.</span><span class="n">empty?</span>
-
-
</pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">¶</a> </div> <p>annotation types</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="n">types</span> <span class="o">=</span> <span class="p">{</span><span class="ss">:text</span> <span class="o">=></span> <span class="mi">0</span><span class="p">,</span> <span class="ss">:area</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span> <span class="ss">:point</span> <span class="o">=></span> <span class="mi">2</span><span class="p">}</span>
-
-
</pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">¶</a> </div> <p>required parameters</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="n">all_params</span> <span class="o">=</span> <span class="n">all_params</span> <span class="o">=</span> <span class="o">[</span><span class="s1">'annotation_type'</span><span class="p">,</span> <span class="s1">'box_x'</span><span class="p">,</span> <span class="s1">'box_y'</span><span class="p">,</span> <span class="s1">'text'</span><span class="o">]</span>
-
-
</pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">¶</a> </div> <p>added required parameters depends on annotation type ['text' or 'area']</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">annotation_type</span> <span class="o">==</span> <span class="s1">'text'</span>
- <span class="n">all_params</span> <span class="o">=</span> <span class="n">all_params</span> <span class="o">|</span> <span class="o">[</span><span class="s1">'box_width'</span><span class="p">,</span> <span class="s1">'box_height'</span><span class="p">,</span> <span class="s1">'annotationPosition_x'</span><span class="p">,</span> <span class="s1">'annotationPosition_y'</span><span class="o">]</span>
- <span class="k">elsif</span> <span class="n">settings</span><span class="o">.</span><span class="n">annotation_type</span> <span class="o">==</span> <span class="s1">'area'</span>
- <span class="n">all_params</span> <span class="o">=</span> <span class="n">all_params</span> <span class="o">|</span> <span class="o">[</span><span class="s1">'box_width'</span><span class="p">,</span> <span class="s1">'box_height'</span><span class="o">]</span>
- <span class="k">end</span>
-
-
</pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">¶</a> </div> <p>checking required parameters</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="n">all_params</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">param</span><span class="o">|</span>
- <span class="k">raise</span> <span class="s1">'Please enter all required parameters'</span> <span class="k">if</span> <span class="n">params</span><span class="o">[</span><span class="n">param</span><span class="o">].</span><span class="n">empty?</span>
- <span class="k">end</span>
-
-
</pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">¶</a> </div> <p>make a request to API using client<em>id and private</em>key</p> </td> <td class="code"> <div class="highlight"><pre>
- <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>
- <span class="n">document</span> <span class="o">=</span> <span class="s1">''</span>
-
-
</pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">¶</a> </div> <p>get document by file ID</p> </td> <td class="code"> <div class="highlight"><pre>
- <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>
- <span class="k">if</span> <span class="n">element</span><span class="o">.</span><span class="n">respond_to?</span><span class="p">(</span><span class="s1">'guid'</span><span class="p">)</span> <span class="o">==</span> <span class="kp">true</span> <span class="ow">and</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">file_id</span>
- <span class="n">document</span> <span class="o">=</span> <span class="n">element</span>
- <span class="k">end</span>
- <span class="k">end</span>
-
- <span class="k">unless</span> <span class="n">document</span><span class="o">.</span><span class="n">instance_of?</span> <span class="nb">String</span>
-
-
</pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">¶</a> </div> <p>start create new annotation</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="n">annotation</span> <span class="o">=</span> <span class="ss">GroupDocs</span><span class="p">:</span><span class="ss">:Document</span><span class="o">::</span><span class="no">Annotation</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="ss">document</span><span class="p">:</span> <span class="n">document</span><span class="o">.</span><span class="n">to_document</span><span class="p">)</span>
- <span class="n">annotation</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">types</span><span class="o">[</span><span class="n">settings</span><span class="o">.</span><span class="n">annotation_type</span><span class="o">]</span>
-
-
</pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">¶</a> </div> <p>construct requestBody depends on annotation type
-text annotation</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">annotation_type</span> <span class="o">==</span> <span class="s1">'text'</span>
- <span class="n">annotation</span><span class="o">.</span><span class="n">box</span> <span class="o">=</span> <span class="p">{</span><span class="ss">x</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_x'</span><span class="o">]</span><span class="p">,</span> <span class="ss">y</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_y'</span><span class="o">]</span><span class="p">,</span> <span class="ss">width</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_width'</span><span class="o">]</span><span class="p">,</span> <span class="ss">height</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_height'</span><span class="o">]</span><span class="p">}</span>
- <span class="n">annotation</span><span class="o">.</span><span class="n">annotationPosition</span> <span class="o">=</span> <span class="p">{</span><span class="ss">x</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'annotationPosition_x'</span><span class="o">]</span><span class="p">,</span> <span class="ss">y</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'annotationPosition_y'</span><span class="o">]</span><span class="p">}</span>
-
-
</pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">¶</a> </div> <p>area annotation</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="k">elsif</span> <span class="n">settings</span><span class="o">.</span><span class="n">annotation_type</span> <span class="o">==</span> <span class="s1">'area'</span>
- <span class="n">annotation</span><span class="o">.</span><span class="n">box</span> <span class="o">=</span> <span class="p">{</span><span class="ss">x</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_x'</span><span class="o">]</span><span class="p">,</span> <span class="ss">y</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_y'</span><span class="o">]</span><span class="p">,</span> <span class="ss">width</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_width'</span><span class="o">]</span><span class="p">,</span> <span class="ss">height</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_height'</span><span class="o">]</span><span class="p">}</span>
- <span class="n">annotation</span><span class="o">.</span><span class="n">annotationPosition</span> <span class="o">=</span> <span class="p">{</span><span class="ss">x</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="ss">y</span><span class="p">:</span> <span class="mi">0</span><span class="p">}</span>
-
-
</pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">¶</a> </div> <p>point annotation</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="k">elsif</span> <span class="n">settings</span><span class="o">.</span><span class="n">annotation_type</span> <span class="o">==</span> <span class="s1">'point'</span>
- <span class="n">annotation</span><span class="o">.</span><span class="n">box</span> <span class="o">=</span> <span class="p">{</span><span class="ss">x</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_x'</span><span class="o">]</span><span class="p">,</span> <span class="ss">y</span><span class="p">:</span> <span class="n">params</span><span class="o">[</span><span class="s1">'box_y'</span><span class="o">]</span><span class="p">,</span> <span class="ss">width</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="ss">height</span><span class="p">:</span> <span class="mi">0</span><span class="p">}</span>
- <span class="n">annotation</span><span class="o">.</span><span class="n">annotationPosition</span> <span class="o">=</span> <span class="p">{</span><span class="ss">x</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="ss">y</span><span class="p">:</span> <span class="mi">0</span><span class="p">}</span>
- <span class="k">end</span>
-
-
</pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">¶</a> </div> <p>call create method</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="n">annotation</span><span class="o">.</span><span class="n">create!</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>
-
-
</pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-16">¶</a> </div> <p>add annotation reply</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="n">reply</span> <span class="o">=</span> <span class="ss">GroupDocs</span><span class="p">:</span><span class="ss">:Document</span><span class="o">::</span><span class="ss">Annotation</span><span class="p">:</span><span class="ss">:Reply</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="ss">annotation</span><span class="p">:</span> <span class="n">annotation</span><span class="p">)</span>
- <span class="n">reply</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">params</span><span class="o">[</span><span class="s1">'text'</span><span class="o">]</span>
- <span class="n">reply</span><span class="o">.</span><span class="n">create!</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="k">end</span>
-
- <span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
- <span class="n">err</span> <span class="o">=</span> <span class="n">e</span><span class="o">.</span><span class="n">message</span>
- <span class="k">end</span>
-
-
</pre></div> </td> </tr> <tr id="section-17"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-17">¶</a> </div> <p>set variables for template</p> </td> <td class="code"> <div class="highlight"><pre>
- <span class="n">haml</span> <span class="ss">:sample11</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">:fileId</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">file_id</span><span class="p">,</span> <span class="ss">:annotationType</span> <span class="o">=></span> <span class="n">settings</span><span class="o">.</span><span class="n">annotation_type</span><span class="p">,</span> <span class="ss">:annotationId</span> <span class="o">=></span> <span class="p">(</span><span class="n">defined?</span> <span class="n">annotation</span><span class="o">.</span><span class="n">id</span><span class="p">)</span> <span class="p">?</span> <span class="n">annotation</span><span class="o">.</span><span class="n">id</span> <span class="p">:</span> <span class="kp">nil</span><span class="p">,</span> <span class="ss">:annotationText</span> <span class="o">=></span> <span class="n">params</span><span class="o">[</span><span class="s1">'text'</span><span class="o">]</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="k">end</span>
-
-</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
\ No newline at end of file
+<!DOCTYPE html>
+
+<html>
+<head>
+ <title>sample11.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>sample11.rb</h1>
+ </div>
+ </li>
+
+
+
+ <li id="section-1">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-1">¶</a>
+ </div>
+ <p>GET request</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre>get <span class="string">'/sample11'</span> <span class="keyword">do</span>
+ haml <span class="symbol">:sample11</span>
+<span class="keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-2">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-2">¶</a>
+ </div>
+ <p>POST request</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre>post <span class="string">'/sample11'</span> <span class="keyword">do</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-3">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-3">¶</a>
+ </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">:file_id</span>, params[<span class="symbol">:fileId</span>]
+ set <span class="symbol">:annotation_type</span>, params[<span class="symbol">:annotation_type</span>]
+
+ <span class="keyword">begin</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-4">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-4">¶</a>
+ </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.file_id.empty? <span class="keyword">or</span> settings.annotation_type.empty?</pre></div></div>
+
+ </li>
+
+
+ <li id="section-5">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-5">¶</a>
+ </div>
+ <p>annotation types</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> types = {<span class="symbol">:text</span> => <span class="number">0</span>, <span class="symbol">:area</span> => <span class="number">1</span>, <span class="symbol">:point</span> => <span class="number">2</span>}</pre></div></div>
+
+ </li>
+
+
+ <li id="section-6">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-6">¶</a>
+ </div>
+ <p>required parameters</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> all_params = all_params = [<span class="string">'annotation_type'</span>, <span class="string">'box_x'</span>, <span class="string">'box_y'</span>, <span class="string">'text'</span>]</pre></div></div>
+
+ </li>
+
+
+ <li id="section-7">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-7">¶</a>
+ </div>
+ <p>added required parameters depends on annotation type ['text' or 'area']</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.annotation_type == <span class="string">'text'</span>
+ all_params = all_params | [<span class="string">'box_width'</span>, <span class="string">'box_height'</span>, <span class="string">'annotationPosition_x'</span>, <span class="string">'annotationPosition_y'</span>]
+ <span class="keyword">elsif</span> settings.annotation_type == <span class="string">'area'</span>
+ all_params = all_params | [<span class="string">'box_width'</span>, <span class="string">'box_height'</span>]
+ <span class="keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-8">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-8">¶</a>
+ </div>
+ <p>checking required parameters</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> all_params.each <span class="keyword">do</span> |param|
+ raise <span class="string">'Please enter all required parameters'</span> <span class="keyword">if</span> params[param].empty?
+ <span class="keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-9">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-9">¶</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="constant">GroupDocs::Storage::Folder</span>.list!(<span class="string">'/'</span>, {}, {<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})
+ document = <span class="string">''</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-10">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-10">¶</a>
+ </div>
+ <p>get document by file ID</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> files_list.each <span class="keyword">do</span> |element|
+ <span class="keyword">if</span> element.respond_to?(<span class="string">'guid'</span>) == <span class="keyword">true</span> <span class="keyword">and</span> element.guid == settings.file_id
+ document = element
+ <span class="keyword">end</span>
+ <span class="keyword">end</span>
+
+ <span class="keyword">unless</span> document.instance_of? <span class="constant">String</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-11">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-11">¶</a>
+ </div>
+ <p>start create new annotation</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> annotation = <span class="constant">GroupDocs::Document::Annotation</span>.new(<span class="symbol">document:</span> document.to_document)
+ annotation.type = types[settings.annotation_type]</pre></div></div>
+
+ </li>
+
+
+ <li id="section-12">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-12">¶</a>
+ </div>
+ <p>construct requestBody depends on annotation type
+text annotation</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="keyword">if</span> settings.annotation_type == <span class="string">'text'</span>
+ annotation.box = {<span class="symbol">x:</span> params[<span class="string">'box_x'</span>], <span class="symbol">y:</span> params[<span class="string">'box_y'</span>], <span class="symbol">width:</span> params[<span class="string">'box_width'</span>], <span class="symbol">height:</span> params[<span class="string">'box_height'</span>]}
+ annotation.annotationPosition = {<span class="symbol">x:</span> params[<span class="string">'annotationPosition_x'</span>], <span class="symbol">y:</span> params[<span class="string">'annotationPosition_y'</span>]}</pre></div></div>
+
+ </li>
+
+
+ <li id="section-13">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-13">¶</a>
+ </div>
+ <p>area annotation</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="keyword">elsif</span> settings.annotation_type == <span class="string">'area'</span>
+ annotation.box = {<span class="symbol">x:</span> params[<span class="string">'box_x'</span>], <span class="symbol">y:</span> params[<span class="string">'box_y'</span>], <span class="symbol">width:</span> params[<span class="string">'box_width'</span>], <span class="symbol">height:</span> params[<span class="string">'box_height'</span>]}
+ annotation.annotationPosition = {<span class="symbol">x:</span> <span class="number">0</span>, <span class="symbol">y:</span> <span class="number">0</span>}</pre></div></div>
+
+ </li>
+
+
+ <li id="section-14">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-14">¶</a>
+ </div>
+ <p>point annotation</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> <span class="keyword">elsif</span> settings.annotation_type == <span class="string">'point'</span>
+ annotation.box = {<span class="symbol">x:</span> params[<span class="string">'box_x'</span>], <span class="symbol">y:</span> params[<span class="string">'box_y'</span>], <span class="symbol">width:</span> <span class="number">0</span>, <span class="symbol">height:</span> <span class="number">0</span>}
+ annotation.annotationPosition = {<span class="symbol">x:</span> <span class="number">0</span>, <span class="symbol">y:</span> <span class="number">0</span>}
+ <span class="keyword">end</span></pre></div></div>
+
+ </li>
+
+
+ <li id="section-15">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-15">¶</a>
+ </div>
+ <p>call create method</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> annotation.create!({<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})</pre></div></div>
+
+ </li>
+
+
+ <li id="section-16">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-16">¶</a>
+ </div>
+ <p>add annotation reply</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> reply = <span class="constant">GroupDocs::Document::Annotation::Reply</span>.new(<span class="symbol">annotation:</span> annotation)
+ reply.text = params[<span class="string">'text'</span>]
+ reply.create!({<span class="symbol">:client_id</span> => settings.client_id, <span class="symbol">:private_key</span> => settings.private_key})
+
+ <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-17">
+ <div class="annotation">
+
+ <div class="pilwrap ">
+ <a class="pilcrow" href="#section-17">¶</a>
+ </div>
+ <p>set variables for template</p>
+
+ </div>
+
+ <div class="content"><div class='highlight'><pre> haml <span class="symbol">:sample11</span>, <span class="symbol">:locals</span> => {<span class="symbol">:userId</span> => settings.client_id, <span class="symbol">:privateKey</span> => settings.private_key, <span class="symbol">:fileId</span> => settings.file_id, <span class="symbol">:annotationType</span> => settings.annotation_type, <span class="symbol">:annotationId</span> => (<span class="keyword">defined</span>? annotation.id) ? annotation.id <span class="symbol">:</span> <span class="keyword">nil</span>, <span class="symbol">:annotationText</span> => params[<span class="string">'text'</span>], <span class="symbol">:err</span> => err}
+<span class="keyword">end</span></pre></div></div>
+
+ </li>
+
+ </ul>
+ </div>
+</body>
+</html>