Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Commit

Permalink
ListAllGangs in a separated endpoint (#109)
Browse files Browse the repository at this point in the history
* ListAllGangs in a separated endpoint + usage.rst updated

* Doc updated
  • Loading branch information
rmuhamed committed Dec 28, 2019
1 parent eae163f commit f5b0b9d
Show file tree
Hide file tree
Showing 24 changed files with 932 additions and 51 deletions.
Binary file modified doc/build/doctrees/application.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/domain.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified doc/build/doctrees/index.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/infrastructure.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/introduction.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/usage.doctree
Binary file not shown.
6 changes: 3 additions & 3 deletions doc/build/html/_sources/usage.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Validating use cases
$ curl localhost:5000/api/v1/outlaw/ -X POST \
--data @examples/json/create_outlaw.json \
-H 'Content-Type: application/json'
{"message":"Outlaw added successfully","status":201}
{"message": "Outlaw created successfully", "outlaw": {"id": "1", "name": "Outlaw", "email": "outlaw@yopmail.com"}}
- Create a Gang

Expand All @@ -43,7 +43,7 @@ Validating use cases
$ curl localhost:5000/api/v1/gang/ -X POST \
--data @examples/json/create_gang.json \
-H 'Content-Type: application/json'
{"name": "The best gang", "members": [], "created_raids": 0, "owner_id": 1, "id": 1}
{"message": "Gang created successfully", "gang": {"name": "The best gang", "members": [], "created_raids": 0, "owner_id": 1, "id": 1}}
- Create a Raid

Expand All @@ -59,7 +59,7 @@ Validating use cases
.. code-block:: console
$ curl localhost:5000/api/v1/gang
{"gangs":[{"id":1,"name":"The best gang"},{"id":2,"name":"The best gang"}],"status":201}
{"message":"Sucess", "gangs":[{"id":1,"name":"The best gang"},{"id":2,"name":"The best gang"}]}
Development Requirements
------------------------
Expand Down
4 changes: 0 additions & 4 deletions doc/build/html/_static/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,6 @@ div.code-block-caption + div > div.highlight > pre {
margin-top: 0;
}

div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
user-select: none;
}

