Sobre a API
Bem vindo a nossa Documentação.
Baixe a coleção para testar no Postman: 
Get Postman Collection
Duvidas, sugestões ou criticas enviar para:  [email protected] 
Empresas
APIs for managing Empresas
Lista
Obtem lista das empresas cadastradas
Example request:
curl -X GET -G "https://fidelizar.me/api/empresas" \
    -H "Authorization: Bearer {token}"
const url = new URL("https://fidelizar.me/api/empresas");
let headers = {
    "Authorization": "Bearer {token}",
    "Accept": "application/json",
    "Content-Type": "application/json",
}
fetch(url, {
    method: "GET",
    headers: headers,
})
    .then(response => response.json())
    .then(json => console.log(json));
Example response (200):
{
    "total": 1,
    "data": [
        {
            "codigo_empresa": 1,
            "nome": "NUC Burguer"
        }
    ]
}
Example response (404):
{
    "message": "No query results for model"
}
Example response (401):
{
    "message": "Unauthenticated."
}
HTTP Request
GET api/empresas
Recompensas
APIs for managing Recompensas
Lista
Obtem lista das empresas cadastradas
Example request:
curl -X GET -G "https://fidelizar.me/api/recompensas" \
    -H "Authorization: Bearer {token}"
const url = new URL("https://fidelizar.me/api/recompensas");
let headers = {
    "Authorization": "Bearer {token}",
    "Accept": "application/json",
    "Content-Type": "application/json",
}
fetch(url, {
    method: "GET",
    headers: headers,
})
    .then(response => response.json())
    .then(json => console.log(json));
Example response (200):
{
    "total": 1,
    "data": [
        {
            "pontuacao": 50,
            "nome": "Pizza Calabresa",
            "descricao": "Descrição detalhada da recompensa",
            "inicio": "2019-01-01",
            "fim": "2019-12-01"
        }
    ]
}
Example response (404):
{
    "message": "No query results for model"
}
Example response (401):
{
    "message": "Unauthenticated."
}
HTTP Request
GET api/recompensas
Resgate
APIs for managing Resgate
Lançar Resgate
Lança resgate;
Example request:
curl -X POST "https://fidelizar.me/api/resgate" \
    -H "Authorization: Bearer {token}" \
    -H "Content-Type: application/json" \
    -d '{"usuario_id":"66999999999","codigo_recompensa":"0001","codigo_empresa":1}'
const url = new URL("https://fidelizar.me/api/resgate");
let headers = {
    "Authorization": "Bearer {token}",
    "Content-Type": "application/json",
    "Accept": "application/json",
}
let body = {
    "usuario_id": "66999999999",
    "codigo_recompensa": "0001",
    "codigo_empresa": 1
}
fetch(url, {
    method: "POST",
    headers: headers,
    body: body
})
    .then(response => response.json())
    .then(json => console.log(json));
Example response (200):
{
    "status": true,
    "codigo_resgate": 1
}
Example response (404):
{
    "message": "No query results for model"
}
HTTP Request
POST api/resgate
Body Parameters
| Parameter | Type | Status | Description | 
|---|---|---|---|
| usuario_id | string | required | ID do Usuario. | 
| codigo_recompensa | string | required | Código do pedido interno. | 
| codigo_empresa | integer | optional | Vincula a venda a determinada empresa. Caso não informado será lançado como geral. | 
Cancelar Resgate
Cancelamento e estorno de pontuação
Example request:
curl -X GET -G "https://fidelizar.me/api/resgate/cancelar/1" \
    -H "Authorization: Bearer {token}"
const url = new URL("https://fidelizar.me/api/resgate/cancelar/1");
let headers = {
    "Authorization": "Bearer {token}",
    "Accept": "application/json",
    "Content-Type": "application/json",
}
fetch(url, {
    method: "GET",
    headers: headers,
})
    .then(response => response.json())
    .then(json => console.log(json));
