Digital Trust Index

Última atualização: 12 de maio de 2020
Requisição
POST https://api.clearsale.com.br/v1/digitaltrust/score HTTP/1.1
Content-Type:application/json
Accept:application/json
Authorization: Bearer {Token}
{
    "Document": "{cpf}",
    "BirthDate": "{Data de Nascimento}", // opcional
    "ReferenceDate": "{Data de referência para geração do score}" // opcional
}
// Execute "Install-Package Microsoft.Net.Http" na linha de comando do nuget.
using System;
using System.Net.Http;

string yourToken = "9f38f5a476d644bfadd8a8803b51fe59"; // Use a autenticação para gerar um token
var baseAddress = new Uri("https://api.clearsale.com.br/v1/");

using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
    httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
    httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
    httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", String.Format("Bearer {0}", yourToken));

    using (var content = new StringContent("{ \"Document\": \"12345678912\", \"BirthDate\": \"1990-12-31\", \"ReferenceDate\": \"2016-12-31\" }"))
    {
        using (var response = await httpClient.PostAsync("digitaltrust/score", content))
        {
            string responseData = await response.Content.ReadAsStringAsync();
        }
    }
}
package main

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    yourToken := "9f38f5a476d644bfadd8a8803b51fe59" // Use a autenticação para gerar um token
    client := &http.Client{}
    body := []byte("{ \"Document\": \"12345678912\", \"BirthDate\": \"1990-12-31\", \"ReferenceDate\": \"2016-12-31\" }")
    req, _ := http.NewRequest("POST", "https://api.clearsale.com.br/v1/digitaltrust/score", bytes.NewBuffer(body))
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Accept", "application/json")
    req.Header.Add("Authorization", "Bearer" + yourToken)
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Errored when sending request to the server")
        return
    }
    defer resp.Body.Close()
    resp_body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(resp.Status)
    fmt.Println(string(resp_body))
}
from urllib2 import Request, urlopen

yourToken = "9f38f5a476d644bfadd8a8803b51fe59" // Use a autenticação para gerar um token

values = """
    {
        "Document": "12345678912",
        "BirthDate": "1990-12-31",
        "ReferenceDate": "2016-12-31"
    }
"""

headers = {
    'Content-Type': 'application/json'
    'Accept': 'application/json'
    'Authorization': 'Bearer ' + yourToken
}

request = Request('https://api.clearsale.com.br/v1/digitaltrust/score', data=values, headers=headers)
response_body = urlopen(request).read()

print response_body
POST https://homologacao.clearsale.com.br/api/v1/digitaltrust/score HTTP/1.1
Content-Type:application/json
Accept:application/json
Authorization: Bearer {Token}
{
    "Document": "{cpf}",
    "BirthDate": "{Data de Nascimento}", // opcional
    "ReferenceDate": "{Data de referência para geração do score}" // opcional
}
// Execute "Install-Package Microsoft.Net.Http" na linha de comando do nuget.
using System;
using System.Net.Http;

string yourToken = "9f38f5a476d644bfadd8a8803b51fe59"; // Use a autenticação para gerar um token
var baseAddress = new Uri("https://homologacao.clearsale.com.br/api/v1/");

using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
    httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
    httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
    httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", String.Format("Bearer {0}", yourToken));

    using (var content = new StringContent("{ \"Document\": \"12345678912\", \"BirthDate\": \"1990-12-31\", \"ReferenceDate\": \"2016-12-31\" }"))
    {
        using (var response = await httpClient.PostAsync("digitaltrust/score", content))
        {
            string responseData = await response.Content.ReadAsStringAsync();
        }
    }
}
package main

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    yourToken := "9f38f5a476d644bfadd8a8803b51fe59" // Use a autenticação para gerar um token
    client := &http.Client{}
    body := []byte("{ \"Document\": \"12345678912\", \"BirthDate\": \"1990-12-31\", \"ReferenceDate\": \"2016-12-31\" }")
    req, _ := http.NewRequest("POST", "https://homologacao.clearsale.com.br/api/v1/digitaltrust/score", bytes.NewBuffer(body))
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Accept", "application/json")
    req.Header.Add("Authorization", "Bearer" + yourToken)
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Errored when sending request to the server")
        return
    }
    defer resp.Body.Close()
    resp_body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(resp.Status)
    fmt.Println(string(resp_body))
}
from urllib2 import Request, urlopen
yourToken = "9f38f5a476d644bfadd8a8803b51fe59" // Use a autenticação para gerar um token

values = """
    {
        "Document": "12345678912",
        "BirthDate": "1990-12-31",
        "ReferenceDate": "2016-12-31"
    }
"""

headers = {
    'Content-Type': 'application/json'
    'Accept': 'application/json'
    'Authorization': 'Bearer ' + yourToken
}

request = Request('https://homologacao.clearsale.com.br/api/v1/digitaltrust/score', data=values, headers=headers)
response_body = urlopen(request).read()

print response_body
Resposta
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
    "ID" = 0,
    "Document" = "{cpf}",
    "BirthDate" = "{Data de Nascimento}",
    "Score" = 0-1000,
    "Date" = "Data de geração do score",
    "ReferenceDate": "{Data de referência para geração do score}", // Caso não seja enviado na requisição iremos retornar a data atual
    "Digital": true | false
}