Listagem de Status

Requisição para a consulta de dados dos status de pedidos.

Método GET

https://{api_address}/orders/statuses

Código de Exemplo

<?php
    $params["access_token"] = "### Chave de Acesso ###";
    $params["sort"] = "id_desc";

    $url = "https://{api_address}/orders/statuses/?".http_build_query($params);

    ob_start();

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
    curl_exec($ch);

    // JSON de retorno  
    $resposta = json_decode(ob_get_contents());
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    ob_end_clean();
    curl_close($ch);

    if($code == "200"){
        //Tratamento dos dados de resposta da consulta.
    }else{
        //Tratamento das mensagens de erro
    }
?>

string URLAuth = "https://{api_address}/orders/statuses/";

NameValueCollection queryParameters = new NameValueCollection();

queryParameters.Add("access_token", "### Chave de Acesso ###");    
queryParameters.Add("sort", "id_desc");

List items = new List();

foreach (String name in queryParameters)
    items.Add(String.Concat(name, "=", System.Web.HttpUtility.UrlEncode(queryParameters[name])));

string argsString = String.Join("&", items.ToArray());

WebRequest request = WebRequest.Create(URLAuth + "?" + argsString);
    
request.Credentials = CredentialCache.DefaultCredentials;
    
WebResponse response = request.GetResponse();
  
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
    
Stream dataStream = response.GetResponseStream();
    
StreamReader reader = new StreamReader(dataStream);

string responseData = reader.ReadToEnd();

Console.WriteLine(responseData);
reader.Close();
response.Close();

String url = "https://{api_address}/orders/statuses/";

Map<String, String> mapToConvert = new HashMap<>();
mapToConvert.put("access_token", "### Chave de Acesso ###");
mapToConvert.put("sort", "id_desc");

String queryString = "";

for (Entry<String, String> entry : mapToConvert.entrySet()) {
    queryString += entry.getKey()+"="+ entry.getValue()+"&";
}

try {
    URL obj = new URL(url+"?"+queryString);
    HttpURLConnection con = (HttpURLConnection) obj.openConnection();
    
    con.setRequestMethod("GET");
    con.setRequestProperty("User-Agent", USER_AGENT);

    int responseCode = con.getResponseCode();

    BufferedReader in ;
    if (responseCode >= 200 && responseCode < 300){
        in = new BufferedReader(
            new InputStreamReader(con.getInputStream()));
    }else{
        in = new BufferedReader(
            new InputStreamReader(con.getErrorStream()));
    }
    
    String inputLine;
    StringBuilder response = new StringBuilder();

    while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
    }
    in.close();
    
    String resposta = response.toString();

} catch (Exception ex){
    // Tratamento da Exception
}

Parâmetros enviados

Field Type Description
access_token String

Chave de acesso

attrs Number

Atributos do status

limit Number

Limite de registros

page Number

Página corrente

sort String

Ordenação ex.: [campo]_[asc/desc]

Retorno em caso de sucesso (status code 200 ou 201)

 
Field Type Description
paging Object

Dados de paginação

  total Number

Total de registros

  page Number

Página corrente

  offset Number

Registro inicial da página

  limit Number

Limite de registros

  maxLimit Number

Máximo de registros

sort Object[]

Ordenação

availableFilters String[]

Filtros disponíveis

appliedFilters String[]

Filtros utilizados

OrderStatuses Object[]

Lista de produtos

  OrderStatus Object

Dados do status

    id Number

Código do status

    status String

Nome do status

    show_backoffice Number

Exibir na área administrativa

Json de retorno

HTTP/1.1 200 OK
{
    "paging": {
        "total": 6,
        "page": 1,
        "offset": 0,
        "limit": 1,
        "maxLimit": 50
    },
    "sort": [
        {
            "id": "desc"
        }
    ],
    "availableFilters": [],
    "appliedFilters": [],
    "OrderStatuses": [
        {
            "OrderStatus": {
                "status": "ENVIADO",
                "id": "1",
                "show_backoffice": "1"
            }
        }
    ]
}

Consultar Dados do Status

Requisição para a consulta de dados de um status de pedidos.

Método GET

https://{api_address}/orders/statuses/:id

Código de Exemplo

<?php
    $params["access_token"] = "### Chave de Acesso ###";

    $url = "https://{api_address}/orders/statuses/1234?".http_build_query($params);

    ob_start();

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
    curl_exec($ch);

    // JSON de retorno  
    $resposta = json_decode(ob_get_contents());
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    ob_end_clean();
    curl_close($ch);

    if($code == "200"){
        //Tratamento dos dados de resposta da consulta.
    }else{
        //Tratamento das mensagens de erro
    }