Example response (200):
{
    "status": true,
    "pontuacao_estornado": 50
}
Example response (404):
{
    "message": "No query results for model"
}
Example response (401):
{
    "message": "Unauthenticated."
}
HTTP Request
GET api/resgate/cancelar/{codigo_resgate}
Usuarios
APIs for managing Usuarios
Consulta
Consulta dados do usuário
Example request:
curl -X GET -G "https://fidelizar.me/api/usuarios/1" \
    -H "Authorization: Bearer {token}"
const url = new URL("https://fidelizar.me/api/usuarios/1");
let headers = {
    "Authorization": "Bearer {token}",
    "Accept": "application/json",
    "Content-Type": "application/json",
}
fetch(url, {
    method: "GET",
    headers: headers,
})
    .then(response => response.json())
    .then(json => console.log(json));
Example response (200):
{
    "celular": 66999999999,
    "cpf": "999.999.999-99",
    "nome": "José",
    "total_gasto": 1000,
    "saldo": 250,
    "acumulado": 500
}
Example response (404):
{
    "message": "No query results for model"
}
Example response (401):
{
    "message": "Unauthenticated."
}
HTTP Request
GET api/usuarios/{id}
Vendas
APIs for managing Vendas
Lançar Venda
Lança venda e pontuação;
Example request:
curl -X POST "https://fidelizar.me/api/vendas" \
    -H "Authorization: Bearer {token}" \
    -H "Content-Type: application/json" \
    -d '{"usuario":{"id":"669999999","tipo_id":"celular","nome":"Joaquin"},"data":"2019-01-01","pedido_numero":"0001","total":55,"pontuacao":1,"codigo_empresa":1}'
const url = new URL("https://fidelizar.me/api/vendas");
let headers = {
    "Authorization": "Bearer {token}",
    "Content-Type": "application/json",
    "Accept": "application/json",
}
let body = {
    "usuario": {
        "id": "669999999",
        "tipo_id": "celular",
        "nome": "Joaquin"
    },
    "data": "2019-01-01",
    "pedido_numero": "0001",
    "total": 55,
    "pontuacao": 1,
    "codigo_empresa": 1
}
fetch(url, {
    method: "POST",
    headers: headers,
    body: body
})
    .then(response => response.json())
    .then(json => console.log(json));
Example response (200):
{
    "total": 1,
    "data": [
        {
            "codigo_empresa": 1,
            "nome": "NUC Burguer"
        }
    ]
}
Example response (404):
{
    "message": "No query results for model"
}
HTTP Request
POST api/vendas
Body Parameters
| Parameter | Type | Status | Description | 
|---|---|---|---|
| usuario | array | required | Array contendo os dados do usuário. | 
| usuario.id | string | required | ID do usuário, normalmente o número do celular. | 
| usuario.tipo_id | string | required | Valores possiveis: id, celular, cpf. | 
| usuario.nome | string | optional | Nome completo do usuário. | 
| data | date | optional | Data da ocorrencia Formato:YYYY-MM-DD. Caso não seja preenchido, será lançado com a data da inclusão. | 
| pedido_numero | string | optional | Código do pedido interno. | 
| total | float | optional | Total da venda -- Importante para campanhas que a pontuação é somada com base no valor da venda. | 
| pontuacao | integer | optional | Caso queira informar a pontuação, será considerado a informada. | 
| codigo_empresa | integer | optional | Vincula a venda a determinada empresa. Caso não informado será lançado como geral. | 
Cancelar Venda
Cancelamento e estorno de pontuação
Example request:
curl -X GET -G "https://fidelizar.me/api/vendas/cancelar/1" \
    -H "Authorization: Bearer {token}"
const url = new URL("https://fidelizar.me/api/vendas/cancelar/1");
let headers = {
    "Authorization": "Bearer {token}",
    "Accept": "application/json",
    "Content-Type": "application/json",
}
fetch(url, {
    method: "GET",
    headers: headers,
})
    .then(response => response.json())
    .then(json => console.log(json));
Example response (200):
{
    "status": true,
    "pontuacao_estornado": 50
}
Example response (404):
{
    "message": "No query results for model"
}
Example response (401):
{
    "message": "Unauthenticated."
}
HTTP Request
GET api/vendas/cancelar/{codigo_venda}