Mudanças entre as edições de "Controllr/API/REST-HTTP"

De BrByte Wiki
< Controllr‎ | API
Linha 1: Linha 1:
===API===
+
==='''API'''===
  
 
Instruções de como capturar informações dos seus clientes.  
 
Instruções de como capturar informações dos seus clientes.  
  
== Requisição de LOGIN ==
+
== '''Requisição de LOGIN''' ==
  
Requisição POST para http://[IP-SERVIDOR]/login
+
Requisição POST para http://[IP-SERVIDOR]/login  
com body username=USER&password=PASS
+
 
 +
Com body username=USER&password=PASS
  
 
Autenticação
 
Autenticação
  
 
<div>
 
<div>
<span class="label label-info">POST</span>
+
<span class="label label-info">POST</span> <span class="label label-concrete">/login</span>
<span class="label label-concrete">/login</span>
 
 
</div>
 
</div>
  
 
<blockquote><pre>
 
<blockquote><pre>
 +
 
curl -i -X POST \
 
curl -i -X POST \
 
     -H "Content-Type:application/x-www-form-urlencoded" \
 
     -H "Content-Type:application/x-www-form-urlencoded" \
Linha 22: Linha 23:
 
     -d "password=admin" \
 
     -d "password=admin" \
 
     <nowiki> 'http://[$IP-do-servidor]/login'</nowiki>  
 
     <nowiki> 'http://[$IP-do-servidor]/login'</nowiki>  
 +
 
</pre></blockquote>
 
</pre></blockquote>
  
Linha 28: Linha 30:
 
Na resposta do Login, capturar o cookie que será usado para requisição
 
Na resposta do Login, capturar o cookie que será usado para requisição
  
<div><span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span></div>
+
<div>
 +
<span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span>
 +
</div>
  
 
<blockquote class="blockquote-neutral"><pre>
 
<blockquote class="blockquote-neutral"><pre>
 +
 +
 
HTTP/1.1 200 OK
 
HTTP/1.1 200 OK
 
Server: nginx/1.10.2
 
Server: nginx/1.10.2
Linha 40: Linha 46:
 
    
 
    
 
{"success": true}
 
{"success": true}
 +
 
</pre></blockquote>
 
</pre></blockquote>
  
 
Para capturar as informações do Dashboard, fazer uma requisição usando o Cookie previamente autenticado.
 
Para capturar as informações do Dashboard, fazer uma requisição usando o Cookie previamente autenticado.
  
<div><span class="label label-info">POST</span> <span class="label label-concrete">/controllrctl/dashboard/info</span></div>
+
<div>
 +
<span class="label label-info">POST</span> <span class="label label-concrete">/controllrctl/dashboard/info</span>
 +
</div>
  
 
<blockquote><pre>
 
<blockquote><pre>
 +
 
curl -i -X GET \
 
curl -i -X GET \
 
   -H "Accept:application/json" \
 
   -H "Accept:application/json" \
 
   -H "Cookie:BRBOSCookie=af3a254b467d7480173f1d739a380d1e" \
 
   -H "Cookie:BRBOSCookie=af3a254b467d7480173f1d739a380d1e" \
 
     <nowiki> 'http://192.168.142.23:8080/controllrctl/dashboard/info'</nowiki>
 
     <nowiki> 'http://192.168.142.23:8080/controllrctl/dashboard/info'</nowiki>
 +
 
</pre></blockquote>
 
</pre></blockquote>
  
  
 
=='''Capturar Informações do Cliente'''==
 
=='''Capturar Informações do Cliente'''==
 +
 +
<div>
 +
<span class="label label-info">POST</span> <span class="label label-concrete">/site_ctl/config/info</span>
 +
</div>
 +
 +
<blockquote><pre>
  
 
   curl -i -X POST \
 
   curl -i -X POST \
Linha 63: Linha 80:
 
       <nowiki>'http://192.168.142.23/site_ctl/config/info'</nowiki>   
 
       <nowiki>'http://192.168.142.23/site_ctl/config/info'</nowiki>   
  
<div><span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span></div>
+
</pre></blockquote>
 +
 
 +
<div>
 +
<span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span>
 +
</div>
 +
 
 +
<blockquote class="blockquote-neutral"><pre>
 
   
 
   
 
  {
 
  {
Linha 82: Linha 105:
 
  }
 
  }
  
 +
</pre></blockquote>
  
 
=='''Alterar senha do Login'''==
 
=='''Alterar senha do Login'''==
  