?>

string URLAuth = "https://{api_address}/orders/statuses/1234";

NameValueCollection queryParameters = new NameValueCollection();

queryParameters.Add("access_token", "### Chave de Acesso ###");    

List items = new List();

foreach (String name in queryParameters)
    items.Add(String.Concat(name, "=", System.Web.HttpUtility.UrlEncode(queryParameters[name])));

string argsString = String.Join("&", items.ToArray());

WebRequest request = WebRequest.Create(URLAuth + "?" + argsString);
    
request.Credentials = CredentialCache.DefaultCredentials;
    
WebResponse response = request.GetResponse();
  
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
    
Stream dataStream = response.GetResponseStream();
    
StreamReader reader = new StreamReader(dataStream);

string responseData = reader.ReadToEnd();

Console.WriteLine(responseData);
reader.Close();
response.Close();

String url = "https://{api_address}/orders/statuses/1234";

Map<String, String> mapToConvert = new HashMap<>();
mapToConvert.put("access_token", "### Chave de Acesso ###");

String queryString = "";

for (Entry<String, String> entry : mapToConvert.entrySet()) {
    queryString += entry.getKey()+"="+ entry.getValue()+"&";
}

try {
    URL obj = new URL(url+"?"+queryString);
    HttpURLConnection con = (HttpURLConnection) obj.openConnection();
    
    con.setRequestMethod("GET");
    con.setRequestProperty("User-Agent", USER_AGENT);

    int responseCode = con.getResponseCode();

    BufferedReader in ;
    if (responseCode >= 200 && responseCode < 300){
        in = new BufferedReader(
            new InputStreamReader(con.getInputStream()));
    }else{
        in = new BufferedReader(
            new InputStreamReader(con.getErrorStream()));
    }
    
    String inputLine;
    StringBuilder response = new StringBuilder();

    while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
    }
    in.close();
    
    String resposta = response.toString();

} catch (Exception ex){
    // Tratamento da Exception
}

Parâmetros enviados

Field Type Description
access_token String

Chave de acesso

:id Number

Código do status

Retorno em caso de sucesso (status code 200 ou 201)

Field Type Description
OrderStatus Object

Dados do status

  id Number

Código do status

  status String

Nome do status

  default Number

Status padrão (Veja Tabela E)

Json de retorno

HTTP/1.1200 OK
{"OrderStatus":{"status":"ENVIADO","id":"1","default":"1"}}


Cadastrar Status

Requisição para inclusão de um novo status de pedidos. Deverá enviar o JSON com os dados do status para a criação.

Método POST

https://{api_address}/orders/statuses

Código de Exemplo

<?php
    $params["access_token"] = "### Chave de Acesso ###";

    $data["OrderStatus"]["status"] = "NOVO STATUS";
    $data["OrderStatus"]["default"] = "1";

    $url = "https://{api_address}/orders/statuses/?".http_build_query($params);

    ob_start();

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen(json_encode($data)))
    );
    curl_exec($ch);

    // JSON de retorno  
    $resposta = json_decode(ob_get_contents());
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    ob_end_clean();
    curl_close($ch);

    if($code == "201"){
        //Tratamento dos dados de resposta da consulta.
    }else{
        //Tratamento das mensagens de erro
    }
?>

string URLAuth = "https://{api_address}/orders/statuses/";

NameValueCollection queryParameters = new NameValueCollection();

queryParameters.Add("access_token", "### Chave de Acesso ###");

List items = new List();

foreach (String name in queryParameters)
    items.Add(String.Concat(name, "=", System.Web.HttpUtility.UrlEncode(queryParameters[name])));

string argsString = String.Join("&", items.ToArray());

string postString  = "{";
       postString += "  \"OrderStatus\": {";
       postString += "      \"status\": \"NOVO STATUS\",";
       postString += "      \"default\": \"1\"";
       postString += "  }";
       postString += "}";

HttpWebRequest webRequest = WebRequest.Create(URLAuth + "?" + argsString) as HttpWebRequest;
webRequest.Method = "POST";
webRequest.ContentType = "application/json";

StreamWriter requestWriter = new StreamWriter(webRequest.GetRequestStream());
requestWriter.Write(postString);
requestWriter.Close();

StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
string responseData = responseReader.ReadToEnd();

responseReader.Close();
webRequest.GetResponse().Close();