div.code-block-caption span.caption-number {
padding: 0.1em 0.3em;
font-style: italic;
Expand Down
1 change: 0 additions & 1 deletion doc/build/html/_static/documentation_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var DOCUMENTATION_OPTIONS = {
VERSION: '1.0.0',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
BUILDER: 'html',
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt',
Expand Down
6 changes: 3 additions & 3 deletions doc/build/html/_static/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ var Search = {
if (results.length) {
var item = results.pop();
var listItem = $('<li style="display:none"></li>');
if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') {
if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') {
// dirhtml builder
var dirname = item[0] + '/';
if (dirname.match(/\/index\/$/)) {
Expand Down Expand Up @@ -424,15 +424,15 @@ var Search = {
for (j = 0; j < _files.length; j++) {
file = _files[j];
if (!(file in scoreMap))
scoreMap[file] = {};
scoreMap[file] = {}
scoreMap[file][word] = o.score;
}
});

// create the mapping
for (j = 0; j < files.length; j++) {
file = files[j];
if (file in fileMap && fileMap[file].indexOf(word) === -1)
if (file in fileMap)
fileMap[file].push(word);
else
fileMap[file] = [word];
Expand Down
271 changes: 267 additions & 4 deletions doc/build/html/application.html

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion doc/build/html/domain.html
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ <h1 class="logo"><a href="index.html">The Sheriff</a></h1>
<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">The Sheriff</a></li>
<li class="toctree-l1"><a class="reference internal" href="introduction.html#introduction">Introduction</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="usage.html">The Sheriff Usage</a></li>
Expand Down Expand Up @@ -563,7 +564,7 @@ <h3 id="searchlabel">Quick search</h3>
&copy;2019, The Sheriff Team.

|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.3.1</a>
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.0</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>

|
Expand Down
120 changes: 110 additions & 10 deletions doc/build/html/genindex.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ <h3 id="searchlabel">Quick search</h3>
&copy;2019, The Sheriff Team.

|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.3.1</a>
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.0</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>

|
Expand Down
510 changes: 507 additions & 3 deletions doc/build/html/infrastructure.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/build/html/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <h3 id="searchlabel">Quick search</h3>
&copy;2019, The Sheriff Team.

|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.3.1</a>
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.0</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>

|
Expand Down
Binary file modified doc/build/html/objects.inv
Binary file not shown.
17 changes: 16 additions & 1 deletion doc/build/html/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,21 @@ <h1>Python Module Index</h1>
<td>&#160;&#160;&#160;
<a href="infrastructure.html#module-thesheriff.infrastructure"><code class="xref">thesheriff.infrastructure</code></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
<a href="infrastructure.html#module-thesheriff.infrastructure.controllers.gang_controller"><code class="xref">thesheriff.infrastructure.controllers.gang_controller</code></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
<a href="infrastructure.html#module-thesheriff.infrastructure.controllers.outlaw_controller"><code class="xref">thesheriff.infrastructure.controllers.outlaw_controller</code></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
<a href="infrastructure.html#module-thesheriff.infrastructure.controllers.raid_controller"><code class="xref">thesheriff.infrastructure.controllers.raid_controller</code></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
Expand Down Expand Up @@ -300,7 +315,7 @@ <h3 id="searchlabel">Quick search</h3>
&copy;2019, The Sheriff Team.

|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.3.1</a>
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.0</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>

</div>
Expand Down
2 changes: 1 addition & 1 deletion doc/build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h3>Related Topics</h3>
&copy;2019, The Sheriff Team.

|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.3.1</a>
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.0</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>

</div>
Expand Down
2 changes: 1 addition & 1 deletion doc/build/html/searchindex.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions doc/build/html/usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ <h2>Validating use cases<a class="headerlink" href="#validating-use-cases" title
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> curl localhost:5000/api/v1/outlaw/ -X POST <span class="se">\</span>
--data @examples/json/create_outlaw.json <span class="se">\</span>
-H <span class="s1">&#39;Content-Type: application/json&#39;</span>
<span class="go">{&quot;message&quot;:&quot;Outlaw added successfully&quot;,&quot;status&quot;:201}</span>
<span class="go"> {&quot;message&quot;: &quot;Outlaw created successfully&quot;, &quot;outlaw&quot;: {&quot;id&quot;: &quot;1&quot;, &quot;name&quot;: &quot;Outlaw&quot;, &quot;email&quot;: &quot;outlaw@yopmail.com&quot;}}</span>
</pre></div>
</div>
</li>
<li><p>Create a Gang</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> curl localhost:5000/api/v1/gang/ -X POST <span class="se">\</span>
--data @examples/json/create_gang.json <span class="se">\</span>
-H <span class="s1">&#39;Content-Type: application/json&#39;</span>
<span class="go">{&quot;name&quot;: &quot;The best gang&quot;, &quot;members&quot;: [], &quot;created_raids&quot;: 0, &quot;owner_id&quot;: 1, &quot;id&quot;: 1}</span>
<span class="go">{&quot;message&quot;: &quot;Gang created successfully&quot;, &quot;gang&quot;: {&quot;name&quot;: &quot;The best gang&quot;, &quot;members&quot;: [], &quot;created_raids&quot;: 0, &quot;owner_id&quot;: 1, &quot;id&quot;: 1}}</span>
</pre></div>
</div>
</li>
Expand All @@ -85,7 +85,7 @@ <h2>Validating use cases<a class="headerlink" href="#validating-use-cases" title
</li>
<li><p>List all Gangs</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> curl localhost:5000/api/v1/gang
<span class="go">{&quot;gangs&quot;:[{&quot;id&quot;:1,&quot;name&quot;:&quot;The best gang&quot;},{&quot;id&quot;:2,&quot;name&quot;:&quot;The best gang&quot;}],&quot;status&quot;:201}</span>
<span class="go">{&quot;message&quot;:&quot;Sucess&quot;, &quot;gangs&quot;:[{&quot;id&quot;:1,&quot;name&quot;:&quot;The best gang&quot;},{&quot;id&quot;:2,&quot;name&quot;:&quot;The best gang&quot;}]}</span>
</pre></div>
</div>
</li>
Expand Down Expand Up @@ -125,6 +125,7 @@ <h1 class="logo"><a href="index.html">The Sheriff</a></h1>
<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">The Sheriff</a></li>
<li class="toctree-l1"><a class="reference internal" href="introduction.html#introduction">Introduction</a></li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">The Sheriff Usage</a><ul>
Expand Down Expand Up @@ -182,7 +183,7 @@ <h3 id="searchlabel">Quick search</h3>
&copy;2019, The Sheriff Team.

|
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.3.1</a>
Powered by <a href="http://sphinx-doc.org/">Sphinx 2.2.0</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>

|
Expand Down
6 changes: 3 additions & 3 deletions doc/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Validating use cases
$ curl localhost:5000/api/v1/outlaw/ -X POST \
--data @examples/json/create_outlaw.json \
-H 'Content-Type: application/json'
{"message":"Outlaw added successfully","status":201}
{"message": "Outlaw created successfully", "outlaw": {"id": "1", "name": "Outlaw", "email": "outlaw@yopmail.com"}}
- Create a Gang

Expand All @@ -43,7 +43,7 @@ Validating use cases
$ curl localhost:5000/api/v1/gang/ -X POST \
--data @examples/json/create_gang.json \
-H 'Content-Type: application/json'
{"name": "The best gang", "members": [], "created_raids": 0, "owner_id": 1, "id": 1}
{"message": "Gang created successfully", "gang": {"name": "The best gang", "members": [], "created_raids": 0, "owner_id": 1, "id": 1}}
- Create a Raid

Expand All @@ -59,7 +59,7 @@ Validating use cases
.. code-block:: console
$ curl localhost:5000/api/v1/gang
{"gangs":[{"id":1,"name":"The best gang"},{"id":2,"name":"The best gang"}],"status":201}
{"message":"Sucess", "gangs":[{"id":1,"name":"The best gang"},{"id":2,"name":"The best gang"}]}
Development Requirements
------------------------
Expand Down
22 changes: 12 additions & 10 deletions thesheriff/infrastructure/controllers/gang_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""
import inject
from flask import Blueprint, jsonify, Response, request

from thesheriff.application.gang.list_gangs import ListGangs
from thesheriff.application.gang.request.create_gang_request import \
CreateGangRequest
Expand Down Expand Up @@ -103,16 +104,17 @@ def join_gang_endpoint(gang_id: int) -> Response:

return jsonify(message)

@blueprint_gang.route('/gang', methods=['GET', 'POST'])
def create_gang_endpoint() -> Response:
if request.method == 'GET':
results = list_gangs.execute()
gangs = list()
for res in results:
gangs.append(dict({'id': res.id, 'name': res.name}))
message = {'message': 'Success', 'gangs': gangs}
return jsonify(message)
@blueprint_gang.route('/gang', methods=['GET'])
def list_gangs_endpoint() -> Response:
results = list_gangs.execute()
gangs = list()
for res in results:
gangs.append(dict({'id': res.id, 'name': res.name}))
message = {'message': 'Success', 'gangs': gangs}
return jsonify(message)

@blueprint_gang.route('/gang', methods=['POST'])
def create_gang_endpoint() -> Response:
data = request.json
new_gang = data.get('gang')

Expand All @@ -123,7 +125,7 @@ def create_gang_endpoint() -> Response:
result = dict({'id': gang.id, 'name': gang.name,
'owner_id': gang.owner_id})

message = {'message': 'Gang successfully created', gang: result}
message = {'message': 'Gang successfully created', 'gang': result}

return jsonify(message)

Expand Down

0 comments on commit f5b0b9d

Please sign in to comment.