La API de integración de Track NPS fue creada con el objetivo de que las informaciones pudieran tener una autenticación para acceder. Las caracteristicas, tenemos:
- Un TOKEN es generado a través de nuestra plataforma, o de una requisición. De esta forma, automatizamos todo el proceso y también homologamos el acceso a informaciones.
- La API integra las funciones en una sola API con diversos métodos.
- Trabaja con el modelo RESTful con JSON.
En esta documentación encontrará también ejemplos de códigos en el idioma que usted escoja, que pueden cambiar en cualquier momento en el botón de la derecha.
Esta API utiliza el protocolo HTTPS. Por lo tanto, todas las llamadas deben comenzar con https://
.
La API tiene un bloqueo de seguridad que limita el número de solicitudes a 1000 en un intervalo de cinco minutos.
Si se realizan más de 1000 solicitudes dentro de este intervalo, se devolverá un error con estado 405
con una validación CAPTCHA que debe resolverse para continuar enviando solicitudes.
La utilización de la API demanda el uso de una clave que llamamos TOKEN, el mismo será responsable de permitir el acceso al sistema.
-
Para ello, iniciar sesión en Tracksale con una cuenta de administrador.
-
Acceder al menú Apps en la esquina superior derecha junto al nombre del usuario.
-
Haga clic en instalar en la aplicación
"API V2".
-
Cliqueando en NUEVO TOKEN.
-
Se generará un nuevo token.
-
Un nuevo TOKEN será generado y agregado a la lista, nuevas adiciones no inutilizan los anteriores.
Cada endpoint tiene una URL específica, verifíquela individualmente.
Utilizaremos el TOKEN que adquirimos en el header (Sin la necesidad de conversión a base64), para autenticar el acceso. De la siguiente manera:
-
Key
Authorization
-
Value
bearer TOKEN
Donde:
- Authorization es la palabra Authorization
- bearer es la palabra bearer y TOKEN es el TOKEN
adquirido aqui
Listar Campañas
Para listar las campañas utilizaremos la siguiente configuración:
-
El método utilizado será :
GET
-
La URL utilizada será :
https://api.tracksale.co/v2/campaign
Este método es responsable de la lista de URL utilizada en todas las campañas, sus códigos y algunos detalles, como por ejemplo, preguntas usadas.
Es posible que se vuelva sólo una campaña específica, esto es posible usando:
Donde Campaign_code es el código de la campaña que desea obtener información.
Para recoger el código de una campaña específica, primero debe listar todos las campañas y tomar el atributo "code" de la vuelta
Asegúrese de utilizar los parámetros start
y end
en formato AAAA-MM-DD para recibir datos de respuesta como número de pasivos, promotores, detractores, etc.
Ejemplo de retorno:
{
"name":"Customers_name",
"code" : Campaign_code,
"description" : Campaign_description,
"detractors" : Detractors_name,
"passives" : Neutrals_name,
"promoters" : Promoters_name,
"dispatches" : Dispatches_number,
"comments" : Comments,
"answers" : Answers,
"main_channel" : "Main_channel",
"create_time" : "Time_of_creation",
"questions" : [
{
"id" : "Question_id",
"type" : "Question_type",
"title" : "Question_title",
"question" : "Question",
"secondary" : "Secondary_question"
}
]
}
También es posible complementar el resultado de la consulta con la información de limitación de disparo. Para hacer esto, use el parámetro de consulta dispatch_limits
con valor 1
.
Si la campaña no utiliza esta función, los valores devueltos serán null
.
Ejemplo de retorno:
{
"name":"Customers_name",
"code" : Campaign_code,
"description" : Campaign_description,
"detractors" : Detractors_name,
"passives" : Neutrals_name,
"promoters" : Promoters_name,
"dispatches" : Dispatches_number,
"comments" : Comments,
"answers" : Answers,
"main_channel" : "Main_channel",
"create_time" : "Time_of_creation",
"questions" : [
{
"id" : "Question_id",
"type" : "Question_type",
"title" : "Question_title",
"question" : "Question",
"secondary" : "Secondary_question"
}
],
"dispatch_limits": {
"daily": {
"limit": null,
"remaining": null
},
"weekly": {
"limit": null,
"remaining": null
},
"monthly": {
"limit": null,
"remaining": null
}
}
}
Ejemplos de código : Listar Campañas
Clase Http
GET /v2/campaign HTTP/1.1
Host: api.tracksale.co
Authorization: bearer TOKEN
Cache-Control: no-cache
Clase C(libCurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.tracksale.co/v2/campaign");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "authorization: bearer TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
Clase cURL
curl -X GET \
https://api.tracksale.co/v2/campaign \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache'
Clase C#
var client = new RestClient("https://api.tracksale.co/v2/campaign");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "bearer TOKEN");
IRestResponse response = client.Execute(request);
Clase Go
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/campaign"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Clase Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/campaign")
.get()
.addHeader("authorization", "bearer TOKEN")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Clase Java Unirest
HttpResponse<String> response = Unirest.get("https://api.tracksale.co/v2/campaign")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.asString();
Clase JavaScript Jquery AJAX
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/campaign",
"method": "GET",
"headers": {
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Clase JavaScript XHR
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://api.tracksale.co/v2/campaign");
xhr.setRequestHeader("authorization", "bearer TOKEN");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Clase NodeJS Native
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/campaign",
"headers": {
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
Clase NodeJS Request
var request = require("request");
var options = { method: 'GET',
url: 'https://api.tracksale.co/v2/campaign',
headers:
{ 'cache-control': 'no-cache',
'authorization': 'bearer TOKEN' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Clase NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("GET", "https://api.tracksale.co/v2/campaign");
req.headers({
"cache-control": "no-cache",
"authorization": "bearer TOKEN"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Clase Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"bearer TOKEN",
@"cache-control": @"no-cache" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/campaign"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Clase OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/campaign" in
let headers = Header.init ()
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "cache-control" "no-cache"
in
Client.call ~headers `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Clase PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/campaign');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Clase PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://api.tracksale.co/v2/campaign');
$request->setRequestMethod('GET');
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Clase PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/campaign",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Clase Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
headers = {
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
conn.request("GET", "/v2/campaign", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Clase Python requests
import requests
url = "https://api.tracksale.co/v2/campaign"
headers = {
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
Clase Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/campaign")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["authorization"] = 'bearer TOKEN'
request["cache-control"] = 'no-cache'
response = http.request(request)
puts response.read_body
Clase Shell wget
wget --quiet \
--method GET \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--output-document \
- https://api.tracksale.co/v2/campaign
Clase Shell Httpie
http GET https://api.tracksale.co/v2/campaign \
authorization:'bearer TOKEN' \
cache-control:no-cache
Clase Shell cURL
curl --request GET \
--url https://api.tracksale.co/v2/campaign \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache'
Clase Swift (NSURL)
import Foundation
let headers = [
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/campaign")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Es posible buscar información de un widget creado, como el número de veces que se abrió, los límites de apertura, su identificador y nombre.
-
El método utilizado será :
GET
-
La URL utilizada será :
https://api.tracksale.co/v2/widget/{key}
Donde {key} es el atributo clave que se puede encontrar al personalizar un widget.
Ejemplo de retorno:
{
"id": 1,
"name": "Widget",
"views": {
"daily": 2,
"weekly": 0,
"monthly": 0,
},
"limits": {
"daily": 2,
"weekly": 0,
"monthly": 0,
"has_limit": false,
"limit_reached": "daily"
}
}
Cheque Noventena
Es posible verificar si un cliente está siendo afectado por las reglas de los noventa.
-
El método utilizado será :
POST
-
La URL utilizada será :
https://api.tracksale.co/v2/campaign/Campaign_code/can-impact
-
JSON puede usar correo electrónico, teléfono o un identificador único del cliente:
Ejemplo de requisición:
{
"email": "Customer Email",
// or
"phone": "Customer Phone",
// or
"identification": "Customer Identification"
}
Donde Campaign_code es el código de la campaña para la que desea verificar la información.
Para recoger el código de una campaña específica, primero debe listar todos las campañas y tomar el atributo "code" de la vuelta
Ejemplo de retorno:
{
"can_impact": true
}
Enlace de búsqueda
Es posible crear enlaces de búsqueda directamente a través de la API respetando la limitación de 500 clientes por solicitud.
-
El método utilizado será :
POST
-
La URL utilizada será :
https://api.tracksale.co/v2/campaign/Campaign_code/survey-links
-
JSON será una matriz de clientes como en el ejemplo a continuación:
Ejemplo de requisición:
{
"customers": [
{
"name": "Customer Name",
"email": "Customer Email",
"phone": "Customer Phone",
"tags": [
{
"name": "Tag name",
"value": "Tag value"
},
{
"name": "Tag name",
"value": "Tag value"
}
]
}
]
}
Donde Campaign_code es el código de la campaña para la que desea verificar la información.
Para recoger el código de una campaña específica, primero debe listar todos las campañas y tomar el atributo "code" de la vuelta
Ejemplo de retorno:
{
"customers": [
{
"name": "Customer Name",
"email": "Customer Email",
"phone": "Customer Phone",
"tags": [
{
"name": "Tag name",
"value": "Tag value"
},
{
"name": "Tag name",
"value": "Tag value"
}
],
"survey_link": "https://tracksale.co/s/Survey_hash"
}
]
}
Donde Survey_hash es el identificador alfanumérico para ese enlace.
Disparos
Los disparos se pueden realizar de dos formas diferentes:
Disparo programado:
La existencia de la variable schedule_time es opcional.
Así, tenemos dos opciones:
-
Insertar la variable "schedule_time" :
De esta forma usted puede utilizar "schedule_time" para definir cuando se realizará el disparo, siendo definido como un formato "Unix Timestamp" en segundos. El body quedará de la siguiente forma
El ejemplo siguiente muestra la inserción con todas las variables, pero hay casos en los que se pueden omitir las variables indentification, phone y email.
Ex: Si la campaña es vía SMS, no es necesario eviar el email, pero todavía puede ser enviado. En las campañas vía email la variable phone no necesita ser enviada, pero si es necesario, existe la posibilidad de enviarla.
El envío de ambas variables se indica si utiliza flujo de campañas.
Se recomienda el envío de identificación si desea identificar al cliente con el mismo parámetro de su empresa / plataforma
Límite máximo de 500 clientes por solicitud.
Ejemplo de requisición:
{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"identification": null,
"phone": "Customers_phone",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_seconds
}
Do clase application/json
No insertar la variable "schedule_time" :
Esta manera debe ser usada si su intención es reunir varios disparos a una campaña, para efectuarlos de una sola vez posteriormente. De esta forma, se devuelve un código del lote de disparos, este código se debe utilizar en Disparo de lotes.
Ejemplo de requisición:
{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
}
Do clase application/json
Todos los disparos posteriores a la misma campaña devolverán el mismo lote de disparos hasta que realice el disparo de este lote.
Parámetros:
Atributos |
Tipos |
Obligatorio |
Descripción |
name |
String |
No |
Nombre del cliente |
email |
String |
Sí (para disparos Vía email) |
Correo electrónico del cliente |
phone |
String |
Sí (para disparos Vía SMS) |
Teléfono del cliente |
tags |
Array |
No |
Nombre de la tag |
finish_time |
Integer |
No |
Fecha de expiración de la encuesta, en el formato unix timestamp |
tags |
Clase |
Obligatorio |
Descripción |
name |
String |
Sí |
Nombre de la tag |
value |
String |
Sí |
Valor de la Tag |
Ejemplo de retorno:
Sin schedule_time
{
"msg":"Customers have been successfully added!",
"dispatch_code":"Dispatch_code",
"status": {
"duplicated":Number_of_duplications,
"invalid":Number_of_invalids,
"inserted":Number_of_insertions
},
"campaign": {
"name":Campaign_name,
"cod":Campaign_code
}
}
Ejemplo de retorno:
Con schedule_time
{
"msg":"Dispatch executed!",
"dispatch_code":"Dispatch_code",
"status": {
"duplicated":Number_of_duplications,
"invalid":Number_of_invalids,
"inserted":Number_of_insertions
},
"campaign": {
"name":Campaign_name,
"cod":Campaign_code
}
}
También se puede devolver una matriz con los clientes que no se han insertado, ya sea que se duplican o por qué se encontraban inválidos.
Para ello, se debe pasar el parámetro getNotInserted con el valor 1. Así regresaremos de la siguiente manera.
Ejemplo de retorno:
{
"msg":"Dispatch executed!",
"dispatch_code":"Dispatch_code",
"status": {
"duplicated":Number_of_duplications,
"invalid":Number_of_invalids,
"inserted":Number_of_insertions
},
"campaign": {
"name":Campaign_name,
"cod":Campaign_code
}
"duplicated_customers": [
{
"name":"customer name",
"email":"email@email.com"
}
],
"invalid_customers": [
{
"name":"customer name",
"reason":"Invalid or empty main channel"
}
],
}
Exemplos de código : Disparos
Clase Http
POST /v2/campaign/campaign_code/dispatch HTTP/1.1
Host: api.tracksale
Content-Type: application/json
Authorization: bearer TOKEN
Cache-Control: no-cache
{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}
Clase C(libCurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.tracksale.co/v2/campaign/campaign_code/dispatch");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "authorization: bearer TOKEN");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}");
CURLcode ret = curl_easy_perform(hnd);
Clase cURL
curl -X POST \
https://api.tracksale.co/v2/campaign/campaign_code/dispatch \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}'
Clase C#
var client = new RestClient("https://api.tracksale.co/v2/campaign/campaign_code/dispatch");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "bearer TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Clase Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/campaign/campaign_code/dispatch"
payload := strings.NewReader("{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Clase Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}");
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/campaign/campaign_code/dispatch")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("authorization", "bearer TOKEN")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Clase Java Unirest
HttpResponse<Foundag> response = Unirest.get("https://api.tracksale.co/v2/campaign")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.asString();
Clase JavaScript Jquery AJAX
HttpResponse<String> response = Unirest.post("https://api.tracksale.co/v2/campaign/campaign_code/dispatch")
.header("content-type", "application/json")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.body("{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}")
.asString();
Clase JavaScript XHR
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/campaign/campaign_code/dispatch",
"method": "POST",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
},
"data": "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Clase NodeJS Native
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/campaign/campaign_code/dispatch",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}");
req.end()
Clase NodeJS Request
var request = require("request");
var options = { method: 'POST',
url: 'https://api.tracksale.co/v2/campaign/campaign_code/dispatch',
headers:
{ 'cache-control': 'no-cache',
'authorization': 'bearer TOKEN',
'content-type': 'application/json' },
body: '{\n "customers": [\n {\n "name":"Customers_name",\n "email":"Customers_email",\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n },\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ],\n "schedule_time": Timestamp_in_Seconds\n}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Clase NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("POST", "https://api.tracksale.co/v2/campaign/campaign_code/dispatch");
req.headers({
"cache-control": "no-cache",
"authorization": "bearer TOKEN",
"content-type": "application/json"
});
req.send("{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}");
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Clase Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"content-type": @"application/json",
@"authorization": @"bearer TOKEN",
@"cache-control": @"no-cache" };
NSData *postData = [[NSData alloc] initWithData:[@"{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/campaign/campaign_code/dispatch"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Clase OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/campaign/campaign_code/dispatch" in
let headers = Header.init ()
|> fun h -> Header.add h "content-type" "application/json"
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "cache-control" "no-cache"
in
let body = Cohttp_lwt_body.of_string "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Clase PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/campaign/campaign_code/dispatch');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$request->setBody('{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Clase PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}');
$request->setRequestUrl('https://api.tracksale.co/v2/campaign/campaign_code/dispatch');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Clase PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/campaign/campaign_code/dispatch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Clase Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
payload = "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
conn.request("POST", "/v2/campaign/campaign_code/dispatch", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Clase Python requests
import requests
url = "https://api.tracksale.co/v2/campaign/campaign_code/dispatch"
payload = "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Clase Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/campaign/campaign_code/dispatch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'bearer TOKEN'
request["cache-control"] = 'no-cache'
request.body = "{\n \"customers\": [\n {\n \"name\":\"Customers_name\",\n \"email\":\"Customers_email\",\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n },\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ],\n \"schedule_time\": Timestamp_in_Seconds\n}"
response = http.request(request)
puts response.read_body
Clase Shell wget
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--body-data '{\n "customers": [\n {\n "name":"Customers_name",\n "email":"Customers_email",\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n },\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ],\n "schedule_time": Timestamp_in_Seconds\n}' \
--output-document \
- https://api.tracksale.co/v2/campaign/campaign_code/dispatch
Clase Shell Httpie
echo '{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}' | \
http POST https://api.tracksale.co/v2/campaign/campaign_code/dispatch \
authorization:'bearer TOKEN' \
cache-control:no-cache \
content-type:application/json
Clase Shell cURL
curl --request POST \
--url https://api.tracksale.co/v2/campaign/campaign_code/dispatch \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{\n "customers": [\n {\n "name":"Customers_name",\n "email":"Customers_email",\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n },\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ],\n "schedule_time": Timestamp_in_Seconds\n}'
Clase Swift (NSURL)
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
]
let postData = NSData(data: "{
"customers": [
{
"name":"Customers_name",
"email":"Customers_email",
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
},
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
],
"schedule_time": Timestamp_in_Seconds
}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/campaign/campaign_code/dispatch")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Disparo de lotes:
El disparo de este lote debe efectuarse utilizando las siguientes configuraciones
El cuerpo debe ser llenado con el tiempo que el disparo debe realizarse en segundos, en el formato timestamp.
Utilice 0 para un disparo instantáneo.
Ejemplo de requisición:
4>
{
"time": Timestamp_in_seconds
}
Nombre |
Clase |
Obligatorio |
Descripción |
time |
Integer |
Sí |
El tiempo que se realizará el disparo, en segundos en el formato timestamp |
Ejemplo de retorno:
{
"msg":"Dispatch executed!",
"customers":"Number_of_customers",
}
Ejemplos de código : Disparo de lotes
Clase Http
POST /v2/campaign/campaign_code/dispatch/Codigo_lote HTTP/1.1
Host: api.tracksale.co
Authorization: bearer TOKEN
Content-Type: application/json
Cache-Control: no-cache
{
"time": Timestamp_in_Seconds
}
Clase C(libCurl)
curl -X POST \
https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"time": Timestamp_in_Seconds
}'
Clase cURL
curl -X POST \
https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"time": Timestamp_in_Seconds
}'
Clase C#
var client = new RestClient("https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "bearer TOKEN");
request.AddParameter("application/json", "{\n \"time\": Timestamp_in_Seconds\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Clase Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote"
payload := strings.NewReader("{\n \"time\": Timestamp_in_Seconds\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("content-type", "application/json")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Clase Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n \"time\": Timestamp_in_Seconds\n}");
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote")
.post(body)
.addHeader("authorization", "bearer TOKEN")
.addHeader("content-type", "application/json")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Clase Java Unirest
HttpResponse<String> response = Unirest.post("https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote")
.header("authorization", "bearer TOKEN")
.header("content-type", "application/json")
.header("cache-control", "no-cache")
.body("{\n \"time\": Timestamp_in_Seconds\n}")
.asString();
Clase JavaScript Jquery AJAX
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote",
"method": "POST",
"headers": {
"authorization": "bearer TOKEN",
"content-type": "application/json",
"cache-control": "no-cache"
},
"data": "{\n \"time\": Timestamp_in_Seconds\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Clase JavaScript XHR
var data = "{\n \"time\": Timestamp_in_Seconds\n}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote");
xhr.setRequestHeader("authorization", "bearer TOKEN");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Clase NodeJS Native
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/campaign/campaign_code/dispatch/Codigo_lote",
"headers": {
"authorization": "bearer TOKEN",
"content-type": "application/json",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"time\": Timestamp_in_Seconds\n}");
req.end();
Clase NodeJS Request
var request = require("request");
var options = { method: 'POST',
url: 'https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote',
headers:
{ 'cache-control': 'no-cache',
'content-type': 'application/json',
'authorization': 'bearer TOKEN' },
body: '{\n "time": Timestamp_in_Seconds\n}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Clase NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("POST", "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote");
req.headers({
"cache-control": "no-cache",
"content-type": "application/json",
"authorization": "bearer TOKEN"
});
req.send("{\n \"time\": Timestamp_in_Seconds\n}");
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Clase Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"bearer TOKEN",
@"content-type": @"application/json",
@"cache-control": @"no-cache" };
NSData *postData = [[NSData alloc] initWithData:[@"{
"time": Timestamp_in_Seconds
}" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Clase OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote" in
let headers = Header.init ()
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "content-type" "application/json"
|> fun h -> Header.add h "cache-control" "no-cache"
in
let body = Cohttp_lwt_body.of_string "{\n \"time\": Timestamp_in_Seconds\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Clase PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/json',
'authorization' => 'bearer TOKEN'
));
$request->setBody('{
"time": Timestamp_in_Seconds
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Clase PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"time": Timestamp_in_Seconds
}');
$request->setRequestUrl('https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'content-type' => 'application/json',
'authorization' => 'bearer TOKEN'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Clase PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"time\": Timestamp_in_Seconds\n}",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Clase Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
payload = "{\n \"time\": Timestamp_in_Seconds\n}"
headers = {
'authorization': "bearer TOKEN",
'content-type': "application/json",
'cache-control': "no-cache"
}
conn.request("POST", "/v2/campaign/campaign_code/dispatch/Codigo_lote", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Clase Python requests
import requests
url = "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote"
payload = "{\n \"time\": Timestamp_in_Seconds\n}"
headers = {
'authorization': "bearer TOKEN",
'content-type': "application/json",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Clase Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["authorization"] = 'bearer TOKEN'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n \"time\": Timestamp_in_Seconds\n}"
response = http.request(request)
puts response.read_body
Clase Shell wget
wget --quiet \
--method POST \
--header 'authorization: bearer TOKEN' \
--header 'content-type: application/json' \
--header 'cache-control: no-cache' \
--body-data '{\n "time": Timestamp_in_Seconds\n}' \
--output-document \
- https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote
Clase Shell Httpie
echo '{
"time": Timestamp_in_Seconds
}' | \
http POST https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote \
authorization:'bearer TOKEN' \
cache-control:no-cache \
content-type:application/json
Clase Shell cURL
curl --request POST \
--url https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{\n "time": Timestamp_in_Seconds\n}'
Clase Swift (NSURL)
import Foundation
let headers = [
"authorization": "bearer TOKEN",
"content-type": "application/json",
"cache-control": "no-cache"
]
let postData = NSData(data: "{
"time": Timestamp_in_Seconds
}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/campaign/campaign_code/dispatch/Codigo_lote")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Insertar Respuestas
También proporcionamos un método de inserción de respuestas. Este método se puede utilizar con los siguientes Parámetros.
- El método será:
POST
- La URL que se utilizará debe ser:
https://api.tracksale.co/v2/answer
El body debe ser completado con el lote de respuestas usando el siguiente por defecto
Ejemplo de requisición:
4>
{
"campaign_code": "Campaign_code",
"answers":[
{
"name":"Customers_name",
"email":"Customers_email",
"score":Customer_score,
"justification":""Customers_comment"",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}
Parámetros:
Parámetro |
Clase |
Obligatorio |
Descripción |
campaign_code |
String |
Sí |
Clave de la campaña objetivo. Obtenido por el métodoListar campañas |
answers |
Array |
Sí |
Lista de respuestas |
answers |
Clase |
Obligatorio |
Descripción |
name |
String |
Sí |
Nombre del cliente |
email |
String |
Sí, se o disparo foi realizado por email |
Correo electrónico del cliente |
phone |
String |
Sí, se o disparo foi realizado por telefone |
Teléfono del cliente |
identification |
String |
No |
Atributo identificador único del cliente |
score |
Integer |
Sí |
Score del cliente (entre 0 a 10) |
justification |
String |
No |
Comentarios del cliente |
create_time |
Integer |
No |
Fecha/hora de la respuesta en el defecto timestamp (en segundos) |
Ejemplo de retorno:
{
"msg":"Number_of_answers Answer inserted"
"status": {
"invalid":Number_of_invalids,
"inserted":Number_of_insertions,
}
}
También es posible obtener un arreglo con los clientes que fueron insertados y los ID de sus respectivas respuestas cuando regrese la solicitud.
Para esto, debe pasar el parámetro de consulta return_answer_id
con el valor 1
.
Así que volvemos de la siguiente manera:
Ejemplo de retorno:
{
"msg":"Number_of_answers Answer inserted"
"status": {
"invalid":Number_of_invalids,
"inserted":Number_of_insertions,
},
"answers": [
{
"answer_id": Answer_id,
"name": "Customers_name",
"email": "Customers_email",
"phone": Customers_phone,
"identification": "Customers_identification"
}
]
}
Ejemplos de código : Insertar Respuestas
Clase Http
POST /v2/answer HTTP/1.1
Host: api.tracksale
Content-Type: application/json
Authorization: bearer TOKEN
Cache-Control: no-cache
{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}
Clase C(libCurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.tracksale.co/v2/answer");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "authorization: bearer TOKEN");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}");
CURLcode ret = curl_easy_perform(hnd);
Clase cURL
curl -X POST \
https://api.tracksale.co/v2/answer \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}'
Clase C#
var client = new RestClient("https://api.tracksale.co/v2/answer");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "bearer TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Clase Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/answer"
payload := strings.NewReader("{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Clase Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}");
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/answer")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("authorization", "bearer TOKEN")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Clase Java Unirest
HttpResponse<String> response = Unirest.post("https://api.tracksale.co/v2/answer")
.header("content-type", "application/json")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.body("{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}")
.asString();
Clase JavaScript Jquery AJAX
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/answer",
"method": "POST",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
},
"data": "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Clase JavaScript XHR
var data = "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.tracksale.co/v2/answer");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "bearer TOKEN");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Clase NodeJS Native
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/answer",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}");
req.end();
Clase NodeJS Request
var request = require("request");
var options = { method: 'POST',
url: 'https://api.tracksale.co/v2/answer',
headers:
{ 'cache-control': 'no-cache',
'authorization': 'bearer TOKEN',
'content-type': 'application/json' },
body: '{\n "campaign_code": "campaign_code",\n "answers":[\n {\n "name":"customers_name",\n "email":"customers_Email",\n "score":Customer_score,\n "justification":"customers_comment",\n "create_time":Timestamp_in_seconds,\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ]\n}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Clase NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("POST", "https://api.tracksale.co/v2/answer");
req.headers({
"cache-control": "no-cache",
"authorization": "bearer TOKEN",
"content-type": "application/json"
});
req.send("{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}");
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Clase Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"content-type": @"application/json",
@"authorization": @"bearer TOKEN",
@"cache-control": @"no-cache" };
NSData *postData = [[NSData alloc] initWithData:[@"{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/answer"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Clase OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/answer" in
let headers = Header.init ()
|> fun h -> Header.add h "content-type" "application/json"
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "cache-control" "no-cache"
in
let body = Cohttp_lwt_body.of_string "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Clase PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/answer');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$request->setBody('{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Clase PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}');
$request->setRequestUrl('https://api.tracksale.co/v2/answer');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Clase PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/answer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Clase Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
payload = "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
conn.request("POST", "/v2/answer", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Clase Python requests
import requests
url = "https://api.tracksale.co/v2/answer"
payload = "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Clase Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/answer")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'bearer TOKEN'
request["cache-control"] = 'no-cache'
request.body = "{\n \"campaign_code\": \"campaign_code\",\n \"answers\":[\n {\n \"name\":\"customers_name\",\n \"email\":\"customers_Email\",\n \"score\":Customer_score,\n \"justification\":\"customers_comment\",\n \"create_time\":Timestamp_in_seconds,\n \"tags\" : [\n {\n \"name\" : \"TagExample\",\n \"value\" : \"TagExample\"\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body
Clase Shell wget
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--body-data '{\n "campaign_code": "campaign_code",\n "answers":[\n {\n "name":"customers_name",\n "email":"customers_Email",\n "score":Customer_score,\n "justification":"customers_comment",\n "create_time":Timestamp_in_seconds,\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ]\n}' \
--output-document \
- https://api.tracksale.co/v2/answer
Clase Shell Httpie
echo '{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}' | \
http POST https://api.tracksale.co/v2/answer \
authorization:'bearer TOKEN' \
cache-control:no-cache \
content-type:application/json
Clase Shell cURL
curl --request POST \
--url https://api.tracksale.co/v2/answer \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{\n "campaign_code": "campaign_code",\n "answers":[\n {\n "name":"customers_name",\n "email":"customers_Email",\n "score":Customer_score,\n "justification":"customers_comment",\n "create_time":Timestamp_in_seconds,\n "tags" : [\n {\n "name" : "TagExample",\n "value" : "TagExample"\n }\n ]\n }\n ]\n}'
Clase Swift (NSURL)
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
]
let postData = NSData(data: "{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/answer")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Insertar Varias Respuestas
Método de inserción de varias respuestas para una campaña. Se aceptan respuestas para campañas con preguntas de los siguientes tipos:
NPS, CSAT, Elección Única, Review, Pregunta Abierta y NPS secundario.
- El método será:
POST
- La URL que se utilizará debe ser:
https://api.tracksale.co/v2/answers
El body debe ser completado con el lote de respuestas usando el siguiente por defecto:
Ejemplo de requisición:
{
"campaign_code": "Campaign_code",
"data":[
{
"name":"Customers_name",
"email":"Customers_email",
"phone":"Customers_phone",
"identification":"Customers_identification",
"create_time":Timestamp_in_seconds,
"answers":[
{
"question_id":Question_id,
"score":Customer_score,
"justification":""Customers_comment""
},
{
"question_id":Question_id,
"option":Option_chosen,
},
{
"question_id":Question_id,
"comment":""Customers_comment""
},
],
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}
Parámetros:
Parâmetro |
Clase |
Obligatorio |
Descripción |
campaign_code |
String |
Sí |
Clave de la campaña objetivo. Obtenido por el método Listar campañas |
data |
Array |
Sí |
Lista de respuestas |
data |
Clase |
Obligatorio |
Descripción |
name |
String |
Sí |
Nombre del cliente |
email |
String |
Sí, si el disparo se realizó por correo electrónico |
Correo electrónico del cliente |
phone |
String |
Sí, si el disparo se realizó por teléfono |
Teléfono del cliente |
identification |
String |
No |
Atributo identificador único del cliente |
create_time |
Integer |
No |
Fecha/hora de la respuesta en el defecto timestamp (en segundos) |
answers | Array |
Sí |
Lista de respuestas a preguntas de la campaña. Deben estar en el mismo orden definido en la campaña. |
tags |
Array |
No |
Tag para agregar información al cliente |
answers |
Clase |
Obligatorio |
Clase de pregunta |
Descripción |
question_id |
Integer |
Sí |
NPS, CSAT, Review, Elección Única, Pregunta Abierta, NPS secundario |
Id de la pregunta |
score |
String|Integer |
Sí |
NPS, CSAT, Review, NPS secundario |
Nota del cliente. |
justification |
String |
No |
NPS, CSAT, Review, NPS secundario |
Comentarios del cliente. |
option |
String |
No |
Elección Única |
Opción elegida por el cliente. Opcional solo si la pregunta está configurada como opcional. |
comment |
String |
Sí |
Pregunta Abierta |
Comentarios del cliente. |
Ejemplo de retorno:
{
"msg":"Number_of_answers Answer inserted",
"status": {
"invalid":Number_of_invalids,
"inserted":Number_of_insertions,
},
"answers": [
{
"answer_id": Answer_id,
"name": "Customers_name",
"email": "Customers_email",
"phone": Customers_phone,
"identification": "Customers_identification"
}
]
}
Ejemplos de código: Insertar Varias Respuestas
El orden de las respuestas debe ser el mismo orden que las preguntas definidas en la campaña. De lo contrario, la respuesta se considerará inválida.
Clase Http
POST /v2/answer HTTP/1.1
Host: api.tracksale
Content-Type: application/json
Authorization: bearer TOKEN
Cache-Control: no-cache
{
"campaign_code": "campaign_code",
"data": [
{
"name": "customers_name",
"email": "customers_email",
"phone": "customers_phoneemail",
"identification": "customers_identification",
"create_time": Timestamp_in_seconds,
"answers": [
{
"question_id": 12345,
"score": 10,
"justification": "NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "Review example"
},
{
"question_id": 12345,
"option": "Single Choice Question example"
},
{
"question_id": 12345,
"comment": "Open Question example"
},
{
"question_id": 12345,
"score": 10,
"justification": "Secondary NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "CSAT example"
}
],
"tags": [
{
"name": "TagExample",
"value": "TagExample"
}
]
}
]
}
Clase C(libCurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.tracksale.co/v2/answers");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "authorization: bearer TOKEN");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}");
CURLcode ret = curl_easy_perform(hnd);
Clase cURL
curl -X POST \
https://api.tracksale.co/v2/answers \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"campaign_code": "campaign_code",
"data": [
{
"name": "customers_name",
"email": "customers_email",
"phone": "customers_phoneemail",
"identification": "customers_identification",
"create_time": Timestamp_in_seconds,
"answers": [
{
"question_id": 12345,
"score": 10,
"justification": "NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "Review example"
},
{
"question_id": 12345,
"option": "Single Choice Question example"
},
{
"question_id": 12345,
"comment": "Open Question example"
},
{
"question_id": 12345,
"score": 10,
"justification": "Secondary NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "CSAT example"
}
],
"tags": [
{
"name": "TagExample",
"value": "TagExample"
}
]
}
]
}'
Clase C#
var client = new RestClient("https://api.tracksale.co/v2/answers");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "bearer TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Clase Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/answers"
payload := strings.NewReader("{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Clase Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}");
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/answers")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("authorization", "bearer TOKEN")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Clase Java Unirest
HttpResponse<String> response = Unirest.post("https://api.tracksale.co/v2/answers")
.header("content-type", "application/json")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.body("{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}")
.asString();
Clase JavaScript Jquery AJAX
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/answers",
"method": "POST",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
},
"data": "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Clase JavaScript XHR
var data = "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}";
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.tracksale.co/v2/answers");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "bearer TOKEN");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Clase NodeJS Native
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/answer",
"headers": {
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}");
req.end();
Clase NodeJS Request
var request = require("request");
var options = { method: 'POST',
url: 'https://api.tracksale.co/v2/answers',
headers:
{ 'cache-control': 'no-cache',
'authorization': 'bearer TOKEN',
'content-type': 'application/json' },
body: '{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Clase NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("POST", "https://api.tracksale.co/v2/answers");
req.headers({
"cache-control": "no-cache",
"authorization": "bearer TOKEN",
"content-type": "application/json"
});
req.send("{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}");
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Clase Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"content-type": @"application/json",
@"authorization": @"bearer TOKEN",
@"cache-control": @"no-cache" };
NSData *postData = [[NSData alloc] initWithData:[@"{
"campaign_code": "campaign_code",
"data": [
{
"name": "customers_name",
"email": "customers_email",
"phone": "customers_phoneemail",
"identification": "customers_identification",
"create_time": Timestamp_in_seconds,
"answers": [
{
"question_id": 12345,
"score": 10,
"justification": "NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "Review example"
},
{
"question_id": 12345,
"option": "Single Choice Question example"
},
{
"question_id": 12345,
"comment": "Open Question example"
},
{
"question_id": 12345,
"score": 10,
"justification": "Secondary NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "CSAT example"
}
],
"tags": [
{
"name": "TagExample",
"value": "TagExample"
}
]
}
]
}" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/answers"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Clase OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/answers" in
let headers = Header.init ()
|> fun h -> Header.add h "content-type" "application/json"
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "cache-control" "no-cache"
in
let body = Cohttp_lwt_body.of_string "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Clase PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/answers');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$request->setBody('{
"campaign_code": "campaign_code",
"data": [
{
"name": "customers_name",
"email": "customers_email",
"phone": "customers_phoneemail",
"identification": "customers_identification",
"create_time": Timestamp_in_seconds,
"answers": [
{
"question_id": 12345,
"score": 10,
"justification": "NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "Review example"
},
{
"question_id": 12345,
"option": "Single Choice Question example"
},
{
"question_id": 12345,
"comment": "Open Question example"
},
{
"question_id": 12345,
"score": 10,
"justification": "Secondary NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "CSAT example"
}
],
"tags": [
{
"name": "TagExample",
"value": "TagExample"
}
]
}
]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Clase PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"campaign_code": "campaign_code",
"data": [
{
"name": "customers_name",
"email": "customers_email",
"phone": "customers_phoneemail",
"identification": "customers_identification",
"create_time": Timestamp_in_seconds,
"answers": [
{
"question_id": 12345,
"score": 10,
"justification": "NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "Review example"
},
{
"question_id": 12345,
"option": "Single Choice Question example"
},
{
"question_id": 12345,
"comment": "Open Question example"
},
{
"question_id": 12345,
"score": 10,
"justification": "Secondary NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "CSAT example"
}
],
"tags": [
{
"name": "TagExample",
"value": "TagExample"
}
]
}
]
}');
$request->setRequestUrl('https://api.tracksale.co/v2/answers');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN',
'content-type' => 'application/json'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Clase PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/answers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Clase Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
payload = "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
conn.request("POST", "/v2/answer", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Clase Python requests
import requests
url = "https://api.tracksale.co/v2/answers"
payload = "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}"
headers = {
'content-type': "application/json",
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Clase Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/answers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'bearer TOKEN'
request["cache-control"] = 'no-cache'
request.body = "{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body
Clase Shell wget
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--body-data '{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}' \
--output-document \
- https://api.tracksale.co/v2/answers
Clase Shell Httpie
echo '{
"campaign_code": "campaign_code",
"answers":[
{
"name":"customers_name",
"email":"customers_Email",
"score":Customer_score,
"justification":"customers_comment",
"create_time":Timestamp_in_seconds,
"tags" : [
{
"name" : "TagExample",
"value" : "TagExample"
}
]
}
]
}' | \
http POST https://api.tracksale.co/v2/answers \
authorization:'bearer TOKEN' \
cache-control:no-cache \
content-type:application/json
Clase Shell cURL
curl --request POST \
--url https://api.tracksale.co/v2/answers \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{\n \"campaign_code\": \"campaign_code\",\n \"data\": [\n {\n \"name\": \"customers_name\",\n \"email\": \"customers_email\",\n \"phone\": \"customers_phoneemail\",\n \"identification\": \"customers_identification\",\n \"create_time\": Timestamp_in_seconds,\n \"answers\": [\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"NPS example\",\n \"tags\": [\n {\n \"name\": \"TagExample\",\n \"value\": \"TagExample\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"Review example\"\n },\n {\n \"question_id\": 12345,\n \"option\": \"Single Choice Question example\"\n },\n {\n \"question_id\": 12345,\n \"comment\": \"Open Question example\"\n },\n {\n \"question_id\": 12345,\n \"score\": 10,\n \"justification\": \"Secondary NPS example\",\n \"tags\": [\n {\n \"name\": \"TagSecondary\",\n \"value\": \"TagSecondary\"\n }\n ]\n },\n {\n \"question_id\": 12345,\n \"score\": 5,\n \"justification\": \"CSAT example\"\n }\n ]\n }\n ]\n}'
Clase Swift (NSURL)
import Foundation
let headers = [
"content-type": "application/json",
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
]
let postData = NSData(data: "{
"campaign_code": "campaign_code",
"data": [
{
"name": "customers_name",
"email": "customers_email",
"phone": "customers_phoneemail",
"identification": "customers_identification",
"create_time": Timestamp_in_seconds,
"answers": [
{
"question_id": 12345,
"score": 10,
"justification": "NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "Review example"
},
{
"question_id": 12345,
"option": "Single Choice Question example"
},
{
"question_id": 12345,
"comment": "Open Question example"
},
{
"question_id": 12345,
"score": 10,
"justification": "Secondary NPS example"
},
{
"question_id": 12345,
"score": 5,
"justification": "CSAT example"
}
],
"tags": [
{
"name": "TagExample",
"value": "TagExample"
}
]
}
]
}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/answers")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
Insertar Notas
También proporcionamos un método de inserción de notas. Este método se puede utilizar con los siguientes Parámetros.
- El método será:
POST
- La URL que se utilizará debe ser:
https://api.tracksale.co/v2/note
El body debe ser completado con la Nota usando el siguiente por defecto
Ejemplo de requisición:
{
"comment": "Comment_Text",
"answer_id": Answer_ID
}
Parámetros
Parámetro |
Clase |
Obligatorio |
Descripción |
comment |
String |
Sí |
Nota que se debe insertar |
answer_id |
Integer |
No |
Codigo de la Respuesta, sí no enviarlo necesario utilizar el filtro siguiente |
filter |
Array |
No |
Sí no enviar lo Codigo de la Respuesta, necesario utilizar este filtro |
Ejemplo de requisición:
{
"comment": "Comment_Text",
"filter": {
"email":"Customer_Email",
"start_date":"Start_Date",
"end_date":"End_date"
}
}
Filtro |
Clase |
Obligatorio |
Descripción |
email |
String |
No, pero para utilizar el filtro es necesario utilizar algun identificador (e-mail or phone or identification) |
Email del cliente |
phone |
String |
No, pero para utilizar el filtro es necesario utilizar algun identificador (e-mail or phone or identification) |
Teléfono del cliente |
identification |
String |
No, pero para utilizar el filtro es necesario utilizar algun identificador (e-mail or phone or identification) |
Identificador del cliente |
start_date |
Date |
No, pero la fecha es necesario para utilizar el filtro |
La fecha final se puede utilizar en formato AAAA-MM-DD. Ejemplo: 2017-01-31 |
end_date |
Date |
No, pero la fecha es necesario para utilizar el filtro |
La fecha final se puede utilizar en formato AAAA-MM-DD. Ejemplo: 2017-01-31 |
campaign_code |
String |
No |
Codigo de la campaña |
Ejemplo de retorno:
{
"msg":"Success",
"answer_id":123456
}
Proporcionamos un método de solicitud para llenar tags sin contenido. Este método se puede utilizar con los siguientes parámetros.
- El método será:
POST
- La URL a utilizar debe ser:
https://api.tracksale.co/v2/fill-empty-tags
El body debe ser enviado con las etiquetas a ser rellenadas en la respuesta, utilizando el siguiente patrón
Límites de envío:
1 cliente por solicitud.
Máximo de 50 etiquetas por solicitud.
Ejemplo de requisición:
{
"answer_id": Answer_ID,
"tags": [
{
"name": "Tag name",
"value": "Tag value"
},
{
"name": "Tag name",
"value": "Tag value"
}
]
}
Parámetros
Parámetro |
Clase |
Obligatorio |
Descripción |
answer_id |
Integer |
No |
Codigo de la Respuesta, sí no enviarlo necesario utilizar el customer siguiente |
tags |
Array |
Sí |
Sí no enviar lo Codigo de la Respuesta, necesario utilizar este filtro |
customer |
Array |
No |
Sí no enviar lo Codigo de la Respuesta, necesario utilizar este filtro: |
Tags |
Clase |
Obligatorio |
Descripción |
name |
String |
Sí |
Nombre de la tag |
value |
String |
Sí |
Valor de la Tag |
Ejemplo de requisición:
{
"campaign_code": "Campaign_code",
"customer": {
"email":"Customer_Email",
},
"tags": [
{
"name": "Tag name",
"value": "Tag value"
},
{
"name": "Tag name",
"value": "Tag value"
}
]
}
Customer |
Clase |
Obligatorio |
Descripción |
email |
String |
No, pero la fecha es necesario para utilizar el customer |
Email del cliente |
phone |
String |
No, pero la fecha es necesario para utilizar el customer |
Teléfono del cliente |
identification |
String |
No, pero la fecha es necesario para utilizar el customer |
Identificador del cliente |
campaign_code |
String |
No |
Codigo de la campaña |
Ejemplo de retorno:
{
"answer_id":12345,
"msg":"Request received successfully!"
}
Buscar lotes del rascunho
Para buscar los lotes del rascunho sí debe utilizar a seguinte configuración
- El método será:
GET
- La URL que se utilizará debe ser:
https://api.tracksale.co/v2/campaign/{code}/draft-lot
Este método es responsable de lista todos os lotes del rascunho de la campaña.
Dónde code es el codigo de la campaña que usted desea conseguir información.
Asegúrese de usar el parámetro code
.
Ejemplo de retorno:
{
"lot": [
{
"code": "Lot_code",
"create_time": "Create_Time",
"total_dispatches": "Total_dispatches",
}
]
}
Descartar lotes de rascunho
Para descartar os lotes de rascunho utilizaremos a seguinte configuração
- El método será:
POST
- La URL que se utilizará debe ser:
https://api.tracksale.co/v2/campaign/{code}/discard-lot/{lot_code}
Este método es responsable de descartar todos os lotes de rascunho da campanha.
Dónde lot_code es el codigo del lote que usted desea realizar lo descarte.
Asegúrese de usar el parámetro lot_code
.
Ejemplo de retorno:
{
"success": true
}
Reports es nuestro método para la generación de informes, es responsable de mostrar los detalles de todas sus campañas o de una campaña.
Toda la comunicación de la API se realiza desde la URL base
https://https://api.tracksale.co/v2/report/Detalles
.
Donde Detalles deberá ser sustituido por los detalles que usted desea obtener a través de un requerimiento
El método que se utilizará seráGET
El header se debe rellenar con los parámetros Donde
-
Key
Authorization
-
Value
bearer TOKEN
Comentarios
El método a ser usado debe ser:GET
La URL a ser usada debe ser:https://https://api.tracksale.co/v2/report/answer
Método responsable por devolver los comentarios de los clientes.
Parámetros:
Parámetro |
Clase |
Predeterminado |
Obligatorio |
Descripción |
start |
Date |
Predeterminadamente mostrará los resultados 30 dias anteriores a la fecha que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha inicial se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
end |
Date |
Predeterminadamente mostrará los resultados 30 dias anteriores a la fecha que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha final se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
limit |
Integer |
Predeterminadamente mostrará 10 Comentarios por requerimiento. |
No |
Total de Comentarios a serem retornados. Utilize -1 para retornar todos.
|
tags |
Boolean |
Predeterminadamente es falso, ou seja, nenhuma tag será mostrada. |
No |
Devuelve las tags referentes a las respuestas |
justifReturn |
String |
Predeterminadamente mostrará en el formato "level" |
No |
Formato de devolución de las justificaciones.
"array" - Devuelve todos en un único array.
"level" - Devuelve el formato JSON con subniveles de justificaciones agrupadas.
|
codes |
String |
Predeterminadamente mostrará los comentarios de todas las campañas |
No |
Usado para mostrar los comentarios de una campaña específica, o los comentarios de todas las campañas. Se puede mostrar tambien los comentarios de más de una campaña por vez, para esto utilice la coma como separador
(Por ejemplo: códigos=52,51,50 mostrará los comentarios de las campañas cuyo Campaign_code es
50, 51 y 52) |
review |
Integer |
Por defecto es 0, es decir, no se devuelven comentarios |
No |
Se utiliza para mostrar notas y comentarios para preguntas de Review. |
nps_secondary |
Integer |
Por defecto es 0, es decir, no se devuelven comentarios |
No |
Se utiliza para mostrar notas y comentarios para otras preguntas NPS además de la pregunta NPS obligatoria en cada campaña. |
open_question |
Integer |
Por defecto es 0, es decir, no se devuelven comentarios |
No |
Se utiliza para mostrar comentarios para preguntas de Pregunta Abierta. |
csat |
Integer |
Por defecto es 0, es decir, no se devuelven comentarios |
No |
Se utiliza para mostrar comentarios para preguntas de CSAT. |
return_update_time |
Boolean |
Por padráo es false |
No |
Devuelve la fecha de la última modificación realizada en la opinión, como cambios en el responsable, estado o categoría. |
Ejemplo de retorno:
[
{
"time": 1454340407,
"type": "Email",
"name": "Customers_name",
"email": "Customers_email",
"identification": null,
"phone": "Customers_phone",
"alternative_email": "Customers_email",
"alternative_phone": "Customers_phone",
"nps_answer": Score,
"last_nps_answer": Score,
"nps_comment": Comment,
"campaign_name": "Campaign_name",
"campaign_code": "Campaign_code",
"lot_code": "ABCDEFG123",
"id": 6805511,
"deadline": null,
"elapsed_time": 17,
"dispatch_time": null,
"reminder_time": null,
"status": "Status",
"priority": "None",
"assignee": "Assignee_name",
"picture": null,
"tags": [],
"categories": [],
"justifications": [],
"review": [],
"nps_secondary": [],
"open_question": [],
"csat": [],
"update_time": 1454340407
}
]
Disparos
El método a utilizar debe ser : GET
La URL que se utilizará debe ser:https://api.tracksale.co/v2/report/dispatch
Método responsable de devolver los disparos y sus datos, como clientes insertados, la hora que se realizó, su estado y los clientes que se han insertado en el mismo.
Ejemplo de retorno:
[
{
"campaign": {
"name": "Camapaign_name",
"code": "Campaign_code"
},
"dispatch_code": "Code_of_dispatch",
"status": Status_of_dispatch,
"create_time": "Campaign_creation_time",
"customers": [
{
"name": "Customers_name",
"identification": null,
"email": "Customers_email",
"phone": "Customers_phone",
"dispatch_time": "Code_of_dispatch",
"status": "Status_of_dispatch",
"has_answered": "Status_of_answer"
}
],
"channel": "Channel_of_dispatch"
}
]
Parámetros:
Parámetro |
Clase |
Predeterminado |
Obligatorio |
Descripción |
start |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha inicial se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
end |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha final se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
codes |
String |
Predeterminado mostrará os Comentarios de todos as campanhas |
No |
Utilizado para mostrar los comentarios de una campaña específica, o los staus de todos las campañas. Se puede también mostrar los comentarios de más de una campaña a la vez, para ello utilice la coma como separador
(Por ejemplo: códigos=52,51,50 mostrará los comentarios de las campañas cuyo Campaign_code es
50, 51 y 52) |
channel |
Boolean |
Por defecto es false, es decir, no devuelve el canal de los disparos. |
No |
Se utiliza para devolver el canal de envío de los disparos. Por ejemplo: Email, WhatsApp, SMS, etc. |
Disparos Paginados
El método a utilizar debe ser :GET
La URL que se utilizará debe ser: https://apiv3.track.co/dispatch
Método responsable de devolver de manera paginada los disparos y sus datos, como clientes insertados, la hora que se realizó, su estado y los clientes que se han insertado en el mismo.
Es posible devolver solo un lote de despacho específico, puedes hacerlo usando
Cuando Dispatch_code es el código del lote de envío del que desea obtener información.
Al filtrar por un código de despacho específico, se desconsiderarán los parámetros start
y end
.
Ejemplo de retorno:
{
"code": "Response_code",
"status": "Response_status",
"data":
[
{
"campaign":
{
"code": "Campaign_code",
"name": "Campaign_name"
},
"lot":
{
"create_time": "Campaign_creation_time",
"dispatch_code": "Code_of_dispatch",
"status": "Status_of_dispatch",
"channel": "Channel_of_dispatch"
},
"customer":
{
"name": "Customers_name",
"identification": null,
"email": "Customers_email",
"phone": "Customers_phone",
"dispatch_time": "Code_of_dispatch",
"status": "Status_of_dispatch",
"has_answered": "Status_of_answer",
"survey_opened": "Survey_opened"
},
}
]
}
Parámetros:
Parámetro |
Clase |
Predeterminado |
Obligatorio |
Descripción |
start |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha inicial se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
end |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha final se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
codes |
String |
Predeterminado mostrará os Comentarios de todos as campanhas |
No |
Utilizado para mostrar los comentarios de una campaña específica, o los staus de todos las campañas. Se puede también mostrar los comentarios de más de una campaña a la vez, para ello utilice la coma como separador
(Por ejemplo: códigos=52,51,50 mostrará los comentarios de las campañas cuyo Campaign_code es
50, 51 y 52) |
channel |
Boolean |
Por defecto es false, es decir, no devuelve el canal de los disparos. |
No |
Se utiliza para devolver el canal de envío de los disparos. Por ejemplo: Email, WhatsApp, SMS, etc. |
tags |
Boolean |
Por padráo es false, es decir, no devuelve tags de los disparos. |
No |
Se utiliza para devolver tags que hacen referencia a los disparos. Por ejemplo: Ciudad, Departamento, Producto, etc. |
page |
Integer |
Por padráo es igual a 1, es decir, devuelve la primera página de los disparos. |
1 |
Se utiliza para obtener una determinada página de los disparos. |
limit |
Integer |
Por padráo es igual a 100, devuelve hasta 100 registros por página. |
100 |
Se utiliza para controlar la cantidad de registros obtenidos en cada página, que puede variar de 100 a 10.000. |
NPS
El método a utilizar debe ser : GET
La URL que se utilizará debe ser: https://https://api.tracksale.co/v2/report/nps
La URL a ser utilizada debe ser:https://https://api.tracksale.co/v2/report/nps
El método responsable de devolver el número de disparos, los números de detractores, promotores y neutros y sus respectivos porcentajes y también el valor del nps.
Parámetros:
Parámetro |
Clase |
Predeterminado |
Obligatorio |
Descripción |
start |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
Fecha inicial de su consulta en el formato aaaa-mm-dd |
end |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
Fecha final de su consulta en el formato aaaa-mm-dd |
compare |
Boolean |
Por padráo es false |
No |
Retorna os dados do NPS referente ao período anterior do filtro de data.
|
codes |
String |
Predeterminadamente mostrará los comentarios de todas las campañas |
No |
Usado para mostrar los comentarios de una campaña específica, o los comentarios de todas las campañas. Se puede mostrar tambien los comentarios de más de una campaña por vez, para esto utilice la coma como separador
(Por ejemplo: códigos=52,51,50 mostrará los comentarios de las campañas cuyo Campaign_code es
50, 51 y 52) |
Ejemplo de retorno:
{
"dispatches": Number_of_dispatches,
"promoters": Number_of_promoter,
"detractors": Number_of_detractors,
"passives": Number_of_neutrals,
"detractors_percentage": Percentage_of_detractors,
"passives_percentage": Percentage_of_neutrals,
"promoters_percentage": Percentage_of_promoters,
"nps": Period_NPS,
"compare": {
"dispatches": Number_of_dispatches,
"promoters": Number_of_promoter,
"detractors": Number_of_detractors,
"passives": Number_of_neutrals,
"detractors_percentage": Percentage_of_detractors,
"passives_percentage": Percentage_of_neutrals,
"promoters_percentage": Percentage_of_promoters,
"nps": Period_NPS,
}
}
Categorías
El método a utilizar debe ser :GET
La URL que se utilizará debe ser: https://https://api.tracksale.co/v2/report/category
Método responsable de devolver las categorías de las campañas de acuerdo Con el NPS.
Parámetros:
Parámetro |
Clase |
Predeterminado |
Obligatorio |
Descripción |
start |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha inicial se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
end |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha final se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
codes |
String |
Predeterminado mostrará os Comentarios de todos as campanhas |
No |
Utilizado para mostrar los comentarios de una campaña específica, o los staus de todos las campañas. Se puede también mostrar los comentarios de más de una campaña a la vez, para ello utilice la coma como separador
(Por ejemplo: códigos=52,51,50 mostrará los comentarios de las campañas cuyo Campaign_code es
50, 51 y 52) |
Ejemplo de retorno:
[
{
"id": 6805511,
"name": "Product",
"color": "#F8D347",
"total": 25,
"nps": Period_NPS,
"total": total,
}
]
Obtener estado de las campañas
El método a utilizar debe ser :GET
La URL que se utilizará debe ser: https://https://api.tracksale.co/v2/report/status
A URL a ser usada debe ser: https://https://api.tracksale.co/v2/report/status
Método responsable de retornar el estado de las campañas.
Parámetros:
Parámetro |
Clase |
Predeterminado |
Obligatorio |
Descripción |
start |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha inicial se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
end |
Date |
Predeterminado mostrará los resultados 30 dias anteriores a data que está
realizando requerimiento (Ej: si usted está haciendo ese requerimiento el día 31/01/2017 y no incluir el intervalo inicial y final que usted desea hacer su investigación, el período retornado será de 01/01/2017 a 31/01/2017) |
No |
La fecha final se puede utilizar en formato AAAA-MM-DD o especificando la hora en formato AAAA-MM-DDTHH:mm:ss. Ejemplo: 2017-01-31T12:00:00 |
codes |
String |
Predeterminado mostrará os Comentarios de todos as campanhas |
No |
Utilizado para mostrar los comentarios de una campaña específica, o los staus de todos las campañas. Se puede también mostrar los comentarios de más de una campaña a la vez, para ello utilice la coma como separador
(Por ejemplo: códigos=52,51,50 mostrará los comentarios de las campañas cuyo Campaign_code es
50, 51 y 52) |
Ejemplo de retorno:
[
{
"id": 76,
"name": "Pendente Cliente",
"total": 25,
"color": "#F8D347"
}
]
Ejemplos de código : Reports /Detalles
Clase Http
GET /v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM HTTP/1.1
Host: api.tracksale
Authorization: bearer TOKEN
Cache-Control: no-cache
Clase C(libCurl)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
headers = curl_slist_append(headers, "authorization: bearer TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
Clase cURL
curl -X GET \
'https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM' \
-H 'authorization: bearer TOKEN' \
-H 'cache-control: no-cache'
Clase C#
var client = new RestClient("https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "bearer TOKEN");
IRestResponse response = client.Execute(request);
Clase Go
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("authorization", "bearer TOKEN")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Clase Java (OK HTTP)
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM")
.get()
.addHeader("authorization", "bearer TOKEN")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Clase Java Unirest
HttpResponse<String> response = Unirest.get("https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM")
.header("authorization", "bearer TOKEN")
.header("cache-control", "no-cache")
.asString();
Clase JavaScript Jquery AJAX
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM",
"method": "GET",
"headers": {
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Clase JavaScript XHR
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://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM");
xhr.setRequestHeader("authorization", "bearer TOKEN");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
Clase NodeJS Native
var http = require("https");
var options = {
"method": "GET",
"hostname": "api.tracksale.co",
"port": null,
"path": "/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM",
"headers": {
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
Clase NodeJS Request
var request = require("request");
var options = { method: 'GET',
url: 'https://api.tracksale.co/v2/report/DETALHES',
qs: { start: 'DATA_INICIO', end: 'DATA_FIM' },
headers:
{ 'cache-control': 'no-cache',
'authorization': 'bearer TOKEN' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Clase NodeJS NodeJS Unirest
var unirest = require("unirest");
var req = unirest("GET", "https://api.tracksale.co/v2/report/DETALHES");
req.query({
"start": "DATA_INICIO",
"end": "DATA_FIM"
});
req.headers({
"cache-control": "no-cache",
"authorization": "bearer TOKEN"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
Clase Objective-C (NSURL)
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"bearer TOKEN",
@"cache-control": @"no-cache" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Clase OCaml(coHttp)
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM" in
let headers = Header.init ()
|> fun h -> Header.add h "authorization" "bearer TOKEN"
|> fun h -> Header.add h "cache-control" "no-cache"
in
Client.call ~headers `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
Clase PHP HttpRequest
<?php
$request = new HttpRequest();
$request->setUrl('https://api.tracksale.co/v2/report/DETALHES');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'start' => 'DATA_INICIO',
'end' => 'DATA_FIM'
));
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Clase PHP pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://api.tracksale.co/v2/report/DETALHES');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
'start' => 'DATA_INICIO',
'end' => 'DATA_FIM'
)));
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'bearer TOKEN'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Clase PHP cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"authorization: bearer TOKEN",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Clase Python http.client(Python 3)
import http.client
conn = http.client.HTTPSConnection("api.tracksale.co")
headers = {
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
conn.request("GET", "/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Clase Python requests
import requests
url = "https://api.tracksale.co/v2/report/DETALHES"
querystring = {"start":"DATA_INICIO","end":"DATA_FIM"}
headers = {
'authorization': "bearer TOKEN",
'cache-control': "no-cache"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
Clase Ruby (NET::Http)
require 'uri'
require 'net/http'
url = URI("https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["authorization"] = 'bearer TOKEN'
request["cache-control"] = 'no-cache'
response = http.request(request)
puts response.read_body
Clase Shell wget
wget --quiet \
--method GET \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache' \
--output-document \
- 'https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM'
Clase Shell Httpie
http GET 'https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM' \
authorization:'bearer TOKEN' \
cache-control:no-cache
Clase Shell cURL
curl --request GET \
--url 'https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM' \
--header 'authorization: bearer TOKEN' \
--header 'cache-control: no-cache'
Clase Swift (NSURL)
import Foundation
let headers = [
"authorization": "bearer TOKEN",
"cache-control": "no-cache"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.tracksale.co/v2/report/DETALHES?start=DATA_INICIO&end=DATA_FIM")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()