update activities endpoints documentation
This commit is contained in:
parent
c0e4cc64bd
commit
d9337d66e6
@ -127,7 +127,7 @@
|
||||
<dd><p>Get activities for the authenticated user.</p>
|
||||
<p><strong>Example requests</strong>:</p>
|
||||
<ul class="simple">
|
||||
<li><p>minimal request</p></li>
|
||||
<li><p>without parameters</p></li>
|
||||
</ul>
|
||||
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
|
||||
</pre></div>
|
||||
@ -245,17 +245,17 @@
|
||||
<li><p><strong>page</strong> (<em>integer</em>) – page if using pagination (default: 1)</p></li>
|
||||
<li><p><strong>per_page</strong> (<em>integer</em>) – number of activities per page (default: 5)</p></li>
|
||||
<li><p><strong>sport_id</strong> (<em>integer</em>) – sport id</p></li>
|
||||
<li><p><strong>from</strong> (<em>string</em>) – start date (format: <cite>%Y-%m-%d</cite>)</p></li>
|
||||
<li><p><strong>to</strong> (<em>string</em>) – end date (format: <cite>%Y-%m-%d</cite>)</p></li>
|
||||
<li><p><strong>from</strong> (<em>string</em>) – start date (format: <code class="docutils literal notranslate"><span class="pre">%Y-%m-%d</span></code>)</p></li>
|
||||
<li><p><strong>to</strong> (<em>string</em>) – end date (format: <code class="docutils literal notranslate"><span class="pre">%Y-%m-%d</span></code>)</p></li>
|
||||
<li><p><strong>distance_from</strong> (<em>float</em>) – minimal distance</p></li>
|
||||
<li><p><strong>distance_to</strong> (<em>float</em>) – maximal distance</p></li>
|
||||
<li><p><strong>duration_from</strong> (<em>string</em>) – minimal duration (format: <cite>%H:%M</cite>)</p></li>
|
||||
<li><p><strong>duration_to</strong> (<em>string</em>) – maximal distance (format: <cite>%H:%M</cite>)</p></li>
|
||||
<li><p><strong>duration_from</strong> (<em>string</em>) – minimal duration (format: <code class="docutils literal notranslate"><span class="pre">%H:%M</span></code>)</p></li>
|
||||
<li><p><strong>duration_to</strong> (<em>string</em>) – maximal distance (format: <code class="docutils literal notranslate"><span class="pre">%H:%M</span></code>)</p></li>
|
||||
<li><p><strong>ave_speed_from</strong> (<em>float</em>) – minimal average speed</p></li>
|
||||
<li><p><strong>ave_speed_to</strong> (<em>float</em>) – maximal average speed</p></li>
|
||||
<li><p><strong>max_speed_from</strong> (<em>float</em>) – minimal max. speed</p></li>
|
||||
<li><p><strong>max_speed_to</strong> (<em>float</em>) – maximal max. speed</p></li>
|
||||
<li><p><strong>order</strong> (<em>string</em>) – sorting order (default: <cite>desc</cite>)</p></li>
|
||||
<li><p><strong>order</strong> (<em>string</em>) – sorting order (default: <code class="docutils literal notranslate"><span class="pre">desc</span></code>)</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-odd">Request Headers</dt>
|
||||
@ -266,6 +266,7 @@
|
||||
<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> – no error</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>
|
||||
</ul>
|
||||
</dd>
|
||||
@ -276,18 +277,309 @@
|
||||
<dt id="get--api-activities-(int-activity_id)">
|
||||
<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><a class="headerlink" href="#get--api-activities-(int-activity_id)" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Get an activity</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</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</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">"data"</span><span class="p">:</span> <span class="p">{</span>
|
||||
<span class="nt">"activities"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Sun, 07 Jul 2019 07:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"ascent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"ave_speed"</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span>
|
||||
<span class="nt">"bounds"</span><span class="p">:</span> <span class="p">[],</span>
|
||||
<span class="nt">"creation_date"</span><span class="p">:</span> <span class="s2">"Sun, 14 Jul 2019 18:57:14 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"descent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"distance"</span><span class="p">:</span> <span class="mi">12</span><span class="p">,</span>
|
||||
<span class="nt">"duration"</span><span class="p">:</span> <span class="s2">"0:45:00"</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span>
|
||||
<span class="nt">"map"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"max_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"max_speed"</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span>
|
||||
<span class="nt">"min_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"modification_date"</span><span class="p">:</span> <span class="s2">"Sun, 14 Jul 2019 18:57:22 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"moving"</span><span class="p">:</span> <span class="s2">"0:45:00"</span><span class="p">,</span>
|
||||
<span class="nt">"next_activity"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
|
||||
<span class="nt">"notes"</span><span class="p">:</span> <span class="s2">"activity without gpx"</span><span class="p">,</span>
|
||||
<span class="nt">"pauses"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"previous_activity"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||
<span class="nt">"records"</span><span class="p">:</span> <span class="p">[],</span>
|
||||
<span class="nt">"segments"</span><span class="p">:</span> <span class="p">[],</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"title"</span><span class="p">:</span> <span class="s2">"biking on sunday morning"</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"weather_end"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"weather_start"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"with_gpx"</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">"status"</span><span class="p">:</span> <span class="s2">"success"</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> – No error</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.5">404 Not Found</a> – Activity not found</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="post">
|
||||
<dt id="post--api-activities">
|
||||
<code class="sig-name descname">POST </code><code class="sig-name descname">/api/activities</code><a class="headerlink" href="#post--api-activities" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Post an activity (with gpx file)</p>
|
||||
<dd><p>Post an activity with a gpx file</p>
|
||||
<p><strong>Example request</strong>:</p>
|
||||
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">POST</span> <span class="nn">/api/activities/</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">multipart/form-data</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">201</span> <span class="ne">CREATED</span>
|
||||
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
|
||||
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"data"</span><span class="p">:</span> <span class="p">{</span>
|
||||
<span class="nt">"activities"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"ascent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"ave_speed"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
|
||||
<span class="nt">"bounds"</span><span class="p">:</span> <span class="p">[],</span>
|
||||
<span class="nt">"creation_date"</span><span class="p">:</span> <span class="s2">"Sun, 14 Jul 2019 13:51:01 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"descent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"distance"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
|
||||
<span class="nt">"duration"</span><span class="p">:</span> <span class="s2">"0:17:04"</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"map"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"max_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"max_speed"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
|
||||
<span class="nt">"min_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"modification_date"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"moving"</span><span class="p">:</span> <span class="s2">"0:17:04"</span><span class="p">,</span>
|
||||
<span class="nt">"next_activity"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||
<span class="nt">"notes"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pauses"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"previous_activity"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"activity_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
|
||||
<span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"value"</span><span class="p">:</span> <span class="mf">10.0</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"activity_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||
<span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"value"</span><span class="p">:</span> <span class="s2">"0:17:04"</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"activity_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
|
||||
<span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"value"</span><span class="p">:</span> <span class="mf">10.0</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"activity_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"value"</span><span class="p">:</span> <span class="mf">10.0</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">],</span>
|
||||
<span class="nt">"segments"</span><span class="p">:</span> <span class="p">[],</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"title"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"weather_end"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"weather_start"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"with_gpx"</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">"status"</span><span class="p">:</span> <span class="s2">"success"</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>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt class="field-even">Form Parameters</dt>
|
||||
<dd class="field-even"><ul class="simple">
|
||||
<li><p><strong>file</strong> – gpx file</p></li>
|
||||
<li><p><strong>data</strong> – sport id and notes (example: <code class="docutils literal notranslate"><span class="pre">{"sport_id":</span> <span class="pre">1,</span> <span class="pre">"notes":</span> <span class="pre">""}</span></code>)</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.2">201 Created</a> – activity created</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.5.1">500 Internal Server Error</a> – </p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="post">
|
||||
<dt id="post--api-activities-no_gpx">
|
||||
<code class="sig-name descname">POST </code><code class="sig-name descname">/api/activities/no_gpx</code><a class="headerlink" href="#post--api-activities-no_gpx" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Post an activity without gpx file</p>
|
||||
<p><strong>Example request</strong>:</p>
|
||||
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">POST</span> <span class="nn">/api/activities/</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">201</span> <span class="ne">CREATED</span>
|
||||
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
|
||||
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"data"</span><span class="p">:</span> <span class="p">{</span>
|
||||
<span class="nt">"activities"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"ascent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"ave_speed"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
|
||||
<span class="nt">"bounds"</span><span class="p">:</span> <span class="p">[],</span>
|
||||
<span class="nt">"creation_date"</span><span class="p">:</span> <span class="s2">"Sun, 14 Jul 2019 13:51:01 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"descent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"distance"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
|
||||
<span class="nt">"duration"</span><span class="p">:</span> <span class="s2">"0:17:04"</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"map"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"max_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"max_speed"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
|
||||
<span class="nt">"min_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"modification_date"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"moving"</span><span class="p">:</span> <span class="s2">"0:17:04"</span><span class="p">,</span>
|
||||
<span class="nt">"next_activity"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||
<span class="nt">"notes"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pauses"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"previous_activity"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"activity_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
|
||||
<span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"value"</span><span class="p">:</span> <span class="mf">10.0</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"activity_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
|
||||
<span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"value"</span><span class="p">:</span> <span class="s2">"0:17:04"</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"activity_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
|
||||
<span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"value"</span><span class="p">:</span> <span class="mf">10.0</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
|
||||
<span class="nt">"activity_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"value"</span><span class="p">:</span> <span class="mf">10.0</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">],</span>
|
||||
<span class="nt">"segments"</span><span class="p">:</span> <span class="p">[],</span>
|
||||
<span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"title"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"user_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"weather_end"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"weather_start"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"with_gpx"</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">"status"</span><span class="p">:</span> <span class="s2">"success"</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>
|
||||
</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>)</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>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.2">201 Created</a> – activity created</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.5.1">500 Internal Server Error</a> – </p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="patch">
|
||||
|
File diff suppressed because one or more lines are too long
@ -28,7 +28,7 @@ def get_activities(auth_user_id):
|
||||
|
||||
**Example requests**:
|
||||
|
||||
- minimal request
|
||||
- without parameters
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
@ -142,21 +142,22 @@ def get_activities(auth_user_id):
|
||||
:query integer page: page if using pagination (default: 1)
|
||||
:query integer per_page: number of activities per page (default: 5)
|
||||
:query integer sport_id: sport id
|
||||
:query string from: start date (format: `%Y-%m-%d`)
|
||||
:query string to: end date (format: `%Y-%m-%d`)
|
||||
:query string from: start date (format: ``%Y-%m-%d``)
|
||||
:query string to: end date (format: ``%Y-%m-%d``)
|
||||
:query float distance_from: minimal distance
|
||||
:query float distance_to: maximal distance
|
||||
:query string duration_from: minimal duration (format: `%H:%M`)
|
||||
:query string duration_to: maximal distance (format: `%H:%M`)
|
||||
:query string duration_from: minimal duration (format: ``%H:%M``)
|
||||
:query string duration_to: maximal distance (format: ``%H:%M``)
|
||||
:query float ave_speed_from: minimal average speed
|
||||
:query float ave_speed_to: maximal average speed
|
||||
:query float max_speed_from: minimal max. speed
|
||||
:query float max_speed_to: maximal max. speed
|
||||
:query string order: sorting order (default: `desc`)
|
||||
:query string order: sorting order (default: ``desc``)
|
||||
|
||||
:reqheader Authorization: OAuth 2.0 Bearer Token
|
||||
|
||||
:statuscode 200: no error
|
||||
:statuscode 401: invalid token
|
||||
:statuscode 500:
|
||||
|
||||
"""
|
||||
@ -232,7 +233,70 @@ def get_activities(auth_user_id):
|
||||
@activities_blueprint.route('/activities/<int:activity_id>', methods=['GET'])
|
||||
@authenticate
|
||||
def get_activity(auth_user_id, activity_id):
|
||||
"""Get an activity"""
|
||||
"""
|
||||
Get an activity
|
||||
|
||||
**Example request**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/activities/3 HTTP/1.1
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"data": {
|
||||
"activities": [
|
||||
{
|
||||
"activity_date": "Sun, 07 Jul 2019 07:00:00 GMT",
|
||||
"ascent": null,
|
||||
"ave_speed": 16,
|
||||
"bounds": [],
|
||||
"creation_date": "Sun, 14 Jul 2019 18:57:14 GMT",
|
||||
"descent": null,
|
||||
"distance": 12,
|
||||
"duration": "0:45:00",
|
||||
"id": 5,
|
||||
"map": null,
|
||||
"max_alt": null,
|
||||
"max_speed": 16,
|
||||
"min_alt": null,
|
||||
"modification_date": "Sun, 14 Jul 2019 18:57:22 GMT",
|
||||
"moving": "0:45:00",
|
||||
"next_activity": 4,
|
||||
"notes": "activity without gpx",
|
||||
"pauses": null,
|
||||
"previous_activity": 3,
|
||||
"records": [],
|
||||
"segments": [],
|
||||
"sport_id": 1,
|
||||
"title": "biking on sunday morning",
|
||||
"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
|
||||
|
||||
:reqheader Authorization: OAuth 2.0 Bearer Token
|
||||
|
||||
:statuscode 200: No error
|
||||
:statuscode 401: Provide a valid auth token
|
||||
:statuscode 403: You do not have permissions
|
||||
:statuscode 404: Activity not found
|
||||
|
||||
"""
|
||||
activity = Activity.query.filter_by(id=activity_id).first()
|
||||
activities_list = []
|
||||
|
||||
@ -349,7 +413,110 @@ def get_map(map_id):
|
||||
@activities_blueprint.route('/activities', methods=['POST'])
|
||||
@authenticate
|
||||
def post_activity(auth_user_id):
|
||||
"""Post an activity (with gpx file)"""
|
||||
"""
|
||||
Post an activity with a gpx file
|
||||
|
||||
**Example request**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/activities/ HTTP/1.1
|
||||
Content-Type: multipart/form-data
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 201 CREATED
|
||||
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
|
||||
|
||||
:form file: gpx file
|
||||
:form data: sport id and notes (example: ``{"sport_id": 1, "notes": ""}``)
|
||||
|
||||
:reqheader Authorization: OAuth 2.0 Bearer Token
|
||||
|
||||
:statuscode 201: activity created
|
||||
:statuscode 400: invalid payload
|
||||
:statuscode 401: invalid token
|
||||
:statuscode 500:
|
||||
|
||||
"""
|
||||
response_object = verify_extension('activity', request)
|
||||
if response_object['status'] != 'success':
|
||||
return jsonify(response_object), 400
|
||||
@ -411,7 +578,114 @@ def post_activity(auth_user_id):
|
||||
@activities_blueprint.route('/activities/no_gpx', methods=['POST'])
|
||||
@authenticate
|
||||
def post_activity_no_gpx(auth_user_id):
|
||||
"""Post an activity without gpx file"""
|
||||
"""
|
||||
Post an activity without gpx file
|
||||
|
||||
**Example request**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/activities/ HTTP/1.1
|
||||
Content-Type: application/json
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 201 CREATED
|
||||
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
|
||||
|
||||
:<json string activity_date: activity date (format: ``%Y-%m-%d %H:%M``)
|
||||
:<json float distance: activity distance in km
|
||||
:<json integer duration: activity duration in seconds
|
||||
:<json string notes: notes
|
||||
:<json integer sport_id: activity sport id
|
||||
:<json string title: activity title
|
||||
|
||||
:reqheader Authorization: OAuth 2.0 Bearer Token
|
||||
|
||||
:statuscode 201: activity created
|
||||
:statuscode 400: invalid payload
|
||||
:statuscode 401: invalid token
|
||||
:statuscode 500:
|
||||
|
||||
"""
|
||||
activity_data = request.get_json()
|
||||
if not activity_data or activity_data.get('sport_id') is None \
|
||||
or activity_data.get('duration') is None \
|
||||
|
Loading…
Reference in New Issue
Block a user