update activities endpoints documentation

This commit is contained in:
Sam 2019-07-19 11:56:48 +02:00
parent 0701cd43da
commit 1247e2253a
5 changed files with 595 additions and 18 deletions

View File

@ -265,7 +265,7 @@
</dd> </dd>
<dt class="field-even">Status Codes</dt> <dt class="field-even">Status Codes</dt>
<dd class="field-even"><ul class="simple"> <dd class="field-even"><ul class="simple">
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> no error</p></li> <li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> success</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> invalid token</p></li> <li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> invalid token</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">500 Internal Server Error</a> </p></li> <li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">500 Internal Server Error</a> </p></li>
</ul> </ul>
@ -281,7 +281,10 @@
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/3</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/3</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
</pre></div> </pre></div>
</div> </div>
<p><strong>Example response</strong>:</p> <p><strong>Example responses</strong>:</p>
<ul class="simple">
<li><p>success</p></li>
</ul>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span> <div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span> <span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
@ -323,6 +326,20 @@
<span class="p">}</span> <span class="p">}</span>
</pre></div> </pre></div>
</div> </div>
<ul class="simple">
<li><p>acitivity not found:</p></li>
</ul>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">404</span> <span class="ne">NOT FOUND</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
<span class="p">{</span>
<span class="nt">&quot;data&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">&quot;activities&quot;</span><span class="p">:</span> <span class="p">[]</span>
<span class="p">},</span>
<span class="nt">&quot;status&quot;</span><span class="p">:</span> <span class="s2">&quot;not found&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<dl class="field-list simple"> <dl class="field-list simple">
<dt class="field-odd">Parameters</dt> <dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple"> <dd class="field-odd"><ul class="simple">
@ -337,10 +354,10 @@
</dd> </dd>
<dt class="field-odd">Status Codes</dt> <dt class="field-odd">Status Codes</dt>
<dd class="field-odd"><ul class="simple"> <dd class="field-odd"><ul class="simple">
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> No error</p></li> <li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> success</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> Provide a valid auth token</p></li> <li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> Provide a valid auth token</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4">403 Forbidden</a> You do not have permissions</p></li> <li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4">403 Forbidden</a> You do not have permissions</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">404 Not Found</a> Activity not found</p></li> <li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">404 Not Found</a> activity not found</p></li>
</ul> </ul>
</dd> </dd>
</dl> </dl>
@ -561,7 +578,7 @@
<li><p><strong>activity_date</strong> (<em>string</em>) activity date (format: <code class="docutils literal notranslate"><span class="pre">%Y-%m-%d</span> <span class="pre">%H:%M</span></code>)</p></li> <li><p><strong>activity_date</strong> (<em>string</em>) activity date (format: <code class="docutils literal notranslate"><span class="pre">%Y-%m-%d</span> <span class="pre">%H:%M</span></code>)</p></li>
<li><p><strong>distance</strong> (<em>float</em>) activity distance in km</p></li> <li><p><strong>distance</strong> (<em>float</em>) activity distance in km</p></li>
<li><p><strong>duration</strong> (<em>integer</em>) activity duration in seconds</p></li> <li><p><strong>duration</strong> (<em>integer</em>) activity duration in seconds</p></li>
<li><p><strong>notes</strong> (<em>string</em>) notes</p></li> <li><p><strong>notes</strong> (<em>string</em>) notes (not mandatory)</p></li>
<li><p><strong>sport_id</strong> (<em>integer</em>) activity sport id</p></li> <li><p><strong>sport_id</strong> (<em>integer</em>) activity sport id</p></li>
<li><p><strong>title</strong> (<em>string</em>) activity title</p></li> <li><p><strong>title</strong> (<em>string</em>) activity title</p></li>
</ul> </ul>
@ -586,24 +603,307 @@
<dt id="patch--api-activities-(int-activity_id)"> <dt id="patch--api-activities-(int-activity_id)">
<code class="sig-name descname">PATCH </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">activity_id</em><span class="sig-paren">)</span><a class="headerlink" href="#patch--api-activities-(int-activity_id)" title="Permalink to this definition"></a></dt> <code class="sig-name descname">PATCH </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">activity_id</em><span class="sig-paren">)</span><a class="headerlink" href="#patch--api-activities-(int-activity_id)" title="Permalink to this definition"></a></dt>
<dd><p>Update an activity</p> <dd><p>Update an activity</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">PATCH</span> <span class="nn">/api/activities/1</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
<p><strong>Example response</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
<span class="p">{</span>
<span class="nt">&quot;data&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">&quot;activities&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;ascent&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;ave_speed&quot;</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
<span class="nt">&quot;bounds&quot;</span><span class="p">:</span> <span class="p">[],</span>
<span class="nt">&quot;creation_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Sun, 14 Jul 2019 13:51:01 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;descent&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;distance&quot;</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
<span class="nt">&quot;duration&quot;</span><span class="p">:</span> <span class="s2">&quot;0:17:04&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;map&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;max_alt&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;max_speed&quot;</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
<span class="nt">&quot;min_alt&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;modification_date&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;moving&quot;</span><span class="p">:</span> <span class="s2">&quot;0:17:04&quot;</span><span class="p">,</span>
<span class="nt">&quot;next_activity&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">&quot;notes&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;pauses&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;previous_activity&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;records&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;MS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;user_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;value&quot;</span><span class="p">:</span> <span class="mf">10.0</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;LD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;user_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;value&quot;</span><span class="p">:</span> <span class="s2">&quot;0:17:04&quot;</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;FD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;user_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;value&quot;</span><span class="p">:</span> <span class="mf">10.0</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;AS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;user_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;value&quot;</span><span class="p">:</span> <span class="mf">10.0</span>
<span class="p">}</span>
<span class="p">],</span>
<span class="nt">&quot;segments&quot;</span><span class="p">:</span> <span class="p">[],</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;title&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;user_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;weather_end&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;weather_start&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;with_gpx&quot;</span><span class="p">:</span> <span class="kc">false</span>
<span class="p">}</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">&quot;status&quot;</span><span class="p">:</span> <span class="s2">&quot;success&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id</p></li>
<li><p><strong>activity_id</strong> (<em>integer</em>) activity id</p></li>
</ul>
</dd>
<dt class="field-even">Request JSON Object</dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>activity_date</strong> (<em>string</em>) activity date (format: <code class="docutils literal notranslate"><span class="pre">%Y-%m-%d</span> <span class="pre">%H:%M</span></code>)
(only for activity without gpx)</p></li>
<li><p><strong>distance</strong> (<em>float</em>) activity distance in km
(only for activity without gpx)</p></li>
<li><p><strong>duration</strong> (<em>integer</em>) activity duration in seconds
(only for activity without gpx)</p></li>
<li><p><strong>notes</strong> (<em>string</em>) notes</p></li>
<li><p><strong>sport_id</strong> (<em>integer</em>) activity sport id</p></li>
<li><p><strong>title</strong> (<em>string</em>) activity title</p></li>
</ul>
</dd>
<dt class="field-odd">Request Headers</dt>
<dd class="field-odd"><ul class="simple">
<li><p><a class="reference external" href="https://tools.ietf.org/html/rfc7235#section-4.2">Authorization</a> OAuth 2.0 Bearer Token</p></li>
</ul>
</dd>
<dt class="field-even">Status Codes</dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> activity updated</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">400 Bad Request</a> invalid payload</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> invalid token</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">404 Not Found</a> activity not found</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">500 Internal Server Error</a> </p></li>
</ul>
</dd>
</dl>
</dd></dl> </dd></dl>
<dl class="delete"> <dl class="delete">
<dt id="delete--api-activities-(int-activity_id)"> <dt id="delete--api-activities-(int-activity_id)">
<code class="sig-name descname">DELETE </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">activity_id</em><span class="sig-paren">)</span><a class="headerlink" href="#delete--api-activities-(int-activity_id)" title="Permalink to this definition"></a></dt> <code class="sig-name descname">DELETE </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">activity_id</em><span class="sig-paren">)</span><a class="headerlink" href="#delete--api-activities-(int-activity_id)" title="Permalink to this definition"></a></dt>
<dd><p>Delete an activity</p> <dd><p>Delete an activity</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">DELETE</span> <span class="nn">/api/activities/1</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
<p><strong>Example response</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">204</span> <span class="ne">NO CONTENT</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id</p></li>
<li><p><strong>activity_id</strong> (<em>integer</em>) activity id</p></li>
</ul>
</dd>
<dt class="field-even">Request Headers</dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference external" href="https://tools.ietf.org/html/rfc7235#section-4.2">Authorization</a> OAuth 2.0 Bearer Token</p></li>
</ul>
</dd>
<dt class="field-odd">Status Codes</dt>
<dd class="field-odd"><ul class="simple">
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.5">204 No Content</a> activity deleted</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> invalid token</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">404 Not Found</a> activity not found</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">500 Internal Server Error</a> </p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="get">
<dt id="get--api-activities-map-(map_id)">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/map/</code><span class="sig-paren">(</span><em class="sig-param">map_id</em><span class="sig-paren">)</span><a class="headerlink" href="#get--api-activities-map-(map_id)" title="Permalink to this definition"></a></dt>
<dd><p>Get map image for activities with gpx</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/map/fa33f4d996844a5c73ecd1ae24456ab8?1563529507772</span>
<span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
<p><strong>Example response</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">image/png</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id</p></li>
<li><p><strong>map_id</strong> (<em>string</em>) activity map id</p></li>
</ul>
</dd>
<dt class="field-even">Request Headers</dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference external" href="https://tools.ietf.org/html/rfc7235#section-4.2">Authorization</a> OAuth 2.0 Bearer Token</p></li>
</ul>
</dd>
<dt class="field-odd">Status Codes</dt>
<dd class="field-odd"><ul class="simple">
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> success</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> invalid token</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">404 Not Found</a> map does not exist</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">500 Internal Server Error</a> </p></li>
</ul>
</dd>
</dl>
</dd></dl> </dd></dl>
<dl class="get"> <dl class="get">
<dt id="get--api-activities-(int-activity_id)-gpx"> <dt id="get--api-activities-(int-activity_id)-gpx">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">activity_id</em><span class="sig-paren">)</span><code class="sig-name descname">/gpx</code><a class="headerlink" href="#get--api-activities-(int-activity_id)-gpx" title="Permalink to this definition"></a></dt> <code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">activity_id</em><span class="sig-paren">)</span><code class="sig-name descname">/gpx</code><a class="headerlink" href="#get--api-activities-(int-activity_id)-gpx" title="Permalink to this definition"></a></dt>
<dd><p>Get gpx file for an activity</p> <dd><p>Get gpx file for an activity displayed on map with Leaflet</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/3/gpx</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
<p><strong>Example response</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
<span class="p">{</span>
<span class="nt">&quot;data&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">&quot;gpx&quot;</span><span class="p">:</span> <span class="s2">&quot;gpx file content&quot;</span>
<span class="p">},</span>
<span class="nt">&quot;message&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;status&quot;</span><span class="p">:</span> <span class="s2">&quot;success&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id</p></li>
<li><p><strong>activity_id</strong> (<em>integer</em>) activity id</p></li>
</ul>
</dd>
<dt class="field-even">Request Headers</dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference external" href="https://tools.ietf.org/html/rfc7235#section-4.2">Authorization</a> OAuth 2.0 Bearer Token</p></li>
</ul>
</dd>
<dt class="field-odd">Status Codes</dt>
<dd class="field-odd"><ul class="simple">
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> success</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">400 Bad Request</a> no gpx file for this activity</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> invalid token</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">404 Not Found</a> activity not found</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">500 Internal Server Error</a> </p></li>
</ul>
</dd>
</dl>
</dd></dl> </dd></dl>
<dl class="get"> <dl class="get">
<dt id="get--api-activities-(int-activity_id)-chart_data"> <dt id="get--api-activities-(int-activity_id)-chart_data">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">activity_id</em><span class="sig-paren">)</span><code class="sig-name descname">/chart_data</code><a class="headerlink" href="#get--api-activities-(int-activity_id)-chart_data" title="Permalink to this definition"></a></dt> <code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">activity_id</em><span class="sig-paren">)</span><code class="sig-name descname">/chart_data</code><a class="headerlink" href="#get--api-activities-(int-activity_id)-chart_data" title="Permalink to this definition"></a></dt>
<dd><p>Get chart data from an activity gpx file</p> <dd><p>Get chart data from an activity gpx file, to display it with Recharts</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/3/chart</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
<p><strong>Example response</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span> <span class="m">200</span> <span class="ne">OK</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
<span class="p">{</span>
<span class="nt">&quot;data&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">&quot;chart_data&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">&quot;distance&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">&quot;duration&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">&quot;elevation&quot;</span><span class="p">:</span> <span class="mf">279.4</span><span class="p">,</span>
<span class="nt">&quot;speed&quot;</span><span class="p">:</span> <span class="mf">8.63</span><span class="p">,</span>
<span class="nt">&quot;time&quot;</span><span class="p">:</span> <span class="s2">&quot;Fri, 14 Jul 2017 13:44:03 GMT&quot;</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;distance&quot;</span><span class="p">:</span> <span class="mf">7.5</span><span class="p">,</span>
<span class="nt">&quot;duration&quot;</span><span class="p">:</span> <span class="mi">7380</span><span class="p">,</span>
<span class="nt">&quot;elevation&quot;</span><span class="p">:</span> <span class="mi">280</span><span class="p">,</span>
<span class="nt">&quot;speed&quot;</span><span class="p">:</span> <span class="mf">6.39</span><span class="p">,</span>
<span class="nt">&quot;time&quot;</span><span class="p">:</span> <span class="s2">&quot;Fri, 14 Jul 2017 15:47:03 GMT&quot;</span>
<span class="p">}</span>
<span class="p">]</span>
<span class="p">},</span>
<span class="nt">&quot;message&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;status&quot;</span><span class="p">:</span> <span class="s2">&quot;success&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id</p></li>
<li><p><strong>activity_id</strong> (<em>integer</em>) activity id</p></li>
</ul>
</dd>
<dt class="field-even">Request Headers</dt>
<dd class="field-even"><ul class="simple">
<li><p><a class="reference external" href="https://tools.ietf.org/html/rfc7235#section-4.2">Authorization</a> OAuth 2.0 Bearer Token</p></li>
</ul>
</dd>
<dt class="field-odd">Status Codes</dt>
<dd class="field-odd"><ul class="simple">
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">200 OK</a> success</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">400 Bad Request</a> no gpx file for this activity</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> invalid token</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">404 Not Found</a> activity not found</p></li>
<li><p><a class="reference external" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">500 Internal Server Error</a> </p></li>
</ul>
</dd>
</dl>
</dd></dl> </dd></dl>
</div> </div>