<div><span class="label label-info">POST</span> <span class="label label-concrete">/session/setpassword</span></div>
+
<div>
 +
<span class="label label-info">POST</span> <span class="label label-concrete">/session/setpassword</span>
 +
</div>
  
  
Linha 102: Linha 128:
  
 
<blockquote><pre>
 
<blockquote><pre>
 +
 
curl -i -X POST \
 
curl -i -X POST \
 
     -H "Content-Type:application/x-www-form-urlencoded" \
 
     -H "Content-Type:application/x-www-form-urlencoded" \
Linha 108: Linha 135:
 
     -d "user_password_repeat: Nova senha" \
 
     -d "user_password_repeat: Nova senha" \
 
     <nowiki>'http://192.168.142.23/session/setpassword'</nowiki>
 
     <nowiki>'http://192.168.142.23/session/setpassword'</nowiki>
 +
 
</pre></blockquote>
 
</pre></blockquote>
  
<div><span class="label label-success">Resposta</span><span class="label label-concrete">JSON</span></div>
+
<div>
 +
<span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span>
 +
</div>
  
 
<blockquote class="blockquote-neutral"><pre>
 
<blockquote class="blockquote-neutral"><pre>
 +
 
{
 
{
 
     "success": true,
 
     "success": true,
Linha 123: Linha 154:
 
     ]
 
     ]
 
}
 
}
 +
 
</pre></blockquote>
 
</pre></blockquote>
  
 
=='''Listagem do Contratos'''==
 
=='''Listagem do Contratos'''==
 +
 +
<div>
 +
<span class="label label-info">POST</span> <span class="label label-concrete">/controllr_client/contract/list</span>
 +
</div>
 +
 +
<blockquote><pre>
  
 
   curl -i -X POST \
 
   curl -i -X POST \
Linha 137: Linha 175:
 
       <nowiki>'http://192.168.142.23/controllr_client/contract/list'</nowiki>
 
       <nowiki>'http://192.168.142.23/controllr_client/contract/list'</nowiki>
  
<div><span class="label label-success">Resposta</span><span class="label label-concrete">JSON</span></div>
+
</pre></blockquote>
 +
 
 +
<div>
 +
<span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span>
 +
</div>
 +
 
 +
<blockquote class="blockquote-neutral"><pre>
  
 
  {
 
  {
Linha 153: Linha 197:
 
  }
 
  }
  
 +
</pre></blockquote>
  
 
=='''Listagem de Cobranças'''==
 
=='''Listagem de Cobranças'''==
 +
 +
<div>
 +
<span class="label label-info">POST</span> <span class="label label-concrete">/invoice_ctl/invoice/list</span>
 +
</div>
 +
 +
<blockquote><pre>
  
 
   curl -i -X POST \
 
   curl -i -X POST \
Linha 166: Linha 217:
 
       <nowiki>'http://192.168.142.23/invoice_ctl/invoice/list'</nowiki>
 
       <nowiki>'http://192.168.142.23/invoice_ctl/invoice/list'</nowiki>
  
Resposta da captura
+
</pre></blockquote>
 +
 
 +
<div>
 +
<span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span>
 +
</div>
 +
 
 +
<blockquote class="blockquote-neutral"><pre>
  
 
  {
 
  {
Linha 203: Linha 260:
 
  }
 
  }
  
 +
</pre></blockquote>
  
 
=='''Listagem de Conexões'''==
 
=='''Listagem de Conexões'''==
  
 +
<div>
 +
<span class="label label-info">POST</span> <span class="label label-concrete">/controllr_client/cpe/list</span>
 +
</div>
 +
 +
<blockquote><pre>
  
 
   curl -i -X POST \
 
   curl -i -X POST \
Linha 217: Linha 280:
 
       <nowiki>'http://192.168.142.23/controllr_client/cpe/list'</nowiki>
 
       <nowiki>'http://192.168.142.23/controllr_client/cpe/list'</nowiki>
  
 +
</pre></blockquote>
  
Resposta da captura
+
<div>
 +
<span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span>
 +
</div>
 +
 
 +
<blockquote class="blockquote-neutral"><pre>
  
 
  {
 
  {
Linha 288: Linha 356:
 
  }
 
  }
  
 +
</pre></blockquote>
  
 
=='''Listagem de Suportes'''==
 
=='''Listagem de Suportes'''==
 +
 +
<div>
 +
<span class="label label-info">POST</span> <span class="label label-concrete">/controllr_client/support/list</span>
 +
</div>
 +
 +
