Skip to content

API - Favorite plugin #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions Apiki.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"info": {
"_postman_id": "0d272c60-6129-49c9-8dbd-e55c1d329843",
"name": "Apiki",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "15777045"
},
"item": [
{
"name": "Generate Token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"pm.environment.set(\"token\", jsonData.token);"
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"packages": {},
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "username",
"value": "apiki",
"type": "text"
},
{
"key": "password",
"value": "Cw37WnYwesrFt9j",
"type": "text"
}
]
},
"url": {
"raw": "{{server}}{{prefix_path}}/login",
"host": [
"{{server}}{{prefix_path}}"
],
"path": [
"login"
]
}
},
"response": []
},
{
"name": "List Posts Favorites",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": []
},
"url": {
"raw": "{{server}}{{prefix_path}}/favoritePosts",
"host": [
"{{server}}{{prefix_path}}"
],
"path": [
"favoritePosts"
]
}
},
"response": []
},
{
"name": "Favoritar Post",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "postId",
"value": "7",
"type": "text"
},
{
"key": "active",
"value": "1",
"type": "text"
}
]
},
"url": {
"raw": "{{server}}{{prefix_path}}/favoritePosts",
"host": [
"{{server}}{{prefix_path}}"
],
"path": [
"favoritePosts"
]
}
},
"response": []
},
{
"name": "Desfavoritar Post",
"request": {
"method": "DELETE",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"url": {
"raw": "{{server}}{{prefix_path}}/favoritePosts/1",
"host": [
"{{server}}{{prefix_path}}"
],
"path": [
"favoritePosts",
"1"
]
}
},
"response": []
}
]
}
57 changes: 57 additions & 0 deletions README-API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Documentação da API - Apiki

## Descrição
Esta API permite que os usuários se autentiquem e gerenciem seus posts favoritos na plataforma Apiki.

## Endpoints

### 1. Gerar Token
**Descrição**: Gera um token de autenticação para o usuário.

**Método**: POST
**URL**: `{{server}}{{prefix_path}}/login`

**Corpo da Solicitação**:
- `username`: "apiki"
- `password`: "Cw37WnYwesrFt9j"

**Eventos**:
- Ao receber a resposta, salva o token no ambiente do Postman:
```javascript
var jsonData = pm.response.json();
pm.environment.set("token", jsonData.token);
```
### 2. Listar Posts Favoritos
**Descrição**: Lista todos os posts favoritos do usuário autenticado.

**Método**: GET
**URL**: `{{server}}{{prefix_path}}/favoritePosts`

**Cabeçalhos**:
- `Authorization`: "Bearer {{token}}"

---

### 3. Favoritar Post
**Descrição**: Marca um post como favorito.

**Método**: POST
**URL**: `{{server}}{{prefix_path}}/favoritePosts`

**Cabeçalhos**:
- `Authorization`: "Bearer {{token}}"

**Corpo da Solicitação**:
- `postId`: "7"
- `active` (opcional): "1"

---

### 4. Desfavoritar Post
**Descrição**: Desmarca um post como favorito.

**Método**: DELETE
**URL**: `{{server}}{{prefix_path}}/favoritePosts/1`

**Cabeçalhos**:
- `Authorization`: "Bearer {{token}}"
Loading