String url = "https://{api_address}/orders/statuses/";
StringBuffer response = null ;
try{
    String access_token = "?access_token=### Chave de Acesso ###";
    
    URL obj = new URL(url+access_token);
    HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();

    //add reuqest header
    con.setRequestMethod("POST");
    con.setRequestProperty("User-Agent", USER_AGENT);
    con.setRequestProperty("Content-Type", "application/json");
    con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");

    String postString  = "{";
           postString += "  \"OrderStatus\": {";
           postString += "      \"status\": \"NOVO STATUS\",";
           postString += "      \"default\": \"1\"";
           postString += "  }";
           postString += "}";
           
    // Send post request
    con.setDoOutput(true);
    DataOutputStream wr = new DataOutputStream(con.getOutputStream());
    wr.writeBytes(postString);
    wr.flush();
    wr.close();

    int responseCode = con.getResponseCode();

    BufferedReader in ;
    if (responseCode >= 200 && responseCode < 300){
        in = new BufferedReader(
            new InputStreamReader(con.getInputStream()));
    }else{
        in = new BufferedReader(
            new InputStreamReader(con.getErrorStream()));
    }
    
    String inputLine;
    response = new StringBuffer();

    while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
    }
    in.close();

} catch (Exception ex){
    // Tratamento da Exception
}
String resposta = response.toString();

Parâmetros enviados

Field Type Description
access_token String

Chave de acesso

OrderStatus JSON

Dados do status

  status String

Nome do status

  default Number

Status padrão (Veja Tabela E)

 

Estrutura de Json


    {
			"OrderStatus":{
				"status":"A ENVIAR TESTE1",
				"description": "criação de um novo status",
				"background": "#FFFFFF",
				"default":"1"
			}
		}
    

Retorno em caso de sucesso (status code 200 ou 201)

Field Type Description
message String

Mensagem de retorno

id Number

Código do status

code Number

Código do retorno (201)

Json de retorno

HTTP/1.1201 OK
{"message":"Created","id":"1234","code":201}


Atualizar Dados do Status

Requisição para alterar os dados de um status de pedidos. Deverá enviar o JSON com os dados do status para a alteração.

Método PUT

https://{api_address}/orders/statuses/:id

Código de Exemplo

<?php
    $params["access_token"] = "### Chave de Acesso ###";

    $data["OrderStatus"]["status"] = "STATUS ALTERADO";
    $data["OrderStatus"]["default"] = "1";

    $url = "https://{api_address}/orders/statuses/1234?".http_build_query($params);

    ob_start();

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen(json_encode($data)))
    );
    curl_exec($ch);

    // JSON de retorno  
    $resposta = json_decode(ob_get_contents());
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    ob_end_clean();
    curl_close($ch);

    if($code == "200"){
        //Tratamento dos dados de resposta da consulta.
    }else{
        //Tratamento das mensagens de erro
    }
?>

string URLAuth = "https://{api_address}/orders/statuses/1234";

NameValueCollection queryParameters = new NameValueCollection();

queryParameters.Add("access_token", "### Chave de Acesso ###");

List items = new List();

foreach (String name in queryParameters)
    items.Add(String.Concat(name, "=", System.Web.HttpUtility.UrlEncode(queryParameters[name])));

string argsString = String.Join("&", items.ToArray());

string putString  = "{";
       putString += "  \"OrderStatus\": {";
       putString += "      \"status\": \"STATUS ALTERADO\",";
       putString += "      \"default\": \"1\"";
       putString += "  }";
       putString += "}";

HttpWebRequest webRequest = WebRequest.Create(URLAuth + "?" + argsString) as HttpWebRequest;
webRequest.Method = "PUT";
webRequest.ContentType = "application/json";

StreamWriter requestWriter = new StreamWriter(webRequest.GetRequestStream());
requestWriter.Write(putString);
requestWriter.Close();

StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
string responseData = responseReader.ReadToEnd();

responseReader.Close();
webRequest.GetResponse().Close();