<blockquote><pre>
  
 
   curl -i -X POST \
 
   curl -i -X POST \
Linha 301: Linha 376:
 
       <nowiki>'http://192.168.142.23/controllr_client/support/list'</nowiki>
 
       <nowiki>'http://192.168.142.23/controllr_client/support/list'</nowiki>
  
 +
</pre></blockquote>
  
Resposta da captura
+
<div>
 +
<span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span>
 +
</div>
 +
 
 +
<blockquote class="blockquote-neutral"><pre>
  
 
  {
 
  {
Linha 321: Linha 401:
 
     ]
 
     ]
 
  }
 
  }
 +
 +
</pre></blockquote>
  
 
=='''Criação de Suporte Técnico'''==
 
=='''Criação de Suporte Técnico'''==
 +
 +
<div>
 +
<span class="label label-info">POST</span> <span class="label label-concrete">/controllr_client/support/create</span>
 +
</div>
 +
 +
<blockquote><pre>
  
 
   curl -i -X POST \
 
   curl -i -X POST \
Linha 333: Linha 421:
 
       <nowiki>'http://192.168.142.23/controllr_client/support/create'</nowiki>
 
       <nowiki>'http://192.168.142.23/controllr_client/support/create'</nowiki>
  
 +
</pre></blockquote>
 +
 +
<div>
 +
<span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span>
 +
</div>
  
Resposta da captura
+
<blockquote class="blockquote-neutral"><pre>
  
 
  {
 
  {
Linha 358: Linha 451:
 
  }
 
  }
  
 +
</pre></blockquote>
  
 
=='''Listagem de Tarefas do Suporte Técnico'''==
 
=='''Listagem de Tarefas do Suporte Técnico'''==
 +
 +
<div>
 +
<span class="label label-info">POST</span> <span class="label label-concrete">/controllr_client/support/tasklist</span>
 +
</div>
 +
 +
<blockquote><pre>
  
 
   curl -i -X POST \
 
   curl -i -X POST \
Linha 368: Linha 468:
 
     <nowiki>'http://192.168.142.23/controllr_client/support/tasklist'</nowiki>
 
     <nowiki>'http://192.168.142.23/controllr_client/support/tasklist'</nowiki>
  
 +
</pre></blockquote>
  
Resposta da captura
+
<div>
 +
<span class="label label-success">Resposta</span> <span class="label label-concrete">JSON</span>
 +
</div>
  
 +
<blockquote class="blockquote-neutral"><pre>
  
 
  {
 
  {
Linha 403: Linha 507:
 
  }
 
  }
  
 +
</pre></blockquote>
  
  
 
__NOEDITSECTION__
 
__NOEDITSECTION__

Edição das 12h40min de 7 de agosto de 2018

API

Instruções de como capturar informações dos seus clientes.

Requisição de LOGIN

Requisição POST para http://[IP-SERVIDOR]/login

Com body username=USER&password=PASS

Autenticação

POST /login


curl -i -X POST \
    -H "Content-Type:application/x-www-form-urlencoded" \
    -H "Accept:application/json" \
    -d "username=admin" \
    -d "password=admin" \
     'http://[$IP-do-servidor]/login' 

RESPOSTA - pegar o cookie do cabeçalho Set-Cookie

Na resposta do Login, capturar o cookie que será usado para requisição

Resposta JSON



HTTP/1.1 200 OK
Server: nginx/1.10.2
Date: Fri, 20 Apr 2018 20:46:26 GMT
Content-Type: application/json
Content-Length: 17
Connection: keep-alive
Set-Cookie: BRBOSCookie=c7a361caa000fab3680a558910c4f33c; expires=Sat, 20 Apr 2019 20:56:26 GMT; path=/
  
{"success": true}

Para capturar as informações do Dashboard, fazer uma requisição usando o Cookie previamente autenticado.

POST /controllrctl/dashboard/info


curl -i -X GET \
   -H "Accept:application/json" \
   -H "Cookie:BRBOSCookie=af3a254b467d7480173f1d739a380d1e" \
     'http://192.168.142.23:8080/controllrctl/dashboard/info'


Capturar Informações do Cliente

POST /site_ctl/config/info


  curl -i -X POST \
        -H "Content-Type:application/x-www-form-urlencoded" \
        -H "Accept:application/json" \
        -d "username=teste" \
        -d "password=12345678" \
      'http://192.168.142.23/site_ctl/config/info'  

