API - POS CONTROLE

Autenticação e troca de informações

/salesDay?dateini={dateini}&dateend={dateend} - GET

O endpoint retorna o valor das vendas no período por Grupo e Produto, de determinada loja do cliente dentro do período solicitado.

Para acessar a API é necessário enviar um token JWT válido no cabeçalho 'Authorization' em todas as solicitações. Para gerar um token JWT válido é necessário requisitar o endpoint /auth/token utilizando um nome de usuário e senha. A sintaxe abaixo deve ser utilizada no cabeçalho 'Authorization': Bearer xxxxxx.yyyyyyy.zzzzzz

Teste agora!

Solicitar URL

Parâmetros de solicitação

string

Format - date (Exemplo: 2012-03-31). Data do início do período.

string

Format - date (Exemplo: 2012-03-31). Data do final do período.

Cabeçalhos de solicitação

string

'Authorization': Bearer xxxxxx.yyyyyyy.zzzzzz

string
Chave de assinatura que fornece acesso a esta API. Encontre-a em seu Perfil.

Corpo da solicitação

Resposta 200

Um array com as vendas.

[
  {
    "Sale": {
      "SaleID": "string",
      "USersID": "string",
      "DatetimeSale": "string",
      "SaleStatus": "string",
      "SalePosCodeID": "string",
      "CpfCnpj": "string",
      "numnf": "string",
      "serienf": "string",
      "accesskey": "string",
      "digval": "string",
      "nprot": "string",
      "dhrecbto": "string",
      "qrCode": "string",
      "urlSefazConsumer": "string",
      "tributo": "string",
      "NFCeID": "string",
      "Identificador": "string",
      "PropertyNumber": "string",
      "CRSapore": "string",
      "CXSapore": "string",
      "idMotivoDesc": "string",
      "txtMotivoDesc": "string",
      "idMotivoNFCe": "string",
      "txtMotivoNFCe": "string",
      "EnvType": "string",
      "retXML": "string",
      "SaleItems": {
        "ProductID": "string",
        "InternalCode": "string",
        "Quantity": "string",
        "PriceAmount": "string",
        "NFCeNCM": "string",
        "NFCeCFOP": "string",
        "NFCeCST": "string",
        "NFCeAliqICMS": "string",
        "NFCeCEST": "string",
        "NFCeCSTPIS": "string",
        "NFCeAliqPIS": "string",
        "NFCeCSTCOFINS": "string",
        "NFCeAliqCOFINS": "string",
        "NFCeCodANP": "string"
      },
      "SalePaymentType": {
        "PaymentTypeID": "string",
        "Name": "string",
        "PaidAmount": "string",
        "TEFType": "string",
        "TEFAutorizacao": "string",
        "TEFDataHora": "string",
        "TEFRede": "string",
        "TEFCartao": "string",
        "TEFNSUSitef": "string",
        "TEFNSUHost": "string",
        "TEFParcelas": "string"
      }
    }
  }
]
{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "Sale": {
        "type": "object",
        "properties": {
          "SaleID": {
            "type": "string",
            "description": "string(36) Uniqueidentifier da Venda - Chave Primária da Tabela"
          },
          "USersID": {
            "type": "string",
            "description": "string(36) Uniqueidentifier do Usuário"
          },
          "DatetimeSale": {
            "type": "string",
            "description": "string(19) Data/Hora da Venda."
          },
          "SaleStatus": {
            "type": "string",
            "description": "string(1) Status da venda 1 - Venda; 2 - ; 3 - Venda Cancelada; 4 - ;"
          },
          "SalePosCodeID": {
            "type": "string",
            "description": "string(50) Chave Única da venda gerada pelo terminal."
          },
          "CpfCnpj": {
            "type": "string",
            "description": "string(18) CPF/CNPJ do cliente"
          },
          "numnf": {
            "type": "string",
            "description": "string(10) Número da NFC-e"
          },
          "serienf": {
            "type": "string",
            "description": "string(3) Série da NFC-e"
          },
          "accesskey": {
            "type": "string",
            "description": "string(50) AccessKey da NFC-e"
          },
          "digval": {
            "type": "string",
            "description": "string(50) Digval da NFC-e"
          },
          "nprot": {
            "type": "string",
            "description": "string(50) NProt da NFC-e"
          },
          "dhrecbto": {
            "type": "string",
            "description": "string(50) Data de Recebimento da NFC-e"
          },
          "qrCode": {
            "type": "string",
            "description": "string(500) qrCode da NFC-e"
          },
          "urlSefazConsumer": {
            "type": "string",
            "description": "string(500) URL de consulta da NFC-e na Sefaz"
          },
          "tributo": {
            "type": "string",
            "description": "string(12) Valor total dos tributos aproximados da NFC-e"
          },
          "NFCeID": {
            "type": "string",
            "description": "string(50) NFCeID da NFC-e"
          },
          "Identificador": {
            "type": "string",
            "description": "string(30) Campo livre para identificacao, quando utilizada impressao de fichas"
          },
          "PropertyNumber": {
            "type": "string",
            "description": "string(5) Número de propriedade do Terminal."
          },
          "CRSapore": {
            "type": "string",
            "description": "string(5) Número de Unidade da Sapore."
          },
          "CXSapore": {
            "type": "string",
            "description": "string(3) Número do caixa na unidade da Sapore."
          },
          "idMotivoDesc": {
            "type": "string",
            "description": "string(3) Nao utilizado."
          },
          "txtMotivoDesc": {
            "type": "string",
            "description": "string(3) Nao utilizado."
          },
          "idMotivoNFCe": {
            "type": "string",
            "description": "string(3) Nao utilizado."
          },
          "txtMotivoNFCe": {
            "type": "string",
            "description": "string(3) Nao utilizado."
          },
          "EnvType": {
            "type": "string",
            "description": "string(1) Ambiente de emissao NFC-e 1-Producao; 2-Homologacao"
          },
          "retXML": {
            "type": "string",
            "description": "string(3) Nao utilizado"
          },
          "SaleItems": {
            "type": "object",
            "properties": {
              "ProductID": {
                "type": "string",
                "description": "string(36) Uniqueidentifier do Produto"
              },
              "InternalCode": {
                "type": "string",
                "description": "string(15) Código Interno do Produto"
              },
              "Quantity": {
                "type": "string",
                "description": "decimal(5,2) Quantidade"
              },
              "PriceAmount": {
                "type": "string",
                "description": "decimal(7,2) Preço"
              },
              "NFCeNCM": {
                "type": "string",
                "description": "string(8) NCM utilizado na venda"
              },
              "NFCeCFOP": {
                "type": "string",
                "description": "string(4) CFOP utilizado na venda"
              },
              "NFCeCST": {
                "type": "string",
                "description": "string(4) CST utilizado na venda"
              },
              "NFCeAliqICMS": {
                "type": "string",
                "description": "decimal(4,2) Alíquota de ICMS utilizada na venda."
              },
              "NFCeCEST": {
                "type": "string",
                "description": "string(7) CEST utilizado na venda"
              },
              "NFCeCSTPIS": {
                "type": "string",
                "description": "string(4) CST PIS utilizado na venda"
              },
              "NFCeAliqPIS": {
                "type": "string",
                "description": "decimal(4,2) Alíquota de PIS utilizada na venda."
              },
              "NFCeCSTCOFINS": {
                "type": "string",
                "description": "string(4) CST COFINS utilizado na venda"
              },
              "NFCeAliqCOFINS": {
                "type": "string",
                "description": "decimal(4,2) Alíquota de COFINS utilizada na venda."
              },
              "NFCeCodANP": {
                "type": "string",
                "description": "decimal(4,2) Cod ANP utilizado na venda."
              }
            }
          },
          "SalePaymentType": {
            "type": "object",
            "properties": {
              "PaymentTypeID": {
                "type": "string",
                "description": "string(36) Uniqueidentifier da Forma de Pagamento"
              },
              "Name": {
                "type": "string",
                "description": "string(50) Descricao da forma de pagamento"
              },
              "PaidAmount": {
                "type": "string",
                "description": "decimal(8,2) Valor Pago"
              },
              "TEFType": {
                "type": "string",
                "description": "string(2) Tipo de operação TEF -- Vide tabela."
              },
              "TEFAutorizacao": {
                "type": "string",
                "description": "string(30) Código de autorização TEF."
              },
              "TEFDataHora": {
                "type": "string",
                "description": "string(25) Data hora da autorização. YYYYMMDDHHMMSS"
              },
              "TEFRede": {
                "type": "string",
                "description": "string(8) Rede de autorização do Cartão. -- Vide tabela."
              },
              "TEFCartao": {
                "type": "string",
                "description": "string(8) Bandeira do cartão. -- Vide tabela."
              },
              "TEFNSUSitef": {
                "type": "string",
                "description": "string NSU do Sitef. -- Vide tabela."
              },
              "TEFNSUHost": {
                "type": "string",
                "description": "string NSU do HOST. -- Vide tabela."
              },
              "TEFParcelas": {
                "type": "string",
                "description": "string(4) Quantidade de parcelas. -- Vide tabela."
              }
            }
          }
        }
      }
    }
  }
}

