Public | Automated Build

Last pushed: 10 months ago
Short Description
for presentation purpose
Full Description

Friday API

Just for presentation purpose

.. image:: https://travis-ci.org/jesuejunior/friday-api.svg?branch=master
:target: https://travis-ci.org/jesuejunior/friday-api

Installation

Developing

Requirements

* python 3.5
* SQLite3
* pip
  • Create your virtualenv

.. code-block:: shell

$ make dev

Tests

Execute test insede of your virtualenv

.. code-block:: shell

$ make test

For a manually test, you could see Makefile to get step-by-step

Deploy

It's easily deployable by docker.

.. code-block:: shell

$ docker run -it -d --name friday -p 8000:8000 -e DEBUG=False jesuejunior/friday

Endpoints

POST IP:PORT/users

.. code-block:: javascript

{
    "name": "Maria das Dores",
    "email": "maria@dores.org",
    "password": "pass2",
    "phones": [
        {
            "number": "999991232",
            "ddd": "21"
        }
    ]
}

response

.. code-block:: json

{
  "id": 1,
  "name": "Maria das Dores",
  "email": "maria@dores.org",
  "password": "pbkdf2_sha256$30000$PKSozMq25Guo$fMRnbVtmLggo/0NsMOU8F4VRth9wQoqPY1cbv15X0qU=",
  "phones": [
    {
      "number": 999991232,
      "ddd": 21
    }
  ],
  "created": "2016-10-10T02:33:57.365806",
  "modified": "2016-10-10T02:33:57.365818",
  "last_login": "2016-10-10T02:33:57.404225",
  "token": null
}

GET IP:PORT/users

.. code-block:: json

[
  {
    "id": 1,
    "name": "Maria das Dores",
    "email": "maria@dores.org",
    "password": "pbkdf2_sha256$30000$PKSozMq25Guo$fMRnbVtmLggo/0NsMOU8F4VRth9wQoqPY1cbv15X0qU=",
    "phones": [
      {
        "number": 999991232,
        "ddd": 21
      }
    ],
    "created": "2016-10-10T02:33:57.365806",
    "modified": "2016-10-10T02:33:57.365818",
    "last_login": "2016-10-10T02:33:57.404225",
    "token": null
  },
  {
    "id": 2,
    "name": "Maria das Dores Silva",
    "email": "maria@silva.org",
    "password": "pbkdf2_sha256$30000$D9qtuRG8OxYW$b1PUDGQqgLRkzKdlGXrVN7oEGpENrCWJ5srwoSmhOKM=",
    "phones": [
      {
        "number": 999991234,
        "ddd": 21
      }
    ],
    "created": "2016-10-10T02:36:32.675887",
    "modified": "2016-10-10T02:36:32.675902",
    "last_login": "2016-10-10T02:36:32.728614",
    "token": null
  }
]

POST IP:PORT/users/login

.. code-block:: javascript

{
    "email": "maria@dores.org",
    "password": "pass2"
}

response

.. code-block:: json

{
  "id": 1,
  "name": "Maria das Dores",
  "email": "maria@dores.org",
  "password": "pbkdf2_sha256$30000$PKSozMq25Guo$fMRnbVtmLggo/0NsMOU8F4VRth9wQoqPY1cbv15X0qU=",
  "phones": [
    {
      "number": 999991232,
      "ddd": 21
    }
  ],
  "created": "2016-10-10T02:33:57.365806",
  "modified": "2016-10-10T02:33:57.365818",
  "last_login": "2016-10-10T02:37:57.205851",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NzYwNjg4NzcsIm9yaWdfaWF0IjoxNDc2MDY3MDc3LCJlbWFpbCI6Im1hcmlhQGRvcmVzLm9yZyIsInVzZXJfaWQiOjEsInVzZXJuYW1lIjoibWFyaWFAZG9yZXMub3JnIn0.zoBV7hyyjbGQEoMDWgdLPsNtiKInh16yZ-DdVSP3CWs"
}

GET IP:PORT/users/:id (Authentcated)

For an endpoint authenticated you must add follow header.

.. code-block:: javascript

{"Authorization": "JWT Token"

For example

.. code-block:: shell

http 127.0.0.1:8000/users/1 Authorization:"JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NzYwNjg4NzcsIm9yaWdfaWF0IjoxNDc2MDY3MDc3LCJlbWFpbCI6Im1hcmlhQGRvcmVzLm9yZyIsInVzZXJfaWQiOjEsInVzZXJuYW1lIjoibWFyaWFAZG9yZXMub3JnIn0.zoBV7hyyjbGQEoMDWgdLPsNtiKInh16yZ-DdVSP3CWs"
HTTP/1.1 200 OK
Allow: GET, PUT, HEAD, OPTIONS
Connection: close
Content-Type: application/json
Date: Mon, 10 Oct 2016 02:45:13 GMT
Server: gunicorn/19.6.0
Transfer-Encoding: chunked
X-Frame-Options: SAMEORIGIN

{
    "created": "2016-10-10T02:33:57.365806",
    "email": "maria@dores.org",
    "id": 1,
    "last_login": "2016-10-10T02:37:57.205851",
    "modified": "2016-10-10T02:33:57.365818",
    "name": "Maria das Dores",
    "password": "pbkdf2_sha256$30000$PKSozMq25Guo$fMRnbVtmLggo/0NsMOU8F4VRth9wQoqPY1cbv15X0qU=",
    "phones": [
        {
            "ddd": 21,
            "number": 999991232
        }
    ],
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0NzYwNjg4NzcsIm9yaWdfaWF0IjoxNDc2MDY3MDc3LCJlbWFpbCI6Im1hcmlhQGRvcmVzLm9yZyIsInVzZXJfaWQiOjEsInVzZXJuYW1lIjoibWFyaWFAZG9yZXMub3JnIn0.zoBV7hyyjbGQEoMDWgdLPsNtiKInh16yZ-DdVSP3CWs"
}

LICENSE

It's released under the BSD-3-Clause_.

.. _BSD-3-Clause: LICENSE

TODO: Improve docs

Docker Pull Command
Owner
jesuejunior
Source Repository

Comments (0)