Resposta JSON

 
 {
    "success": true,
    "facebook": {
        "page": "https://www.facebook.com/ispcontrollr",
        "title": "FACEBOOK"
    },
    "anatel": {
        "scm": "00000",
        "title": "Provedor Licenciado"
    },
    "title": "Meu Provedor",
    "theme": "brbyte-light",
    "support_open_time": 5,
    "print_contract": 1,
    "change_password": 1
 }

Alterar senha do Login

POST /session/setpassword


PROPRIEDADE TIPO TAMANHO OBRIGATÓRIO DESCRIÇÃO
user_password Texto 8~16 Sim Senha
user_password_repeat Texto 8~16 Sim Senha de novo

curl -i -X POST \
    -H "Content-Type:application/x-www-form-urlencoded" \
    -H "Accept:application/json" \
    -d "user_password: Nova senha" \
    -d "user_password_repeat: Nova senha" \
    'http://192.168.142.23/session/setpassword'

Resposta JSON


{
    "success": true,
    "total": 1,
    "results": [
        {
            "client_username": "teste",
            "client_pk": 1
        }
    ]
}

Listagem do Contratos

POST /controllr_client/contract/list


  curl -i -X POST \
        -H "Content-Type:application/x-www-form-urlencoded" \
        -H "Accept:application/json" \
        -d "limit: 10" \
        -d "start: 0" \
        -d "page: 0" \
        -d "sort: contract_pk" \
        -d "dir: ASC" \
      'http://192.168.142.23/controllr_client/contract/list'

Resposta JSON


 {
    "success": true,
    "total": 1,
    "results": [
        {
            "contract_pk": 3,
            "contract_number": 3,
            "contract_pay_day": 10,
            "contract_amount": "1",
            "contract_date_cad": "2018-05-15 16:19:45"
        }
    ]
 }

Listagem de Cobranças

POST /invoice_ctl/invoice/list


  curl -i -X POST \
        -H "Content-Type:application/x-www-form-urlencoded" \
        -H "Accept:application/json" \
        -d "limit: 15" \
        -d "start: 0" \
        -d "page: 0" \
        -d "sort: invoice_date_due" \
        -d "dir: DESC" \
      'http://192.168.142.23/invoice_ctl/invoice/list'

Resposta JSON


 {
    "success": true,
    "total": 2,
    "results": [
        {
            "contract_pk": null,
            "contract_number": null,
            "invoice_pk": 11,
            "bank_account_code": "0",
            "invoice_gn_link": null,
            "invoice_date_due": "2018-05-11",
            "invoice_amount_document": "15",
            "invoice_date_credit": "2018-05-11",
            "invoice_amount_paid": "15.00",
            "invoice_type": 1,
            "invoice_state": 0,
            "invoice_obs": 4
        },
        {
            "contract_pk": null,
            "contract_number": null,
            "invoice_pk": 2,
            "bank_account_code": "0",
            "invoice_gn_link": null,
            "invoice_date_due": "2018-05-09",
            "invoice_amount_document": "123",
            "invoice_date_credit": "2018-05-14",
            "invoice_amount_paid": "123.00",
            "invoice_type": 1,
            "invoice_state": 0,
            "invoice_obs": 4
        }
    ]
 }

Listagem de Conexões

POST /controllr_client/cpe/list


  curl -i -X POST \
        -H "Content-Type:application/x-www-form-urlencoded" \
        -H "Accept:application/json" \
        -d "limit: 15" \
        -d "start: 0" \
        -d "page: 0" \
        -d "sort: contract_pk" \
        -d "dir: DESC" \
      'http://192.168.142.23/controllr_client/cpe/list'

