Commit aa9c5b4ab2af60eac8bf33dbd23f73df51198144
Committed by
GitHub
1 parent
7c0feca5
Exists in
master
and in
5 other branches
Modificando documentação da API #266
Showing
1 changed file
with
19 additions
and
9 deletions
Show diff stats
README.md
... | ... | @@ -80,14 +80,31 @@ Para Classes que envolvem formulários: |
80 | 80 | * `CreateCourseForm` |
81 | 81 | * `UpdateCourseForm()` |
82 | 82 | |
83 | +[PT-BR] | |
84 | +##API Descrição | |
85 | +Estamos usando em sua maioria viewsets ( http://www.django-rest-framework.org/api-guide/viewsets/) para construir os endpoints da nossa API. Ela tem como função compartilhar os dados da instância do Amadeus com aplicações credenciadas. | |
86 | + | |
87 | +##API Setup | |
88 | +**Criar aplicação** | |
89 | +* Vá para "/o/applications/" e clique "new application". Um formulário irá aparecer para preencher. | |
90 | +* No formulário, preencha somente o "Name" com o nome da aplicação, os campos "client id" e "client secret" são gerados automaticamente e não devem ser modificados. | |
91 | +"Client type" deve ser confidential, e "Authorization Grant Type" como " Resource owner password-based". | |
92 | + | |
93 | +**Obtendo um access Token** | |
94 | + | |
95 | +* Crie um request, usando um usuário valido, usando o seguinte abaixo (lembre-se que isso é um POST, estou usando um comando curl para fins de teste): | |
96 | +curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" -u"<client_id>:<client_secret>" http://amadeus/o/token/ | |
83 | 97 | |
84 | -##API Description | |
85 | -We are using mostly viewsets ( http://www.django-rest-framework.org/api-guide/viewsets/) to build our API endpoints now, so all default methods and API points were kept. | |
98 | +* finalmente, com o seu access token, você pode testar um dos endpoints usando o template abaixo: | |
99 | +curl -H "Authorization: Bearer <your_access_token>" -X POST -d"username=foo&password=bar" http://localhost:8000/users/ (inserting a new user) | |
100 | + | |
86 | 101 | |
87 | 102 | * model list(GET) = list all objects from that mode in pagination mode, each page has 10 |
88 | 103 | * model detail(GET) = give the details of the objects and most important fields of the ones objects its has relationships. |
89 | 104 | * model create |
90 | 105 | |
106 | +**API Endpoints ** | |
107 | + | |
91 | 108 | **Courses (URL: coursesapi)** |
92 | 109 | * course list ("/coursesapi/") |
93 | 110 | * course detail ("/coursesapi/id") (id is a parameter) |
... | ... | @@ -104,14 +121,7 @@ We are using mostly viewsets ( http://www.django-rest-framework.org/api-guide/vi |
104 | 121 | * logs list ("/logs/") |
105 | 122 | * log detail ("/logs/id") (id is a parameter) |
106 | 123 | |
107 | -#Obtaining an Access Token | |
108 | -* First build an application o "amadeus/o/applications" following this tutorial: http://django-oauth-toolkit.readthedocs.io/en/latest/tutorial/tutorial_01.html#create-an-oauth2-client-application | |
109 | 124 | |
110 | -* Then request, using a valid user, an access token using the following template (you'll have to know how to translate a GET Method into a POST one) | |
111 | -curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" -u"<client_id>:<client_secret>" http://amadeus/o/token/ | |
112 | - | |
113 | -* finally, with your access token you can use test using | |
114 | -curl -H "Authorization: Bearer <your_access_token>" -X POST -d"username=foo&password=bar" http://localhost:8000/users/ (inserting a new user) | |
115 | 125 | |
116 | 126 | |
117 | 127 | ## Link's úteis | ... | ... |