String url = "https://{api_address}/orders/statuses/1234";
StringBuffer response = null ;
try{
    String access_token = "?access_token=### Chave de Acesso ###";
    
    URL obj = new URL(url+access_token);
    HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();

    //add reuqest header
    con.setRequestMethod("PUT");
    con.setRequestProperty("User-Agent", USER_AGENT);
    con.setRequestProperty("Content-Type", "application/json");
    con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");

    String putString  = "{";
           putString += "  \"OrderStatus\": {";
           putString += "      \"status\": \"STATUS ALTERADO\",";
           putString += "      \"default\": \"1\"";
           putString += "  }";
           putString += "}";
           
    // Send put request
    con.setDoOutput(true);
    DataOutputStream wr = new DataOutputStream(con.getOutputStream());
    wr.writeBytes(putString);
    wr.flush();
    wr.close();

    int responseCode = con.getResponseCode();

    BufferedReader in ;
    if (responseCode == 200){
        in = new BufferedReader(
            new InputStreamReader(con.getInputStream()));
    }else{
        in = new BufferedReader(
            new InputStreamReader(con.getErrorStream()));
    }
    
    String inputLine;
    response = new StringBuffer();

    while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
    }
    in.close();

} catch (Exception ex){
    // Tratamento da Exception
}
String resposta = response.toString();

Parâmetros enviados

Field Type Description
access_token String

Chave de acesso

:id String

Código do status

OrderStatus JSON

Dados do status

  status String

Nome do status

  default Number

Status padrão (Veja Tabela E)

Estrutura de Json

PUT /orders/statuses/1234?access_token=abc96fb7b1defd2496b9a9d81071fa12319b12306465e057d0ebca9bd9ab19
{"OrderStatus":{"status":"STATUS ALTERADO","default":"1"}}

Retorno em caso de sucesso (status code 200 ou 201)

Field Type Description
message String

Mensagem de retorno

id Number

Código do status

code Number

Código do retorno (200)

 

Json de retorno

HTTP/1.1200 OK
{"message":"Saved","id":"1234","code":200}


Excluir Status

Requisição para excluir um status de pedidos.

Método DELETE

https://{api_address}/orders/statuses/:id

Código de Exemplo

<?php
    $params["access_token"] = "### Chave de Acesso ###";

    $url = "https://{api_address}/orders/statuses/1234?".http_build_query($params);

    ob_start();

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen(json_encode($data)))
    );
    curl_exec($ch);

    // JSON de retorno  
    $resposta = json_decode(ob_get_contents());
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    ob_end_clean();
    curl_close($ch);

    if($code == "200"){
        //Tratamento dos dados de resposta da consulta.
    }else{
        //Tratamento das mensagens de erro
    }
?>

string URLAuth = "https://{api_address}/orders/statuses/1";

NameValueCollection queryParameters = new NameValueCollection();

queryParameters.Add("access_token", "### Chave de Acesso ###");

List items = new List();

foreach (String name in queryParameters)
    items.Add(String.Concat(name, "=", System.Web.HttpUtility.UrlEncode(queryParameters[name])));

string argsString = String.Join("&", items.ToArray());

HttpWebRequest webRequest = WebRequest.Create(URLAuth + "?" + argsString) as HttpWebRequest;
webRequest.Method = "DELETE";
webRequest.ContentType = "application/json";

StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
string responseData = responseReader.ReadToEnd();

responseReader.Close();
webRequest.GetResponse().Close();

String url = "https://{api_address}/orders/statuses/1";
StringBuffer response = null ;
try{
    String access_token = "?access_token=### Chave de Acesso ###";
    
    URL obj = new URL(url+access_token);
    HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();

    //add reuqest header
    con.setRequestMethod("DELETE");
    con.setRequestProperty("User-Agent", USER_AGENT);
    con.setRequestProperty("Content-Type", "application/json");
    con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");

    int responseCode = con.getResponseCode();

    BufferedReader in ;
    if (responseCode == 200){
        in = new BufferedReader(
            new InputStreamReader(con.getInputStream()));
    }else{
        in = new BufferedReader(
            new InputStreamReader(con.getErrorStream()));
    }
    
    String inputLine;
    response = new StringBuffer();

    while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
    }
    in.close();

} catch (Exception ex){
    // Tratamento da Exception
}
String resposta = response.toString();

Parâmetros enviados

Field Type Description
access_token String

Chave de acesso

id Number

Código do pedido

Retorno em caso de sucesso (status code 200 ou 201)

Field Type Description
message String

Mensagem de retorno

id Number

Código do status

code Number

Código do retorno (200)

Json de retorno

HTTP/1.1 200 OK
{
    "message": "Deleted",
    "id": "1",
    "code": 200
}

 

Tabelas Auxiliares

Tabelas Auxiliares de Pedidos

Tabela E - Tipo de status do pedido (campo OrderStatus.default)

Valor Descrição
1 Status adicional
Frontend - Agencia 
Tem mais dúvidas? Envie uma solicitação

Comentários

    Artigos nessa seção

    Powered by Zendesk