Resposta JSON


 {
    "success": true,
    "total": 1,
    "results": [
        {
            "network_cpe_pk": 2,
            "network_cpe_automac": false,
            "network_cpe_autoip": false,
            "network_cpe_status": 0,
            "network_cpe_ip": "",
            "network_cpe_mac": "",
            "network_cpe_mac_status": 2,
            "network_cpe_ip_status": 2,
            "network_cpe_username": "123",
            "network_cpe_password": "123",
            "network_cpe_authentication_type": 3,
            "network_cpe_date_cad": "2018-05-15 16:20:34",
            "network_cpe_deleted": false,
            "network_cpe_commom_interface": null,
            "network_cpe_commom_device_name": null,
            "network_cpe_commom_lastip": null,
            "network_cpe_commom_rates": null,
            "network_cpe_commom_rx_rate": null,
            "network_cpe_commom_tx_rate": null,
            "network_cpe_commom_distance": null,
            "network_cpe_commom_tx_ccq": null,
            "network_cpe_commom_signal_rx": null,
            "network_cpe_commom_signal_tx": null,
            "network_cpe_commom_noisefloor": null,
            "network_cpe_commom_idle": null,
            "network_cpe_commom_tx_bytes": null,
            "network_cpe_commom_rx_bytes": null,
            "network_cpe_especdata": null,
            "network_cpe_commom_rx_ccq": null,
            "network_cpe_commom_ping": null,
            "network_cpe_commom_uptime": null,
            "network_cpe_lending": 0,
            "network_cpe_lastupdate": null,
            "network_cpe_reduced_speed": false,
            "network_cpe_reduced_speed_date": null,
            "network_cpe_turbo_active": false,
            "network_cpe_wifi_encryption_type": 0,
            "network_cpe_wifi_encryption_password": null,
            "network_cpe_access_login": "",
            "network_cpe_access_password": "",
            "network_cpe_access_port": "22",
            "network_cpe_longitude": "0",
            "network_cpe_latitude": "0",
            "network_cpe_circuit_id": "",
            "network_cpe_circuit_id_hex": null,
            "network_cpe_fiber": 0,
            "network_cpe_fiber_onu_mac": null,
            "network_cpe_fiber_device_pk": null,
            "network_cpe_fiber_onu_pppoe_svc_name": null,
            "network_cpe_req_origin": 0,
            "suppliers_pk": null,
            "network_devices_pk": 3,
            "network_cpe_model_pk": null,
            "radius_plans_pk": 1,
            "contract_pk": 3,
            "network_subnets_pk": 1,
            "client_pk": 1,
            "panel_pk": 1,
            "network_cpe_control_pk": 0
        }
    ]
 }

Listagem de Suportes

POST /controllr_client/support/list


  curl -i -X POST \
        -H "Content-Type:application/x-www-form-urlencoded" \
        -H "Accept:application/json" \
        -d "limit: 10" \
        -d "start: 0" \
        -d "page: 0" \
        -d "sort: os_date_entry" \
        -d "dir: ASC" \
      'http://192.168.142.23/controllr_client/support/list'

Resposta JSON


 {
    "success": true,
    "total": 1,
    "results": [
        {
            "support_protocol": "2018051515386",
            "os_obs": "Sua descrição",
            "os_date_entry": "2018-05-15 15:38:45",
            "os_date_soluction": null,
            "os_date_sched": "2018-05-15 15:38:45",
            "os_done": 0,
            "os_amount": null,
            "task_name": "Viabilidade",
            "task_desc": "Teste de viabilidade técnica para instalação de internet"
        }
    ]
 }

Criação de Suporte Técnico

POST /controllr_client/support/create


  curl -i -X POST \
        -H "Content-Type:application/x-www-form-urlencoded" \
        -H "Accept:application/json" \
        -d "priority: 0" \
        -d "task_pk: 1" \
        -d "phone: 67998083499" \
        -d "os_obs: Sua Descrição" \
      'http://192.168.142.23/controllr_client/support/create'

Resposta JSON


 {
    "success": true,
    "total": 1,
    "results": [
        {
            "os_pk": -1,
            "os_obs": "1.12337081805556",
            "os_desc": null,
            "os_date_entry": null,
            "os_date_soluction": null,
            "os_date_sched": null,
            "os_done": null,
            "os_deleted": null,
            "os_amount": null,
            "staff_pk": null,
            "task_pk": null,
            "os_create_type": null,
            "support_pk": null
        }
    ]
 }

Listagem de Tarefas do Suporte Técnico

POST /controllr_client/support/tasklist


  curl -i -X POST \
        -H "Content-Type:application/x-www-form-urlencoded" \
        -H "Accept:application/json" \
        -d "sort: task_name" \
        -d "dir: ASC" \
     'http://192.168.142.23/controllr_client/support/tasklist'

Resposta JSON


 {
    "success": true,
    "total": 6,
    "results": [
        {
            "task_pk": 5,
            "task_name": "Desinstalação"
        },
        {
            "task_pk": 8,
            "task_name": "Desinstalação Equipamento"
        },
        {
            "task_pk": 2,
            "task_name": "Instalação"
        },
        {
            "task_pk": 3,
            "task_name": "Suporte Técnico"
        },
        {
            "task_pk": 4,
            "task_name": "Troca de Equipamento"
        },
        {
            "task_pk": 1,
            "task_name": "Viabilidade"
        }
    ]
 }