View File

@ -140,6 +140,11 @@
<td> <td>
<a href="api/activities.html#get--api-activities-(int-activity_id)-gpx"><code class="xref">GET /api/activities/(int:activity_id)/gpx</code></a></td><td> <a href="api/activities.html#get--api-activities-(int-activity_id)-gpx"><code class="xref">GET /api/activities/(int:activity_id)/gpx</code></a></td><td>
<em></em></td></tr> <em></em></td></tr>
<tr>
<td></td>
<td>
<a href="api/activities.html#get--api-activities-map-(map_id)"><code class="xref">GET /api/activities/map/(map_id)</code></a></td><td>
<em></em></td></tr>
<tr> <tr>
<td></td> <td></td>
<td> <td>

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -156,7 +156,7 @@ def get_activities(auth_user_id):
:reqheader Authorization: OAuth 2.0 Bearer Token :reqheader Authorization: OAuth 2.0 Bearer Token
:statuscode 200: no error :statuscode 200: success
:statuscode 401: invalid token :statuscode 401: invalid token
:statuscode 500: :statuscode 500:
@ -242,7 +242,9 @@ def get_activity(auth_user_id, activity_id):
GET /api/activities/3 HTTP/1.1 GET /api/activities/3 HTTP/1.1
**Example response**: **Example responses**:
- success
.. sourcecode:: http .. sourcecode:: http
@ -286,15 +288,29 @@ def get_activity(auth_user_id, activity_id):
"status": "success" "status": "success"
} }
- acitivity not found:
.. sourcecode:: http
HTTP/1.1 404 NOT FOUND
Content-Type: application/json
{
"data": {
"activities": []
},
"status": "not found"
}
:param integer auth_user_id: authenticate user id :param integer auth_user_id: authenticate user id
:param integer activity_id: activity id :param integer activity_id: activity id
:reqheader Authorization: OAuth 2.0 Bearer Token :reqheader Authorization: OAuth 2.0 Bearer Token
:statuscode 200: No error :statuscode 200: success
:statuscode 401: Provide a valid auth token :statuscode 401: Provide a valid auth token
:statuscode 403: You do not have permissions :statuscode 403: You do not have permissions
:statuscode 404: Activity not found :statuscode 404: activity not found
""" """
activity = Activity.query.filter_by(id=activity_id).first() activity = Activity.query.filter_by(id=activity_id).first()
@ -323,7 +339,7 @@ def get_activity(auth_user_id, activity_id):
def get_activity_data(auth_user_id, activity_id, data_type): def get_activity_data(auth_user_id, activity_id, data_type):
"""Get chart data from an activity gpx file""" """Get data from an activity gpx file"""
activity = Activity.query.filter_by(id=activity_id).first() activity = Activity.query.filter_by(id=activity_id).first()
content = '' content = ''
if activity: if activity:
@ -375,7 +391,43 @@ def get_activity_data(auth_user_id, activity_id, data_type):
) )
@authenticate @authenticate
def get_activity_gpx(auth_user_id, activity_id): def get_activity_gpx(auth_user_id, activity_id):
"""Get gpx file for an activity""" """
Get gpx file for an activity displayed on map with Leaflet
**Example request**:
.. sourcecode:: http
GET /api/activities/3/gpx HTTP/1.1
Content-Type: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"gpx": "gpx file content"
},
"message": "",
"status": "success"
}
:param integer auth_user_id: authenticate user id
:param integer activity_id: activity id
:reqheader Authorization: OAuth 2.0 Bearer Token
:statuscode 200: success
:statuscode 400: no gpx file for this activity
:statuscode 401: invalid token
:statuscode 404: activity not found
:statuscode 500:
"""
return get_activity_data(auth_user_id, activity_id, 'gpx') return get_activity_data(auth_user_id, activity_id, 'gpx')
@ -384,12 +436,92 @@ def get_activity_gpx(auth_user_id, activity_id):
) )
@authenticate @authenticate
def get_activity_chart_data(auth_user_id, activity_id): def get_activity_chart_data(auth_user_id, activity_id):
"""Get chart data from an activity gpx file""" """
Get chart data from an activity gpx file, to display it with Recharts
**Example request**:
.. sourcecode:: http
GET /api/activities/3/chart HTTP/1.1
Content-Type: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"chart_data": [
{
"distance": 0,
"duration": 0,
"elevation": 279.4,
"speed": 8.63,
"time": "Fri, 14 Jul 2017 13:44:03 GMT"
},
{
"distance": 7.5,
"duration": 7380,
"elevation": 280,
"speed": 6.39,
"time": "Fri, 14 Jul 2017 15:47:03 GMT"
}
]
},
"message": "",
"status": "success"
}
:param integer auth_user_id: authenticate user id
:param integer activity_id: activity id
:reqheader Authorization: OAuth 2.0 Bearer Token
:statuscode 200: success
:statuscode 400: no gpx file for this activity
:statuscode 401: invalid token
:statuscode 404: activity not found
:statuscode 500:
"""
return get_activity_data(auth_user_id, activity_id, 'chart') return get_activity_data(auth_user_id, activity_id, 'chart')
@activities_blueprint.route('/activities/map/<map_id>', methods=['GET']) @activities_blueprint.route('/activities/map/<map_id>', methods=['GET'])
def get_map(map_id): def get_map(map_id):
"""
Get map image for activities with gpx
**Example request**:
.. sourcecode:: http
GET /api/activities/map/fa33f4d996844a5c73ecd1ae24456ab8?1563529507772
HTTP/1.1
Content-Type: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: image/png
:param integer auth_user_id: authenticate user id
:param string map_id: activity map id
:reqheader Authorization: OAuth 2.0 Bearer Token
:statuscode 200: success
:statuscode 401: invalid token
:statuscode 404: map does not exist
:statuscode 500:
"""
try: try:
activity = Activity.query.filter_by(map_id=map_id).first() activity = Activity.query.filter_by(map_id=map_id).first()
if not activity: if not activity:
@ -674,7 +806,7 @@ def post_activity_no_gpx(auth_user_id):
:<json string activity_date: activity date (format: ``%Y-%m-%d %H:%M``) :<json string activity_date: activity date (format: ``%Y-%m-%d %H:%M``)
:<json float distance: activity distance in km :<json float distance: activity distance in km
:<json integer duration: activity duration in seconds :<json integer duration: activity duration in seconds
:<json string notes: notes :<json string notes: notes (not mandatory)
:<json integer sport_id: activity sport id :<json integer sport_id: activity sport id
:<json string title: activity title :<json string title: activity title
@ -724,7 +856,119 @@ def post_activity_no_gpx(auth_user_id):
@activities_blueprint.route('/activities/<int:activity_id>', methods=['PATCH']) @activities_blueprint.route('/activities/<int:activity_id>', methods=['PATCH'])
@authenticate @authenticate
def update_activity(auth_user_id, activity_id): def update_activity(auth_user_id, activity_id):
"""Update an activity""" """
Update an activity
**Example request**:
.. sourcecode:: http
PATCH /api/activities/1 HTTP/1.1
Content-Type: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"activities": [
{
"activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
"ascent": null,
"ave_speed": 10.0,
"bounds": [],
"creation_date": "Sun, 14 Jul 2019 13:51:01 GMT",
"descent": null,
"distance": 10.0,
"duration": "0:17:04",
"id": 1,
"map": null,
"max_alt": null,
"max_speed": 10.0,
"min_alt": null,
"modification_date": null,
"moving": "0:17:04",
"next_activity": 3,
"notes": null,
"pauses": null,
"previous_activity": null,
"records": [
{
"activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
"activity_id": 1,
"id": 4,
"record_type": "MS",
"sport_id": 1,
"user_id": 1,
"value": 10.0
},
{
"activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
"activity_id": 1,
"id": 3,
"record_type": "LD",
"sport_id": 1,
"user_id": 1,
"value": "0:17:04"
},
{
"activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
"activity_id": 1,
"id": 2,
"record_type": "FD",
"sport_id": 1,
"user_id": 1,
"value": 10.0
},
{
"activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
"activity_id": 1,
"id": 1,
"record_type": "AS",
"sport_id": 1,
"user_id": 1,
"value": 10.0
}
],
"segments": [],
"sport_id": 1,
"title": null,
"user_id": 1,
"weather_end": null,
"weather_start": null,
"with_gpx": false
}
]
},
"status": "success"
}
:param integer auth_user_id: authenticate user id
:param integer activity_id: activity id
:<json string activity_date: activity date (format: ``%Y-%m-%d %H:%M``)
(only for activity without gpx)
:<json float distance: activity distance in km
(only for activity without gpx)
:<json integer duration: activity duration in seconds
(only for activity without gpx)
:<json string notes: notes
:<json integer sport_id: activity sport id
:<json string title: activity title
:reqheader Authorization: OAuth 2.0 Bearer Token
:statuscode 200: activity updated
:statuscode 400: invalid payload
:statuscode 401: invalid token
:statuscode 404: activity not found
:statuscode 500:
"""
activity_data = request.get_json() activity_data = request.get_json()
if not activity_data: if not activity_data:
response_object = { response_object = {
@ -774,7 +1018,35 @@ def update_activity(auth_user_id, activity_id):
) )
@authenticate @authenticate
def delete_activity(auth_user_id, activity_id): def delete_activity(auth_user_id, activity_id):
"""Delete an activity""" """
Delete an activity
**Example request**:
.. sourcecode:: http
DELETE /api/activities/1 HTTP/1.1
Content-Type: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.1 204 NO CONTENT
Content-Type: application/json
:param integer auth_user_id: authenticate user id
:param integer activity_id: activity id
:reqheader Authorization: OAuth 2.0 Bearer Token
:statuscode 204: activity deleted
:statuscode 401: invalid token
:statuscode 404: activity not found
:statuscode 500:
"""
try: try:
activity = Activity.query.filter_by(id=activity_id).first() activity = Activity.query.filter_by(id=activity_id).first()
if activity: if activity: