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

Commit

Permalink
Issue/#72 (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmuhamed committed Dec 24, 2019
1 parent 05efbef commit 9359539
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 21 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/usage.doctree
Binary file not shown.
4 changes: 2 additions & 2 deletions doc/build/html/application.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ <h2>Raid<a class="headerlink" href="#raid" title="Permalink to this headline">¶
<span class="target" id="module-thesheriff.application.raid.request.create_raid_request"><span id="create-raid-request"></span></span><dl class="class">
<dt id="thesheriff.application.raid.request.create_raid_request.CreateRaidRequest">
<em class="property">class </em><code class="sig-prename descclassname">thesheriff.application.raid.request.create_raid_request.</code><code class="sig-name descname">CreateRaidRequest</code><span class="sig-paren">(</span><em class="sig-param">name: str, date: datetime.datetime, location: str, gang_id: int, sheriff_id: int, outlaw_ids: List[int]</em><span class="sig-paren">)</span><a class="headerlink" href="#thesheriff.application.raid.request.create_raid_request.CreateRaidRequest" title="Permalink to this definition"></a></dt>
<dd><p>Class CreateOutlawRequest holds data required to create an Outlaw.</p>
<dd><p>Class CreateRaidRequest holds data required to create a Raid.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<em>String</em>) – Outlaw’s given name.</p></li>
<li><p><strong>name</strong> (<em>String</em>) – Raid’s given name.</p></li>
<li><p><strong>date</strong> (<em>datetime.datetime</em>) – Date and time for the Raid.</p></li>
<li><p><strong>location</strong> (<em>String</em>) – Location of the Raid.</p></li>
<li><p><strong>gang_id</strong> (<em>Integer</em>) – Id of the Gang where the Raid is being organized.</p></li>
Expand Down
20 changes: 18 additions & 2 deletions doc/build/html/infrastructure.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h2>Controllers<a class="headerlink" href="#controllers" title="Permalink to thi
</div>
<p><strong>Response Example:</strong></p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="nt">&quot;status&quot;</span><span class="p">:</span> <span class="mi">201</span><span class="p">,</span>
<span class="nt">&quot;status&quot;</span><span class="p">:</span> <span class="mi">200</span><span class="p">,</span>
<span class="nt">&quot;gangs&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">&quot;gang1&quot;</span><span class="p">:</span> <span class="p">{},</span>
<span class="nt">&quot;gang2&quot;</span><span class="p">:</span> <span class="p">{}</span>
Expand Down Expand Up @@ -112,14 +112,15 @@ <h3>thesheriff.infrastructure.controllers.outlaw_controller<a class="headerlink"
<p>This module implements the RESTful part of the Outlaw use cases.</p>
<dl class="function">
<dt id="thesheriff.infrastructure.controllers.outlaw_controller.outlaw_controller">
<code class="sig-prename descclassname">thesheriff.infrastructure.controllers.outlaw_controller.</code><code class="sig-name descname">outlaw_controller</code><span class="sig-paren">(</span><em class="sig-param">create_outlaw: thesheriff.application.outlaw.create_outlaw.CreateOutlaw</em>, <em class="sig-param">list_friends: thesheriff.application.outlaw.list_friends.ListFriends</em>, <em class="sig-param">list_gangs: thesheriff.application.outlaw.list_gangs.ListGangs</em><span class="sig-paren">)</span> &#x2192; flask.blueprints.Blueprint<a class="headerlink" href="#thesheriff.infrastructure.controllers.outlaw_controller.outlaw_controller" title="Permalink to this definition"></a></dt>
<code class="sig-prename descclassname">thesheriff.infrastructure.controllers.outlaw_controller.</code><code class="sig-name descname">outlaw_controller</code><span class="sig-paren">(</span><em class="sig-param">create_outlaw: thesheriff.application.outlaw.create_outlaw.CreateOutlaw</em>, <em class="sig-param">list_friends: thesheriff.application.outlaw.list_friends.ListFriends</em>, <em class="sig-param">list_gangs: thesheriff.application.outlaw.list_gangs.ListGangs</em>, <em class="sig-param">invite_friend: thesheriff.application.outlaw.invite_friend.InviteFriend</em><span class="sig-paren">)</span> &#x2192; flask.blueprints.Blueprint<a class="headerlink" href="#thesheriff.infrastructure.controllers.outlaw_controller.outlaw_controller" title="Permalink to this definition"></a></dt>
<dd><p>outlaw_controller holds the blueprint for all outlaw routes.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>create_outlaw</strong> (<a class="reference internal" href="application.html#thesheriff.application.outlaw.create_outlaw.CreateOutlaw" title="thesheriff.application.outlaw.create_outlaw.CreateOutlaw"><em>CreateOutlaw</em></a>) – Create Outlaw use case implementation.</p></li>
<li><p><strong>list_friends</strong> (<a class="reference internal" href="application.html#thesheriff.application.outlaw.list_friends.ListFriends" title="thesheriff.application.outlaw.list_friends.ListFriends"><em>ListFriends</em></a>) – List Friends use case implementation.</p></li>
<li><p><strong>list_gangs</strong> (<a class="reference internal" href="application.html#thesheriff.application.gang.list_gangs.ListGangs" title="thesheriff.application.gang.list_gangs.ListGangs"><em>ListGangs</em></a>) – List Gangs use case implementation.</p></li>
<li><p><strong>invite_friend</strong> (<a class="reference internal" href="application.html#thesheriff.application.outlaw.invite_friend.InviteFriend" title="thesheriff.application.outlaw.invite_friend.InviteFriend"><em>InviteFriend</em></a>) – InviteFiend use case implementation.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
Expand Down Expand Up @@ -178,6 +179,21 @@ <h3>thesheriff.infrastructure.controllers.outlaw_controller<a class="headerlink"
</pre></div>
</div>
</li>
<li><p><em>/&lt;prefix&gt;/outlaw/invite_friend/</em> (POST)</p>
<p><strong>Request Example:</strong></p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> curl localhost:5000/api/&lt;version&gt;/outlaw/invite_friend/ <span class="se">\</span>
-X POST --data @examples/json/invite_friend.json <span class="se">\</span>
-H <span class="s1">&#39;Content-Type: application/json&#39;</span>
</pre></div>
</div>
<p><strong>Response Example:</strong></p>
<div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="nt">&quot;message&quot;</span><span class="p">:</span> <span class="s2">&quot;Invitation sent&quot;</span><span class="p">,</span>
<span class="nt">&quot;status&quot;</span><span class="p">:</span> <span class="mi">201</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
</ul>
</dd></dl>

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

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions examples/json/invite_friend.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"receiver_mail_address": "outlaw@yopmail.com"
}
3 changes: 3 additions & 0 deletions examples/json/join_gang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"outlaw_id": 1
}
11 changes: 6 additions & 5 deletions thesheriff/infrastructure/controllers/gang_controller.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import inject
import json

import inject
from flask import Blueprint, jsonify, Response, request, make_response

from thesheriff.application.gang.list_gangs import ListGangs
from thesheriff.application.gang.request.create_gang_request import \
CreateGangRequest
from thesheriff.application.gang.request.join_gang_request import \
JoinGangRequest
from thesheriff.application.outlaw.join_gang import JoinGang
from thesheriff.application.gang.list_gangs import ListGangs
from thesheriff.application.outlaw.create_gang import CreateGang
from thesheriff.application.outlaw.join_gang import JoinGang


@inject.autoparams()
Expand Down Expand Up @@ -41,7 +42,7 @@ def gang_controller(
.. code-block:: json
{
"status": 201,
"status": 200,
"gangs": {
"gang1": {},
"gang2": {}
Expand Down Expand Up @@ -106,7 +107,7 @@ def create_gang_endpoint() -> Response:
gangs = list()
for res in results:
gangs.append(dict({'id': res.id, 'name': res.name}))
message = {'status': 201, 'gangs': gangs}
message = {'status': 200, 'gangs': gangs}
return jsonify(message)

data = request.json
Expand Down
39 changes: 28 additions & 11 deletions thesheriff/infrastructure/controllers/outlaw_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from flask import Blueprint, jsonify, Response, request

from thesheriff.application.outlaw.create_outlaw import CreateOutlaw
from thesheriff.application.outlaw.invite_friend import InviteFriend
from thesheriff.application.outlaw.list_friends import ListFriends
from thesheriff.application.outlaw.list_gangs import ListGangs
from thesheriff.application.outlaw.request.create_outlaw_request import \
Expand All @@ -20,7 +21,7 @@
@inject.autoparams()
def outlaw_controller(
create_outlaw: CreateOutlaw, list_friends: ListFriends,
list_gangs: ListGangs
list_gangs: ListGangs, invite_friend: InviteFriend
) -> Blueprint:
"""outlaw_controller holds the blueprint for all outlaw routes.
Expand All @@ -30,6 +31,8 @@ def outlaw_controller(
:type list_friends: ListFriends
:param list_gangs: List Gangs use case implementation.
:type list_gangs: ListGangs
:param invite_friend: InviteFiend use case implementation.
:type invite_friend: InviteFriend
:return: Flask Blueprint.
:rtype: Blueprint
Expand Down Expand Up @@ -92,6 +95,25 @@ def outlaw_controller(
"gang2": {}
}
}
* */<prefix>/outlaw/invite_friend/* (POST)
**Request Example:**
.. code-block:: console
$ curl localhost:5000/api/<version>/outlaw/invite_friend/ \\
-X POST --data @examples/json/invite_friend.json \\
-H 'Content-Type: application/json'
**Response Example:**
.. code-block:: json
{
"message": "Invitation sent",
"status": 201
}
"""
blueprint_outlaw = Blueprint('outlaw', __name__)

Expand Down Expand Up @@ -129,16 +151,11 @@ def create_outlaw_endpoint() -> Response:
return jsonify(message)

@blueprint_outlaw.route("/outlaw/invite_friend/", methods=['POST'])
def invite_friend(receiver_mail_address: str) -> Response:
"""Invite friend will receive a mail from a json payload and will send
to him an invitation mail to join the app
:param
:type :
:return: Response.
"""
invite_friend.execute(receiver_mail_address)
# TODO: Fill json response
message = {''}
def invite_friend_endpoint() -> Response:
data = request.get_json()
mail_address = data.get('receiver_mail_address')
invite_friend.execute(mail_address)
message = {'status': 201, 'message': 'Invitation sent'}
return jsonify(message)

return blueprint_outlaw

0 comments on commit 9359539

Please sign in to comment.