Resposta 500

Unexpected error

{
  "code": 0,
  "message": "string",
  "fields": "string"
}
{
  "type": "object",
  "properties": {
    "code": {
      "type": "integer",
      "format": "int32"
    },
    "message": {
      "type": "string"
    },
    "fields": {
      "type": "string"
    }
  }
}

Exemplos de código

@ECHO OFF

curl -v -X GET "https://api.poscontrole.com.br/v2/salesDay?dateini={dateini}&dateend={dateend}"
-H "Authorization: Bearer xxxxxx.yyyyyyy.zzzzzz"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Authorization", "Bearer xxxxxx.yyyyyyy.zzzzzz");
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            var uri = "https://api.poscontrole.com.br/v2/salesDay?dateini={dateini}&dateend={dateend}&" + queryString;

            var response = await client.GetAsync(uri);
        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://api.poscontrole.com.br/v2/salesDay?dateini={dateini}&dateend={dateend}");


            URI uri = builder.build();
            HttpGet request = new HttpGet(uri);
            request.setHeader("Authorization", "Bearer xxxxxx.yyyyyyy.zzzzzz");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "https://api.poscontrole.com.br/v2/salesDay?dateini={dateini}&dateend={dateend}&" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Authorization","Bearer xxxxxx.yyyyyyy.zzzzzz");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            type: "GET",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://api.poscontrole.com.br/v2/salesDay?dateini={dateini}&dateend={dateend}";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"GET"];
    // Request headers
    [_request setValue:@"Bearer xxxxxx.yyyyyyy.zzzzzz" forHTTPHeaderField:@"Authorization"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://api.poscontrole.com.br/v2/salesDay?dateini={dateini}&dateend={dateend}');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Authorization' => 'Bearer xxxxxx.yyyyyyy.zzzzzz',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_GET);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'Authorization': 'Bearer xxxxxx.yyyyyyy.zzzzzz',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('api.poscontrole.com.br')
    conn.request("GET", "/v2/salesDay?dateini={dateini}&dateend={dateend}&%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'Authorization': 'Bearer xxxxxx.yyyyyyy.zzzzzz',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('api.poscontrole.com.br')
    conn.request("GET", "/v2/salesDay?dateini={dateini}&dateend={dateend}&%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://api.poscontrole.com.br/v2/salesDay?dateini={dateini}&dateend={dateend}')


request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['Authorization'] = 'Bearer xxxxxx.yyyyyyy.zzzzzz'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body