NAV Navbar
Logo
javascript

Introdução

Seja bem vindo!

Nesta documentação tentaremos explicar como funciona a integração com o Dental Office Cloud, e apresentar as rotas disponíveis nesta integração.

O Dental Office Cloud possui uma API Rest, com entrada e saída de dados no formato JSON. A autenticação desta API é baseada em um Token de acesso, E-mail do usuário e o Registro do Device utilizado.

Endpoint

Cada cliente do Dental Office possui um endpoint de acesso diferente. Ao solicitar o token de acesso em um endpoint padrão, será retornado um hash em um atributo chamado client_key, este hash deverá ser usado como subdomínio das rotas da API.

Endpoint Padrão

https://no.api.stage.dentaloffice.com.br

Este endpoint é utilizado nas rotas genéricas, como solicitar token de acesso!

Endpoint do Cliente

https://ae2sc4.api.stage.dentaloffice.com.br

Este endpoint é utilizado em todas as rotas da API. O valor ae2sc4 deve ser substituído pelo valor do campo client_key, retornado na rota de solicitação de token.

Erros

No caso de algum erro, é retornado um JSON com detalhes do erro. O JSON segue o seguinte formato:

{"errors":{"format_error":["The request must be json."]}}

Autenticação

Para ter permissão para requisitar as rotas da API do Dental Cloud é preciso solicitar um token, informando o e-mail e senha de um usuário cadastrado. Caso tenha sucesso, esta request irá lhe retornar algumas informações do usuário que você precisará usar nas próximas requests.

Solicitar Token de Acesso

Para solicitar o Token, use o script abaixo:

var data = JSON.stringify({
  "email": "email@example.com.br",
  "password": "password1234",
  "register": "asdasdads",
  "platform": "web"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://no.api.stage.dentaloffice.com.br/auth/tokens.json");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
    "expiration_date": null,
    "trial_period": null,
    "client_key": "jp4vxkv",
    "device_id": 2,
    "token": "MN-ubYyfM8U8B3fZUeng",
    "socket_token": "EzvjounIKEs1zIOBgRX9oO20XSmv0bWsO7YUs6IsvUwTeuk4Je66GRoev3acaXk-V5exQVOjDteJ4WortMfUkQaEb2F4vcQKVNmdjxrqnC3yu2WrGv2hjGwCXwpWwYKG4p-RYrUb61Er77RTrlMleFI1X2yAhrj8veZm0lNDF0XEiESF8_t5ddWACp3jv2NIvB_ChW3L6nikxPvNg6LLpIDb_hLwNrsmjSP96mawJTI%3D",
    "user": {
        "id": 1,
        "name": "Marcos Junior",
        "email": "marcos@maini.com.br",
        "user_group": {
            "id": 1,
            "name": "Administrador",
            "permission_type": "admin"
        },
        "clinics": [
            {
                "id": 1,
                "name": "Marcos Junior",
                "logo_url": "http://newdow-sp.s3.amazonaws.com/resources/jp4vxkv/clinics/logo/1/thumb/data?1481591146",
                "ev_cash_enabled": true
            },
            {
                "id": 2,
                "name": "Clínica Filial",
                "logo_url": "https://newdow-sp.s3.amazonaws.com/assets/images/dental.png",
                "ev_cash_enabled": false
            }
        ],
        "user_preference": {
            "id": 1,
            "calendar_weekend": true,
            "calendar_dentist": 0,
            "calendar_chair": 0
        },
        "permissions": [
          ...
        ]
    }
}

HTTP Request

POST /auth/tokens.json

Parâmetros

Nome Obrigatório Descrição
email sim E-mail do usuário
password sim Senha do usuário
register sim Código de identificação do device utilizado
platform sim Plataforma utilizada (Ex: Web, Android, iOS)

Headers

Para que as rotas seguintes sejam autenticadas, é necessário enviar através do cabeçalho da request algumas informações.

Header Conteúdo
X-User-Token Token retornado na request
X-User-Email Email de login do usuário
X-Device-Register Código do device utilizado

Possíveis erros

Abaixo seguem os possíveis erros para esta rota.

Código do Status Código do Erro Descrição
401 format_error A requisição precisa ser por JSON
401 request_login_and_password É obrigatório o envio do email e senha
401 request_device_register É obrigatório o envio do registro do device
401 request_device_platform É obrigatório o envio da Plataforma
401 invalid_login O e-mail informado é inválido ou não existe em nosso sistema
401 invalid_password A senha informada é inválida

Usuários

Buscar Usuários

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/users.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "total_pages": 1,
  "count": 1,
  "from": 1,
  "to": 1,
  "current_page": 1,
  "results": [
    {
      "id": 1,
      "name": "User 2",
      "email": "email@example.com.br",
      "additional_info": null,
      "ev_cash_terminal_id": null,
      "deleted_at": null,
      "invitation_accepted": true,
      "contacts_attributes": [],
      "confirmed_at": "2016-11-16T16:24:39.000Z",
      "user_group": {
        "id": 8,
        "name": "Aluno"
      }
    }
  ]
}

Rota

GET /users.json

Query Parameters

Parâmetro Valor Padrão Descrição
q Caracteres para pesquisa
page 1 Número da página

Cadastrar Usuários

var data = JSON.stringify({
  "user": {
    "user_group_id": 1,
    "name": "User 2",
    "email": "email2@example.com.br",
    "password": "12345678" (optional)
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://ae2sc4.api.stage.dentaloffice.com.br/users.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "id": 2,
  "name":"User 2",
  "email": "email2@example.com.br",
  "user_group": {
    "id": 1,
    "name": "Administrador"
  },
  "contacts_attributes": [],
  "addresses_attributes": [],
  "created_at": "2017-09-01T17:42:05.000Z",
  "updated_at": "2017-09-01T17:42:05.000Z"
}

Rota

POST /users.json

Parâmetros

Nome Obrigatório Descrição
user sim Objeto com informações do usuário
user.name sim Nome do Usuário
user.user_group_id sim Id do Grupo que o usuário pertence
user.email sim E-mail do usuário
user.password não senha não criptografada do usuário

Se uma senha for fornecida, a API não enviará um convite para o usuário, cadastrando-o com esta senha. Caso contrário, o usuário receberá um convite para cadastrar sua senha no e-mail informado.

Carregar Usuário pelo ID

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/users/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);
{
  "id": 2,
  "name": "User 2",
  "email": "email2@example.com.br",
  "additional_info": null,
  "ev_cash_terminal_id": "q7w8e9r4",
  "deleted_at": null,
  "addresses_attributes": [],
  "contacts_attributes": [],
  "user_group": {
    "id": 1,
    "name": "Administrador"
  },
  "clinic_ids": [
    1,
    2
  ],
  "clinics": [...],
  "confirmed_at": "2016-11-01T13:17:19.000Z",
  "permissions": [...]
}

Rota

GET /users/:id.json

Alterar Usuário

var data = JSON.stringify({
  "user": {
    "id": 2,
    "user_group_id": 1,
    "name": "User 2",
    "email": "email2@example.com.br"
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://ae2sc4.api.stage.dentaloffice.com.br/users/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

Rota

PUT /users/:id.json

Parâmetros

Nome Obrigatório Descrição
id sim Id do usuário
user sim Objeto com informações do usuário
user.id sim Id do Usuário
user.name sim Nome do Usuário
user.user_group_id sim Id do Grupo que o usuário pertence
user.email sim E-mail do usuário

Remover Usuário

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/users/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

Rota

DELETE /users/:id.json

Dentistas

Buscar Dentistas

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/dentists.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "total_pages": 1,
  "count": 2,
  "from": 1,
  "to": 2,
  "current_page": 1,
  "results": [
    {
      "id": 1,
      "name": "Dentista 1",
      "specialty_id": null,
      "duration": 30,
      "birth_date": null,
      "rg": null,
      "cpf": null,
      "cr_type": null,
      "cr_number": null,
      "cr_uf": null,
      "commission_type": 0,
      "commission_percent": "50.0",
      "commission_prosthetic": true,
      "commission_prosthetic_percent": "10.0",
      "semester": null,
      "register_number": null,
      "dentist_type": "dentist",
      "chair_ids": [1],
      "created_at": "2015-01-01T01:02:03.000Z",
      "updated_at": "2017-05-10T14:30:55.000Z",
      "deleted_at": null,
      "contacts_attributes": []
    },
    {
      "id": 2,
      "name": "Dra. Dentista 2",
      "specialty_id": null,
      "duration": 30,
      "birth_date": null,
      "rg": null,
      "cpf": null,
      "cr_type": null,
      "cr_number": null,
      "cr_uf": null,
      "commission_type": 0,
      "commission_percent": null,
      "commission_prosthetic": false,
      "commission_prosthetic_percent": null,
      "semester": null,
      "register_number": null,
      "dentist_type": "student",
      "chair_ids": [1],
      "created_at": "2017-03-07T03:14:59.000Z",
      "updated_at": "2017-03-07T03:14:59.000Z",
      "deleted_at": null,
      "contacts_attributes": []
    }
  ]
}

Rota

GET /dentists.json

Query Parameters

Parâmetro Valor Padrão Descrição
q Caracteres para pesquisa
page 1 Número da página

Cadastrar Dentistas

var data = JSON.stringify({
  "dentist": {
    "name": "Dentista 2",
    "duration": 30,
    "dentist_type": "student"
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://ae2sc4.api.stage.dentaloffice.com.br/dentists.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "id":1,
  "name":"Dentista 1",
  "specialty":{
    "id": 1,
    "name": "Cirurgia"
  },
  "duration":null,
  "birth_date":null,
  "rg":null,
  "cpf":null,
  "cr_type":null,
  "cr_number":null,
  "cr_uf":"",
  "dentist_type":"dentist",
  "record_number":"",
  "semester":"",
  "created_at":"2014-09-03T13:33:51.000Z",
  "updated_at":"2014-09-03T13:33:51.000Z",
  "addresses_attributes":[
    {
      "id":4,
      "address_type":null,
      "street":"Rua 5",
      "number":null,
      "complement":null,
      "neighborhood":null,
      "city":null,
      "state":null,
      "zipcode":null,
      "created_at":"2014-09-03T13:33:51.000Z",
      "updated_at":"2014-09-03T13:33:51.000Z"
    }
  ],
  "vacations_attributes":[],
  "work_schedules_attributes":[]
}

Rota

POST /dentists.json

Parâmetros

Nome Obrigatório Descrição
dentist sim Objeto com informações do Dentista
dentist.name sim Nome do Dentista
dentist.dentist_type sim Tipo de Dentista (dentist, student, teacher)
dentist.duration não Duração do Dentista
dentist.semester não Semestre
dentist.register_number não Número da Matrícula

Carregar Dentista pelo ID

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/dentists/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);
{
  "id":1,
  "name":"Dentista 1",
  "specialty":{
    "id": 1,
    "name": "Cirurgia"
  },
  "duration":null,
  "birth_date":null,
  "rg":null,
  "cpf":null,
  "cr_type":null,
  "cr_number":null,
  "cr_uf":"",
  "dentist_type":"dentist",
  "record_number":"",
  "semester":"",
  "created_at":"2014-09-03T13:33:51.000Z",
  "updated_at":"2014-09-03T13:33:51.000Z",
  "addresses_attributes":[
    {
      "id":4,
      "address_type":null,
      "street":"Rua 5",
      "number":null,
      "complement":null,
      "neighborhood":null,
      "city":null,
      "state":null,
      "zipcode":null,
      "created_at":"2014-09-03T13:33:51.000Z",
      "updated_at":"2014-09-03T13:33:51.000Z"
    }
  ],
  "vacations_attributes":[],
  "work_schedules_attributes":[]
}

Rota

GET /dentists/:id.json

Alterar Dentista

var data = JSON.stringify({
  "dentist": {
    "id": 2,
    "name": "Dentista 2",
    "duration": 30,
    "dentist_type": "student"
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://ae2sc4.api.stage.dentaloffice.com.br/dentists/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

Rota

PUT /dentists/:id.json

Parâmetros

Nome Obrigatório Descrição
id sim Id do Dentista
dentist sim Objeto com informações do Dentista
dentist.id sim Id do Dentista
dentist.name sim Nome do Dentista
dentist.dentist_type sim Tipo de Dentista (dentist, student, teacher)
dentist.duration não Duração do Dentista
dentist.semester não Semestre
dentist.register_number não Número da Matrícula

Remover Dentista

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/dentists/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

Rota

DELETE /dentists/:id.json

Clientes

Buscar Clientes

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/customers.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "total_pages": 1,
  "count": 1,
  "from": 1,
  "to": 1,
  "current_page": 1,
  "results": [
    {
      "id": "3",
      "name": "Andressa Ruiz",
      "client_key": "jp4vxkv",
      "email": "and.ruiz@email.com",
      "cpf": "99999999999",
      "record_number": "6",
      "cellphone": "9999999999",
      "created_at": "2016-11-03T16:43:36.000Z",
      "updated_at": "2017-03-14T19:41:14.000Z",
      "clinic_id": 1,
      "deleted": false,
      "photo_url": {
        "thumb": "https://bkp-newdow-sp-dev.s3.amazonaws.com/assets/images/logo-customer.png",
        "medium": "https://bkp-newdow-sp-dev.s3.amazonaws.com/assets/images/logo-customer.png",
        "original": "https://bkp-newdow-sp-dev.s3.amazonaws.com/assets/images/logo-customer.png"
      },
      "contacts_attributes": [
        {
          "email": "and.ruiz@email.com",
          "cellphone": "9999999999"
        }
      ]
    }
  ]
}

Rota

GET /customers.json

Query Parameters

Parâmetro Valor Padrão Descrição
q Caracteres para pesquisa
page 1 Número da página

Cadastrar Cliente

var data = JSON.stringify({
  "customer": {
    "name": "Marcos Junior",
    "record_date": "2016-01-05",
    "record_number": 5
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://ae2sc4.api.stage.dentaloffice.com.br/customers.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "id": 1,
  "title": null,
  "name": "Tabata Schnoeller",
  "photo": "",
  "record_number": "a",
  "customer_group_id": 1,
  "customer_situation_id": 1,
  "record_date": "2016-01-05",
  "gender": null,
  "dental_arcade": "P",
  "birth_date": "1989-09-18",
  "birth_place": "São Paulo",
  "marital_status": 1,
  "dentist_id": 1,
  "document_id": 1,
  "is_holder": true,
  "holder_id": null,
  "company_id": null,
  "department": null,
  "profession_id": null,
  "father_name": null,
  "father_profession_id": null,
  "mother_name": null,
  "mother_profession_id": null,
  "is_sponsor": false,
  "sponsor_id": 6,
  "indicator_id": null,
  "indicator_type": null,
  "payment_credit": "1113.49",
  "created_at": "2016-11-01T13:44:02.000Z",
  "updated_at": "2017-12-20T23:37:08.000Z",
  "deleted_at": null,
  "father_rg": null,
  "father_cpf": null,
  "father_phone": null,
  "mother_rg": null,
  "mother_cpf": null,
  "mother_phone": null,
  "addresses_attributes": [
    {
      "id": 1,
      "address_type": null,
      "street": "Rua Antônio Fogal",
      "number": 123,
      "complement": "Apto 703 - Bloco 5",
      "neighborhood": "Jardim Umuarama",
      "city": "São Paulo",
      "state": "SP",
      "zipcode": "04650160",
      "created_at": "2016-11-01T13:44:02.000Z",
      "updated_at": "2016-11-14T12:15:23.000Z"
    }
  ],
  "contacts_attributes": [
    {
      "id": 1,
      "contact_type": null,
      "name": null,
      "email": "tabata@tabataruiz.com.br",
      "phone": "(11) 5698-7478",
      "cellphone": "(11) 98562-1456",
      "fax": "(11) 5236-5478",
      "homepage": null,
      "message_phone": "(11) 5632-5896",
      "message_contact": "Marcos Junior",
      "created_at": "2016-11-01T13:44:02.000Z",
      "updated_at": "2016-11-14T12:15:23.000Z"
    }
  ],
  "photo_url": {
    "thumb": "http://dentalclouddev.s3.amazonaws.com/customers/jp4vxkv/1/thumb/data?1479127620",
    "medium": "http://dentalclouddev.s3.amazonaws.com/customers/jp4vxkv/1/medium/data?1479127620",
    "original": "http://dentalclouddev.s3.amazonaws.com/customers/jp4vxkv/1/original/data?1479127620"
  },
  "document_attributes": {
    "id": 1,
    "cpf": "10349378045",
    "rg": "45.368.695-3",
    "emitter": "SSP",
    "dental_insurance_id": 1,
    "plan_id": 1,
    "card_number": "452136589",
    "card_validate": "2017-03-14",
    "cns_number": 123456,
    "accession_date": "2017-03-14",
    "dental_insurance": {
        "id": 1,
        "name": "Particular",
        "deleted_at": null
    },
    "plan": {
        "id": 1,
        "name": "Plano 1",
        "deleted_at": null
    }
  },
  "sponsor_attributes": {
    "id": 6,
    "title": null,
    "name": "Marco Schnoeller",
    "record_number": "12",
    "customer_group_id": 1,
    "customer_situation_id": null,
    "record_date": "2017-01-13",
    "gender": null,
    "dental_arcade": null,
    "birth_date": "1980-10-01",
    "birth_place": null,
    "marital_status": null,
    "dentist_id": null,
    "document_id": 4,
    "is_holder": true,
    "holder_id": null,
    "company_id": null,
    "department": null,
    "profession_id": null,
    "father_name": null,
    "father_profession_id": null,
    "mother_name": null,
    "mother_profession_id": null,
    "is_sponsor": true,
    "sponsor_id": null,
    "indicator_id": null,
    "indicator_type": null,
    "created_at": "2017-01-13T01:31:42.000Z",
    "updated_at": "2017-11-07T13:56:53.000Z",
    "deleted_at": null
  },
  "dentist": {
    "id": 1,
    "name": "Dentista 1",
    "specialty_id": null,
    "duration": 30,
    "birth_date": null,
    "rg": null,
    "cpf": null,
    "cr_type": null,
    "cr_number": null,
    "cr_uf": null,
    "commission_type": 0,
    "commission_percent": "50.12",
    "commission_prosthetic": true,
    "commission_prosthetic_percent": "10.13",
    "semester": null,
    "register_number": null,
    "dentist_type": "dentist",
    "chair_ids": [],
    "created_at": "2015-01-01T01:02:03.000Z",
    "updated_at": "2017-06-21T13:18:48.000Z",
    "deleted_at": null
  },
  "customer_group": {
    "id": 1,
    "name": "Definitivo",
    "deleted_at": null
  },
  "customer_situation": {
    "id": 1,
    "name": "1ª Consulta"
  },
  "specialty_ids": [
    8
  ],
  "specialties": [
    {
      "id": 8,
      "name": "Odontologia"
    }
  ],
  "have_alerts": true
}

Rota

POST /customers.json

Parâmetros

Nome Obrigatório Descrição
customer sim Objeto com informações do Cliente
customer.title não Identificacao ( Sr., Sra., Dr., Dra., Srta. )
customer.name sim Nome do Cliente
customer.record_number não Número de cadastro
customer.record_date não Data de Cadastro
customer.photo não Foto do cliente (imagem convertida em base64)
customer.gender não Sexo (M/F)
customer.birth_date não Sexo (M/F)
customer.birth_place não Sexo (M/F)
customer.marital_status não Sexo (M/F)
customer.dentist_id não Sexo (M/F)
customer.addresses_attributes[] não Array com a entidade Endereço com o endereço do cliente
customer.contacts_attributes[] não Array com a entidade Contato com o contato do cliente
customer.document_attributes não Entidade Documento com os documentos do cliente

Carregar Cliente pelo ID

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/customers/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);
{
  "id": 1,
  "title": null,
  "name": "Tabata Schnoeller",
  "photo": "",
  "record_number": "a",
  "customer_group_id": 1,
  "customer_situation_id": 1,
  "record_date": "2016-01-05",
  "gender": null,
  "dental_arcade": "P",
  "birth_date": "1989-09-18",
  "birth_place": "São Paulo",
  "marital_status": 1,
  "dentist_id": 1,
  "document_id": 1,
  "is_holder": true,
  "holder_id": null,
  "company_id": null,
  "department": null,
  "profession_id": null,
  "father_name": null,
  "father_profession_id": null,
  "mother_name": null,
  "mother_profession_id": null,
  "is_sponsor": false,
  "sponsor_id": 6,
  "indicator_id": null,
  "indicator_type": null,
  "payment_credit": "1113.49",
  "created_at": "2016-11-01T13:44:02.000Z",
  "updated_at": "2017-12-20T23:37:08.000Z",
  "deleted_at": null,
  "father_rg": null,
  "father_cpf": null,
  "father_phone": null,
  "mother_rg": null,
  "mother_cpf": null,
  "mother_phone": null,
  "addresses_attributes": [
    {
      "id": 1,
      "address_type": null,
      "street": "Rua Antônio Fogal",
      "number": 123,
      "complement": "Apto 703 - Bloco 5",
      "neighborhood": "Jardim Umuarama",
      "city": "São Paulo",
      "state": "SP",
      "zipcode": "04650160",
      "created_at": "2016-11-01T13:44:02.000Z",
      "updated_at": "2016-11-14T12:15:23.000Z"
    }
  ],
  "contacts_attributes": [
    {
      "id": 1,
      "contact_type": null,
      "name": null,
      "email": "tabata@tabataruiz.com.br",
      "phone": "(11) 5698-7478",
      "cellphone": "(11) 98562-1456",
      "fax": "(11) 5236-5478",
      "homepage": null,
      "message_phone": "(11) 5632-5896",
      "message_contact": "Marcos Junior",
      "created_at": "2016-11-01T13:44:02.000Z",
      "updated_at": "2016-11-14T12:15:23.000Z"
    }
  ],
  "photo_url": {
    "thumb": "http://dentalclouddev.s3.amazonaws.com/customers/jp4vxkv/1/thumb/data?1479127620",
    "medium": "http://dentalclouddev.s3.amazonaws.com/customers/jp4vxkv/1/medium/data?1479127620",
    "original": "http://dentalclouddev.s3.amazonaws.com/customers/jp4vxkv/1/original/data?1479127620"
  },
  "document_attributes": {
    "id": 1,
    "cpf": "10349378045",
    "rg": "45.368.695-3",
    "emitter": "SSP",
    "dental_insurance_id": 1,
    "plan_id": 1,
    "card_number": "452136589",
    "card_validate": "2017-03-14",
    "cns_number": 123456,
    "accession_date": "2017-03-14",
    "dental_insurance": {
        "id": 1,
        "name": "Particular",
        "deleted_at": null
    },
    "plan": {
        "id": 1,
        "name": "Plano 1",
        "deleted_at": null
    }
  },
  "sponsor_attributes": {
    "id": 6,
    "title": null,
    "name": "Marco Schnoeller",
    "record_number": "12",
    "customer_group_id": 1,
    "customer_situation_id": null,
    "record_date": "2017-01-13",
    "gender": null,
    "dental_arcade": null,
    "birth_date": "1980-10-01",
    "birth_place": null,
    "marital_status": null,
    "dentist_id": null,
    "document_id": 4,
    "is_holder": true,
    "holder_id": null,
    "company_id": null,
    "department": null,
    "profession_id": null,
    "father_name": null,
    "father_profession_id": null,
    "mother_name": null,
    "mother_profession_id": null,
    "is_sponsor": true,
    "sponsor_id": null,
    "indicator_id": null,
    "indicator_type": null,
    "created_at": "2017-01-13T01:31:42.000Z",
    "updated_at": "2017-11-07T13:56:53.000Z",
    "deleted_at": null
  },
  "dentist": {
    "id": 1,
    "name": "Dentista 1",
    "specialty_id": null,
    "duration": 30,
    "birth_date": null,
    "rg": null,
    "cpf": null,
    "cr_type": null,
    "cr_number": null,
    "cr_uf": null,
    "commission_type": 0,
    "commission_percent": "50.12",
    "commission_prosthetic": true,
    "commission_prosthetic_percent": "10.13",
    "semester": null,
    "register_number": null,
    "dentist_type": "dentist",
    "chair_ids": [],
    "created_at": "2015-01-01T01:02:03.000Z",
    "updated_at": "2017-06-21T13:18:48.000Z",
    "deleted_at": null
  },
  "customer_group": {
    "id": 1,
    "name": "Definitivo",
    "deleted_at": null
  },
  "customer_situation": {
    "id": 1,
    "name": "1ª Consulta"
  },
  "specialty_ids": [
    8
  ],
  "specialties": [
    {
      "id": 8,
      "name": "Odontologia"
    }
  ],
  "have_alerts": true
}

Rota

GET /customers/:id.json

Alterar Cliente

var data = JSON.stringify({
  "customer": {
    "name": "Marcos Antonio Junior"
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://ae2sc4.api.stage.dentaloffice.com.br/customers/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

Rota

PUT /customers/:id.json

Parâmetros

Nome Obrigatório Descrição
id sim Id do Cliente
customer sim Objeto com informações do Cliente
customer.title não Identificacao ( Sr., Sra., Dr., Dra., Srta. )
customer.name sim Nome do Cliente
customer.record_number não Número de cadastro
customer.record_date não Data de Cadastro
customer.photo não Foto do cliente (imagem convertida em base64)
customer.gender não Sexo (M/F)
customer.birth_date não Sexo (M/F)
customer.birth_place não Sexo (M/F)
customer.marital_status não Sexo (M/F)
customer.dentist_id não Sexo (M/F)
customer.addresses_attributes[] não Array com a entidade Endereço com o endereço do cliente
customer.contacts_attributes[] não Array com a entidade Contato com o contato do cliente
customer.document_attributes não Entidade Documento com os documentos do cliente

Remover Cliente

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/customers/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

Rota

DELETE /customers/:id.json

Agenda

Carregar Agendamentos

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/clinics/1/schedules.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "current_page": 1,
  "total_pages": 1,
  "count": 40,
  "results": [
    {
      "_index": "dental_schedule_20170627154150786",
      "_type": "schedules_jp4vxkv",
      "_id": "1",
      "_score": null,
      "sort": [
        1478174400000
      ],
      "client_key": "jp4vxkv",
      "real_id": 1,
      "title": "Tabata Schnoeller",
      "start": "2016-11-03T12:00:00.000Z",
      "end": "2016-11-03T12:30:00.000Z",
      "sms_confirmation": null,
      "record_number": "a",
      "deleted": false,
      "schedule_start": "2016-11-03T12:00:00.000Z",
      "schedule_end": "2016-11-03T12:30:00.000Z",
      "clinic_id": 1,
      "duration": 30,
      "notes": null,
      "textColor": "#ffffff",
      "borderColor": "#773951",
      "backgroundColor": "#c86088",
      "dentist": {
        "id": 1,
        "name": "Dentista 1"
      },
      "chair": {
        "id": 1,
        "name": "Cadeira Principal"
      },
      "schedule_situation": {
        "id": 1,
        "name": "Confirmar"
      },
      "className": "to_confirm",
      "schedule_type": {
        "id": 1,
        "name": "Consulta"
      },
      "customer": {
        "id": 1,
        "record_number": "1",
        "name": "Tabata Schnoeller",
        "contacts_attributes": [
          {
            "cellphone": "(11) 98765-4321",
            "email": "tabata@email.com.br"
          }
        ]
      },
      "id": "1"
    }
  ]
}

Rota

GET /clinics/:clinic_id/schedules.json

Query Parameters

Parâmetro Valor Padrão Descrição
q Caracteres para pesquisa
page 1 Número da página
clinic_id Id da Clínica
chair_id Id da Cadeira
dentist_id Id do Dentista
start Período Inicial
end Período Final
web 1 = Retorna os dados tratados para o sistema WEB, 0 = Retorna os dados tratados pra mobile.
calendar 1 = Retorna os dados sem paginação, preparados para o calendário web. 0 = Retorna os dados paginados, tratados para o formato lista.

Cadastrar Agendamentos

var data = JSON.stringify({
  "schedule": {
    "chair_id": 1,
    "dentist_id": 1,
    "customer_id": 1,
    "schedule_start": "2017-12-30 12:00:00",
    "duration": 30,
    "integration_attributes": {
      "name": "Parceiro X",
      "color": "#ff0000"
    }
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://ae2sc4.api.stage.dentaloffice.com.br/clinics/1/schedules.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "id": 1,
  "clinic_id": 1,
  "chair_id": 1,
  "dentist_id": 1,
  "customer_id": 1,
  "description": null,
  "schedule_start": "2017-12-30T12:00:00.000Z",
  "schedule_end": "2017-12-30T12:30:00.000Z",
  "phone": null,
  "cellphone": null,
  "email": null,
  "duration": 30,
  "periodic": null,
  "notes": null,
  "schedule_type_id": 1,
  "schedule_reason_id": null,
  "schedule_situation_id": 1,
  "marketing_action_id": null,
  "arrived_at": null,
  "served_at": null,
  "deleted_at": null,
  "created_at": "2017-12-20T23:37:08.937Z",
  "updated_at": "2017-12-20T23:37:08.937Z",
  "sms_confirmation": null,
  "personal": false
}

Rota

POST /clinics/:clinic_id/schedules.json

Parâmetros

Nome Obrigatório Descrição
schedule sim Objeto com informações do usuário
schedule.chair_id sim Id da Cadeira
schedule.dentist_id sim Id do Dentista
schedule.customer_id não Id do Paciente
schedule.personal não Compromisso Pessoal - True/False
schedule.description não Descrição do Compromisso
schedule.schedule_start sim Data/Hora de Início
schedule.phone não Telefone
schedule.cellphone não Celular
schedule.email sim E-mail
schedule.duration sim Duração da Consulta
schedule.notes não Anotações
schedule.schedule_type_id não Id do Tipo de Agendamento
schedule.schedule_reason_id não Id do Motivo de Agendamento
schedule.schedule_situation_id não Id da Situação do Agendamento
schedule.integration_attributes não Configurações da Integração

Carregar Agendamento pelo ID

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/clinics/1/schedules/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);
{
  "id": 1,
  "clinic_id": 1,
  "chair_id": 1,
  "dentist_id": 1,
  "customer_id": 1,
  "description": "Tabata Schnoeller",
  "schedule_start": "2016-11-03T12:00:00.000Z",
  "schedule_end": "2016-11-03T12:30:00.000Z",
  "phone": null,
  "cellphone": null,
  "email": null,
  "duration": 30,
  "periodic": null,
  "notes": null,
  "schedule_type_id": 1,
  "schedule_reason_id": null,
  "schedule_situation_id": 1,
  "marketing_action_id": null,
  "arrived_at": null,
  "served_at": null,
  "sms_confirmation": null,
  "personal": false,
  "customer": {
    "id": 1,
    "title": null,
    "name": "Tabata Schnoeller",
    "photo": "http://dentalclouddev.s3.amazonaws.com/customers/ae2sc4/1/original/data?1479127620",
    "record_number": "a",
    "customer_group_id": 1,
    "customer_situation_id": 1,
    "record_date": "2016-01-05",
    "gender": null,
    "dental_arcade": "P",
    "birth_date": "1989-09-18",
    "birth_place": "São Paulo",
    "marital_status": 1,
    "dentist_id": 1,
    "document_id": 1,
    "is_holder": true,
    "holder_id": null,
    "company_id": null,
    "department": null,
    "profession_id": null,
    "father_name": null,
    "father_profession_id": null,
    "mother_name": null,
    "mother_profession_id": null,
    "is_sponsor": false,
    "sponsor_id": 6,
    "indicator_id": null,
    "indicator_type": null,
    "payment_credit": "1113.49",
    "created_at": "2016-11-01T13:44:02.000Z",
    "updated_at": "2017-11-07T13:56:53.000Z",
    "deleted_at": null,
    "father_rg": null,
    "father_cpf": null,
    "father_phone": null,
    "mother_rg": null,
    "mother_cpf": null,
    "mother_phone": null,
    "contacts_attributes": [
      {
          "id": 1,
          "contact_type": null,
          "name": null,
          "email": "tabata@tabataruiz.com.br",
          "phone": "(11) 9876-5432",
          "cellphone": "(11) 98765-4321",
          "fax": "(11) 1234-5678",
          "homepage": null,
          "message_phone": "(11) 1234-5678",
          "message_contact": "Marcos Junior",
          "created_at": "2016-11-01T13:44:02.000Z",
          "updated_at": "2016-11-14T12:15:23.000Z"
      }
    ]
  },
  "dentist": {
    "id": 1,
    "name": "Dentista 1",
    "specialty_id": null,
    "duration": 30,
    "birth_date": null,
    "rg": null,
    "cpf": null,
    "cr_type": null,
    "cr_number": null,
    "cr_uf": null,
    "commission_type": 0,
    "commission_percent": "50.12",
    "commission_prosthetic": true,
    "commission_prosthetic_percent": "10.13",
    "semester": null,
    "register_number": null,
    "dentist_type": "dentist",
    "chair_ids": [],
    "created_at": "2015-01-01T01:02:03.000Z",
    "updated_at": "2017-06-21T13:18:48.000Z",
    "deleted_at": null
  },
  "chair": {
    "id": 1,
    "name": "Cadeira Principal",
    "created_at": "2015-01-01T01:02:03.000Z",
    "updated_at": "2015-01-01T01:02:03.000Z",
    "deleted_at": null
  },
  "schedule_situation": {
    "id": 1,
    "name": "Confirmar",
    "color": "#c86088",
    "font_color": "#ffffff",
    "label": "to_confirm"
  },
  "schedule_type": {
    "id": 1,
    "name": "Consulta",
    "color": null,
    "font_color": null
  }
}

Rota

GET /clinics/:clinic_id/schedules/:id.json

Alterar Agendamento

var data = JSON.stringify({
  "schedule": {
    "chair_id": 1,
    "dentist_id": 1,
    "schedule_start": "2017-04-30 12:00:00",
    "duration": 30,
    "personal": true,
    "description": "teste de agendamento"
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://ae2sc4.api.stage.dentaloffice.com.br/clinics/1/schedules/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

Rota

PUT /clinics/:clinic_id/schedules/:id.json

Parâmetros

Nome Obrigatório Descrição
id sim Id do Agendamento
schedule sim Objeto com informações do usuário
schedule.chair_id sim Id da Cadeira
schedule.dentist_id sim Id do Dentista
schedule.customer_id não Id do Paciente
schedule.personal não Compromisso Pessoal - True/False
schedule.description não Descrição do Compromisso
schedule.schedule_start sim Data/Hora de Início
schedule.phone não Telefone
schedule.cellphone não Celular
schedule.email sim E-mail
schedule.duration sim Duração da Consulta
schedule.notes não Anotações
schedule.schedule_type_id não Id do Tipo de Agendamento
schedule.schedule_reason_id não Id do Motivo de Agendamento
schedule.schedule_situation_id não Id da Situação do Agendamento

Remover Agendamento

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/clinics/1/schedules/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

Rota

DELETE /clinics/:clinic_id/schedules/:id.json

Horários Disponíveis no dia

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/clinics/1/schedules/available_hours.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "date": "2018-06-18",
  "periods": [
    {
        "start_time": "2018-06-18T08:00:00.000Z",
        "end_time": "2018-06-18T08:30:00.000Z"
    },
    {
        "start_time": "2018-06-18T08:30:00.000Z",
        "end_time": "2018-06-18T09:00:00.000Z"
    },
    {
        "start_time": "2018-06-18T09:00:00.000Z",
        "end_time": "2018-06-18T09:30:00.000Z"
    },
    {
        "start_time": "2018-06-18T09:30:00.000Z",
        "end_time": "2018-06-18T10:00:00.000Z"
    },
    {
        "start_time": "2018-06-18T10:00:00.000Z",
        "end_time": "2018-06-18T10:30:00.000Z"
    },
    {
        "start_time": "2018-06-18T10:30:00.000Z",
        "end_time": "2018-06-18T11:00:00.000Z"
    },
    {
        "start_time": "2018-06-18T11:00:00.000Z",
        "end_time": "2018-06-18T11:30:00.000Z"
    },
    {
        "start_time": "2018-06-18T12:00:00.000Z",
        "end_time": "2018-06-18T12:30:00.000Z"
    },
    {
        "start_time": "2018-06-18T14:00:00.000Z",
        "end_time": "2018-06-18T14:30:00.000Z"
    },
    {
        "start_time": "2018-06-18T14:30:00.000Z",
        "end_time": "2018-06-18T15:00:00.000Z"
    },
    {
        "start_time": "2018-06-18T15:00:00.000Z",
        "end_time": "2018-06-18T15:30:00.000Z"
    },
    {
        "start_time": "2018-06-18T15:30:00.000Z",
        "end_time": "2018-06-18T16:00:00.000Z"
    },
    {
        "start_time": "2018-06-18T16:00:00.000Z",
        "end_time": "2018-06-18T16:30:00.000Z"
    },
    {
        "start_time": "2018-06-18T16:30:00.000Z",
        "end_time": "2018-06-18T17:00:00.000Z"
    },
    {
        "start_time": "2018-06-18T17:00:00.000Z",
        "end_time": "2018-06-18T17:30:00.000Z"
    },
    {
        "start_time": "2018-06-18T17:30:00.000Z",
        "end_time": "2018-06-18T18:00:00.000Z"
    },
    {
        "start_time": "2018-06-18T18:00:00.000Z",
        "end_time": "2018-06-18T18:30:00.000Z"
    }
  ]
}

Rota

GET /clinics/:clinic_id/schedules/available_hours.json

Query Parameters

Parâmetro Valor Padrão Descrição
date Dia atual Data para pesquisa
dentist_id Id do Dentista

Imagens

Carregar Imagens

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/customers/1/images.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
"total_pages": 1,
"count": 1,
"from": 1,
"to": 1,
"current_page": 1,
"results" : [
    {
    "id": 2,
    "customer_id": 1,
    "name": "teste de imagem",
    "description": "",
    "file": "",
    "file_url": {
        "original": "",
        "medium": "",
        "thumb": ""
    }
    }
]
}

Rota

GET /customers/:customer_id/images.json

Query Parameters

Parâmetro Valor Padrão Descrição
q Caracteres para pesquisa
page 1 Número da página

Cadastrar Imagens

var data = JSON.stringify({
  "customer_image": {
    "description": "Descrição da imagem",
    "file": "data:image/png;base64,iVBORwOKGgoAAAA.......",
    "name": "Teste de Imagem",
    "tag_list": "radiografia"
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://ae2sc4.api.stage.dentaloffice.com.br/customers/1/images.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{
  "id": 4,
  "customer_id": 2,
  "name": "Captura de Tela 2017-10-05 às 09.14.56.png",
  "description": "Teste de Imagem",
  "file_file_name": "data",
  "file_content_type": "image/png",
  "file_file_size": 326564,
  "file_updated_at": "2018-10-05T19:33:09.961Z",
  "deleted_at": null,
  "created_at": "2018-10-05T19:33:10.721Z",
  "updated_at": "2018-10-05T19:33:10.721Z"
}

Rota

POST /customers/:customer_id/images.json

Parâmetros

Nome Obrigatório Descrição
customer_id sim Id do Paciente
customer_image sim Objeto com informações da imagem
customer_image.name sim Título da Imagem
customer_image.file sim String em Base64 da Imagem, deve ser em formato url encoded, com o content type, vide exemplo.
customer_image.description não Descrição da Imagem
customer_image.tag_list não Tags para identificar a imamge. Caso seja mais do que uma, separar por virgula

Carregar Imagem pelo ID

var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://ae2sc4.api.stage.dentaloffice.com.br/customers/1/images/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);
{
  "id": 4,
  "customer_id": 2,
  "name": "Captura de Tela 2017-10-05 às 09.14.56.png",
  "description": "Teste de Imagem",
  "tag_list": [
    "radiografia"
  ],
  "file": "http://dentalcloudprod.s3.amazonaws.com/resources/xxxxxxx/customers/2/images/4/original/data?1538767989",
  "deleted_at": null,
  "created_at": "2018-10-05T19:33:10.000Z",
  "updated_at": "2018-10-05T19:33:10.000Z",
  "file_url": {
    "original": "http://dentalcloudprod.s3.amazonaws.com/resources/xxxxxxx/customers/2/images/4/original/data?1538767989",
    "medium": "http://dentalcloudprod.s3.amazonaws.com/resources/xxxxxxx/customers/2/images/4/medium/data?1538767989",
    "thumb": "http://dentalcloudprod.s3.amazonaws.com/resources/xxxxxxx/customers/2/images/4/thumb/data?1538767989",
    "full": "http://dentalcloudprod.s3.amazonaws.com/resources/xxxxxxx/customers/2/images/4/full/data?1538767989"
  }
}

Rota

GET /customers/:customer_id/images/:id.json

Alterar Imagem

var data = JSON.stringify({
  "customer_image": {
    "id": 2,
    "description": "Descrição da imagem",
    "file": "data:image/png;base64,iVBORwOKGgoAAAA.......",
    "name": "Teste de Imagem",
    "tag_list": "radiografia"
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://ae2sc4.api.stage.dentaloffice.com.br/customers/1/images/2.json");
xhr.setRequestHeader("X-User-Token", "MN-ubYyfM8U8B3fZUeng");
xhr.setRequestHeader("X-User-Email", "email@example.com.br");
xhr.setRequestHeader("X-Device-Register", "asdasdads");

xhr.send(data);

Rota

PUT /customers/:customer_id/images/:id.json

Parâmetros

Nome Obrigatório Descrição
id sim Id da Imagem
customer_id sim Id do Paciente
customer_image sim Objeto com informações da imagem
customer_image.name sim Título da Imagem
customer_image.file sim String em Base64 da Imagem, deve ser em formato url encoded, com o content type, vide exemplo.
customer_image.description não Descrição da Imagem
customer_image.tag_list não Tags para identificar a imamge. Caso seja mais do que uma, separar por virgula

Remover Imagem

Rota

DELETE /customers/:customer_id/images/:id.json

Tabelas

Grupos de Usuário

Id Nome
1 Administrador
2 Atendente
3 Cirurgiao Dentista
4 Recepcionista
5 Secretaria
6 Gerente Financeiro
7 Gerente Geral
8 Aluno
9 Professor

Entidades

Address

Nome Obrigatório Descrição
id não Id do endereço
street não Endereço
number não Número
complement não Complemento
neighborhood não Bairro
city não Cidade
state não Estado
zipcode não Cep

Contact

Nome Obrigatório Descrição
id não Id do endereço
email não E-mail
phone não Telefone
cellphone não Celular
fax não Fax
homepage não Home Page
message_contact não Contato para Recado
message_phone não Telefone pra Recado

Document

Nome Obrigatório Descrição
id não Id do documento
cpf não CPF
rg não RG
emitter não Emissão
dental_insurance_id não Id do Convênio
plan_id não Id do Plano
card_number não Número da Carteirinha
card_validate não Validade da Carteirinha

Integration

Nome Obrigatório Descrição
name sim Nome do parceiro
color sim Cor do Agendamento em Hexadecimal

SSO

Introdução

O módulo SSO é uma forma de permitir que o usuário possa acessar o Dental Office através de um outro sistema, sem a necessidade de realizar o login no Dental Office.

O software que realizará a integração irá precisar de uma chave específica para esta funcionalidade. Esta chave deve ser solicitada ao desenvolvimento.

Com a chave em mãos, algumas etapas devem ser seguidas:

1 - Solicitar um token de acesso.

2 - Criar um formulário com botão pra login.

Usando a chave Integration Token e Secret Access, é necessário chamar uma rota usando autênticação básica http, passando o e-mail do usuário que irá fazer o login. Esta rota irá retornar um Access Token, que deverá ser usado na rota seguinte.

Solicitar token para sso

var data = JSON.stringify({
  "email": "aluno3@escola.com.br"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://no.api.stage.dentaloffice.com.br/users/access_token");
xhr.setRequestHeader("authorization", "Basic ZUNzZTZ3Y3ZqeGd5SFUyeGs1aWM6UVFKd3JxZk5IZGxkczRpSy9DV1hreU44Z3YvNkI0NHBWVnFROVRuLzd5OD0=");

xhr.send(data);

O Retorno será um JSON aproximadamente igual a esse:

{"id":7,"name":"Aluno 3","email":"aluno3@escola.com.br","client_key":"eoz8w3j","access_token":"XVUsE8TMD6QpJDxABjR8IzxUV4dOv5_jBntMwzrr3xYl6Rb8czMc-FGoENSSEV-R"}

Rota

POST /users/access_token

Parâmetros

Nome Obrigatório Descrição
email sim E-mail do usuário

Formulário de Acesso

<form action="http://no.api.stage.dentaloffice.com.br/auth/access" method="POST" target="_blank">
  <input name="integration_token" type="hidden" />
  <input name="access_token" type="hidden" />
  <button type="submit">Acessar Dental Office</button>
</form>

Após solicitado o token de acesso, é necessário criar um formulário html que fará uma requisição post para o endpoint /auth/access enviando o Integration Token e o Access Token do usuário. Esta rota irá se responsabilizar por fazer a autenticação do usuário e direciona-lo ao Dental Office.