Integración de Inventario
Es necesario proveer el token dentro de cada solicitud realizada hacia la Global Inventory API.
curl --location --request POST 'https://id.s.core.csnglobal.net/connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=464f4235-8052-4832-a5ea-6738021263fe' \
--data-urlencode 'client_secret=Cen/5ic8fYtGbHMD4lU8VYHZ5/sJsU/N4qrl9V2DIzU=' \
--data-urlencode 'grant_type=client_credentials'
fetch('https://id.s.core.csnglobal.net/connect/token', {
method: 'POST',
body: new URLSearchParams({
'client_id': '464f4235-8052-4832-a5ea-6738021263fe',
'client_secret': 'Cen/5ic8fYtGbHMD4lU8VYHZ5/sJsU/N4qrl9V2DIzU=',
'grant_type': 'client_credentials'
}),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
}).then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
...
async static void GetToken()
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://id.s.core.csnglobal.net/connect/token");
var request = new HttpRequestMessage(HttpMethod.Post, "");
var keyValues = new List<KeyValuePair<string, string>>();
keyValues.Add(new KeyValuePair<string, string>("client_id", "464f4235-8052-4832-a5ea-6738021263fe"));
keyValues.Add(new KeyValuePair<string, string>("client_secret", "Cen/5ic8fYtGbHMD4lU8VYHZ5/sJsU/N4qrl9V2DIzU="));
keyValues.Add(new KeyValuePair<string, string>("grant_type", "client_credentials"));
request.Content = new FormUrlEncodedContent(keyValues);
var response = await client.SendAsync(request);
string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
$client = new GuzzleHttp\Client();
$response = $client->request('POST', 'https://id.s.core.csnglobal.net/connect/token', [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded'
],
'form_params' => [
'client_id' => '464f4235-8052-4832-a5ea-6738021263fe',
'client_secret' => 'Cen/5ic8fYtGbHMD4lU8VYHZ5/sJsU/N4qrl9V2DIzU=',
'grant_type' => 'client_credentials',
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
Clientid: 464f4235-8052-4832-a5ea-6738021263fe
Secret Key: Cen/5ic8fYtGbHMD4lU8VYHZ5/sJsU/N4qrl9V2DIzU=
{
"Seller": {
"Identifier": " 4AA0C7A3-DE66-4F21-91E8-84CA5CD8C6F4"
},
},
Este Identificador debe ser utilizado en el nodo Seller al momento de gestionar el inventario.
Nombre: Automotora / Concesionaria de prueba
Id: CL-SELLER-99
El token de acceso de este resultado debe ser usado para todas las solicitudes.
Hemos disponibilizado un servicio que permite la administración del inventario. Con el mismo endpoint es posible publicar y actualizar avisos dentro de nuestro portal.
La API actualmente nos permite publicar vehículos asociados a las categorías Autos,Camionetas y 4x4, asi como Motos y Camiones para diferenciar cada categoría solo deben ajustar los valores en los atributos Recordtype y Type. A continuación, detallamos la información para cada categoría:
{
"Specification": {
"RecordType": "Autos, camionetas y 4x4"
},
"Type": "Car"
}
{
"Specification": {
"RecordType": "Motos"
},
"Type": "Bike"
}
{
"Specification": {
"RecordType": "Camiones"
},
"Type": "Truck"
}
A continuación, encontraran un ejemplo de cómo se debe enviar un vehículo a publicar:
curl --location --request POST 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}' \
--header 'Authorization: Bearer {access_token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"PublishingDestinations": [
{
"Name": "ChileAutos"
}
],
"Media": {
"Photos": [
{
"Url": "http://fotos.carplanet.mx/view/img/usedcars/hex99889/5fa300797e5ae/big/big_0.jpg",
"Order": "1"
},
{
"Url": "http://fotos.carplanet.mx/view/img/usedcars/hex99889/5fa300797e5ae/big/big_1.jpg",
"Order": "2"
},
{
"Url": "http://fotos.carplanet.mx/view/img/usedcars/hex99889/5fa300797e5ae/big/big_2.jpg",
"Order": "3"
}
]
},
"Seller": {
"Identifier": "4AA0C7A3-DE66-4F21-91E8-84CA5CD8C6F4"
},
"Specification": {
"RecordType": "Autos, camionetas y 4x4",
"Make": "Volkswagen",
"Model": "Polo",
"ReleaseDate": {
"Year": 2019
},
"Title": "VOLKSWAGEN POLO 2019 DESING SOUND 1.6L L4 105HP TM",
"ShortTitle": "VOLKSWAGEN POLO 2019",
"Attributes": [
{
"Name": "Color",
"Group": "Detalles",
"DisplayName": "Color",
"Value": "Blanco",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "DoorNumber",
"Group": "Detalles",
"DisplayName": "Puertas",
"Value": "4",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "BodyStyle",
"Group": "Detalles",
"Value": "SUV",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "FuelType",
"Group": "Detalles",
"Value": "Gas",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "GearType",
"Group": "Detalles",
"Value": "Autom\u00e1tica",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "TipoVehiculo",
"Group": "Detalles",
"DisplayName": "Tipo Vehiculo",
"Value": "Autos, Camionetas y 4x4",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "TipoCategoria",
"Group": "Detalles",
"DisplayName": "Tipo Categoria",
"Value": "Camioneta",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Aire Acondicionado",
"Group": "Equipamiento",
"DisplayName": "Aire Acondicionado",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Espejos Electricos",
"Group": "Equipamiento",
"DisplayName": "Espejos Electricos",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Frenos ABS",
"Group": "Equipamiento",
"DisplayName": "Frenos ABS",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Airbag",
"Group": "Equipamiento",
"DisplayName": "Airbag",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Cierre Centralizado",
"Group": "Equipamiento",
"DisplayName": "Cierre Centralizado",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Catalítico",
"Group": "Equipamiento",
"DisplayName": "Catalítico",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Llantas",
"Group": "Equipamiento",
"DisplayName": "Llantas",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Alarma",
"Group": "Equipamiento",
"DisplayName": "Alarma",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Radio",
"Group": "Equipamiento",
"DisplayName": "Radio",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Cilindrada",
"Group": "Equipamiento",
"DisplayName": "Cilindrada",
"Value": "1500",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
}
]
},
"Identifier": "55253bcc-b1f1-4c43-9c68-70669f6c2076",
"Type": "Car",
"ListingType": "Usado",
"SaleStatus": "In Stock",
"Registration": {
"Number": "ABCD12"
},
"Description": "",
"ExtendedProperties": [
{
"Name": "WhatsApp",
"Value": "+56990432865"
}
],
"Colours": [
{
"Location": "Exterior",
"Generic": "Grey",
"Name": "Gris"
},
{
"Location": "Interior",
"Generic": "Grey",
"Name": "Gris"
}
],
"OdometerReadings": [
{
"Value": 21968,
"UnitOfMeasure": "KM"
}
],
"PriceList": [
{
"Currency": "CLP",
"Amount": 224700
}
]
}'
fetch('http://globalinventorypublicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}', {
method: 'POST',
body: {
"PublishingDestinations": [
{
"Name": "ChileAutos"
}
],
"Media": {
"Photos": [
{
"Url": "http://fotos.carplanet.mx/view/img/usedcars/hex99889/5fa300797e5ae/big/big_0.jpg",
"Order": "1"
},
{
"Url": "http://fotos.carplanet.mx/view/img/usedcars/hex99889/5fa300797e5ae/big/big_1.jpg",
"Order": "2"
},
{
"Url": "http://fotos.carplanet.mx/view/img/usedcars/hex99889/5fa300797e5ae/big/big_2.jpg",
"Order": "3"
}
]
},
"Seller": {
"Identifier": "4AA0C7A3-DE66-4F21-91E8-84CA5CD8C6F4"
},
"Specification": {
"RecordType": "Autos, camionetas y 4x4",
"Make": "Volkswagen",
"Model": "Polo",
"ReleaseDate": {
"Year": 2019
},
"Title": "VOLKSWAGEN POLO 2019 DESING SOUND 1.6L L4 105HP TM",
"ShortTitle": "VOLKSWAGEN POLO 2019",
"Attributes": [
{
"Name": "Color",
"Group": "Detalles",
"DisplayName": "Color",
"Value": "Blanco",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "DoorNumber",
"Group": "Detalles",
"DisplayName": "Puertas",
"Value": "4",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "BodyStyle",
"Group": "Detalles",
"Value": "SUV",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "FuelType",
"Group": "Detalles",
"Value": "Gas",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "GearType",
"Group": "Detalles",
"Value": "Autom\u00e1tica",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "TipoVehiculo",
"Group": "Detalles",
"DisplayName": "Tipo Vehiculo",
"Value": "Autos, Camionetas y 4x4",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "TipoCategoria",
"Group": "Detalles",
"DisplayName": "Tipo Categoria",
"Value": "Camioneta",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Aire Acondicionado",
"Group": "Equipamiento",
"DisplayName": "Aire Acondicionado",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Espejos Electricos",
"Group": "Equipamiento",
"DisplayName": "Espejos Electricos",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Frenos ABS",
"Group": "Equipamiento",
"DisplayName": "Frenos ABS",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Airbag",
"Group": "Equipamiento",
"DisplayName": "Airbag",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Cierre Centralizado",
"Group": "Equipamiento",
"DisplayName": "Cierre Centralizado",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Catalítico",
"Group": "Equipamiento",
"DisplayName": "Catalítico",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Llantas",
"Group": "Equipamiento",
"DisplayName": "Llantas",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Alarma",
"Group": "Equipamiento",
"DisplayName": "Alarma",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Radio",
"Group": "Equipamiento",
"DisplayName": "Radio",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
},
{
"Name": "Cilindrada",
"Group": "Equipamiento",
"DisplayName": "Cilindrada",
"Value": "1500",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
}
]
},
"Identifier": "55253bcc-b1f1-4c43-9c68-70669f6c2076",
"Type": "Car",
"ListingType": "Usado",
"SaleStatus": "In Stock",
"Registration": {
"Number": "ABCD12"
},
"Description": "",
"ExtendedProperties": [
{
"Name": "WhatsApp",
"Value": "+56990432865"
}
],
"Colours": [
{
"Location": "Exterior",
"Generic": "Grey",
"Name": "Gris"
},
{
"Location": "Interior",
"Generic": "Grey",
"Name": "Gris"
}
],
"OdometerReadings": [
{
"Value": 21968,
"UnitOfMeasure": "KM"
}
],
"PriceList": [
{
"Currency": "CLP",
"Amount": 224700
}
]
},
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer {access_token}'
}
}).then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using Newtonsoft.Json;
...
async static void CreateVehicle()
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("Content-Type", 'application/json');
var vehicle = new Vehicle("property1", "property2", ...);
var json = JsonConvert.SerializeObject(vehicle);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var uri = "http://globalinventorypublicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}";
var response = await client.PostAsync(uri);
string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
$client = new GuzzleHttp\Client();
$response = $client->request('POST', 'http://globalinventorypublicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}', [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer {access_token}'
],
'body' => [
'Identifier' => '6C705713-52E6-447B-9FC2-C3C155EF41D0',
'Type' => 'CAR',
'ListingType' => 'USADO',
'SaleStatus' => 'In Stock',
'Description' => 'This is just a comment',
'Key' => 'Value',
'Key' => 'Value',
...
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
Es posible agregar videos a los avisos,para ello solo debes agregar al nodo Media la siguiente información:
"Videos": [
{
"Url": "https://myexample.com/file.mp4",
"Order": 1
}
]
Los videos deben cumplir con las siguientes especificaciones:
Es posible configurar el precio de un aviso tanto en moneda local (CLP) o en moneda extranjera (USD).
Ejemplo:
Moneda Local
"PriceList": [
{
"Currency": "CLP",
"Amount": 224700
}
]
Moneda extranjera (USD)
"PriceList": [
{
"Currency": "USD",
"Amount": 430000.0
}
]
Es posible agregar productos desde la API, para eso solo debes incluir el nombre de los mismos en el array tags. Para Chileautos, los productos disponbiles son:
"Tags": [
{
"Name": "premium"
},
{
"Name": "topspot"
},
{
"Name": "showcase"
}
]
Para consultar la disponibilidad de los productos deben usar el siguiente endpoint:
curl --location --request GET 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/customers/{seller_identifier}/products' \
--header 'Authorization: Bearer {access_token}' \
--header 'Content-Type: application/json' \
--data-raw ''
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/customers/{seller_identifier}/products', {
method: 'GET',
headers: {
'Authorization': 'Bearer {access_token}'
'Content-Type': 'application/json',
},
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using System.Threading.Tasks;
async static void Search()
{
//...
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("Content-Type", 'application/json');
string uri = 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/customers/{seller_identifier}/products';
HttpResponseMessage response = await client.GetAsync(uri);
string contentString = await response.Content.ReadAsStringAsync();
dynamic parsedJson = JsonConvert.DeserializeObject(contentString);
Console.WriteLine(parsedJson);
}
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/customers/{seller_identifier}/products', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access_token}'
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
El response de este endpoint nos entrega los detalles de los productos disponibles para el cliente:
{
"name": "Aviso Premium",//Nombre del Producto
"code": "Premium",//código que debo utilizar para agregarlo al aviso
"quantity": 20,
"available": 18, // disponibilidad
"countryCode": "CL",
"type": "Primary",
"vertical": null
}
Es posible agregar este producto a un aviso a través del nodo ExtendedProperties al momento de publicar. Se debe tener en cuenta la siguiente estructura del número telefónico:
Ejemplo:
"ExtendedProperties": [
{
"Name": "WhatsApp",
"Value": "+56990432865"
}
]
Para los atributos o especificaciones la informacion debe ser enviada de esta forma
{
"Name": "Airbag",
"Group": "Equipamiento",
"DisplayName": "Airbag",
"Value": "SI",
"DisplayOnDetailsPage": true,
"IsKeyAttribute": false,
"IsDeleted": false
}
Hemos habilitado un nuevo endpoint que les permitira actualizar algo especifico del aviso sin necesidad de enviar todo la información.
curl --location --request PATCH 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}' \
--header 'accept: */*' \
--header 'Content-Type: application/merge-patch+json' \
--header 'Authorization: Bearer {access_token}' \
--header 'x-seller-identifier: {seller_identifier}' \
--header 'Cookie: csncidcf=69DB9F96-EB3A-49F9-A600-50504FA6627E' \
--data-raw '{
"OdometerReadings":[
{
"Value":60000,
"UnitOfMeasure":"KM"
}
]
}'
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}', {
method: 'PATCH',
body: {
"OdometerReadings":[
{
"Value":60000,
"UnitOfMeasure":"KM"
}
]},
headers: {
'accept': '*/*',
'Content-Type': 'application/merge-patch+json',
'Authorization': 'Bearer {access_token}',
'x-seller-identifier': '{seller_identifier}',
'Cookie': 'csncidcf=69DB9F96-EB3A-49F9-A600-50504FA6627E'
}
}).then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using Newtonsoft.Json;
...
async static void CreateVehicle()
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("Content-Type", 'application/merge-patch+json');
client.DefaultRequestHeaders.Add("x-seller-identifier", '{seller_identifier}');
client.DefaultRequestHeaders.Add("Cookie", 'csncidcf=69DB9F96-EB3A-49F9-A600-50504FA6627E');
client.DefaultRequestHeaders.Add("accept", '*/*');
var vehicle = new Vehicle("property1", "property2", ...);
var json = JsonConvert.SerializeObject(vehicle);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var uri = "http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}";
var response = await client.PatchtAsync(uri);
string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
$client = new GuzzleHttp\Client();
$response = $client->request('PATCH', 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}', [
'headers' => [
'accept' => '*/*',
'Content-Type' => 'application/merge-patch+json',
'Authorization' => 'Bearer {access_token}',
'x-seller-identifier' => '{seller_identifier}',
'Cookie' => 'csncidcf=69DB9F96-EB3A-49F9-A600-50504FA6627E'
],
'body' => [
'SaleStatus' => 'In Stock',
'Description' => 'This is just a comment',
'Key' => 'Value',
'Key' => 'Value',
...
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
Hemos habilitado un endpoint para que la eliminación de los avisos sea mas sencilla.
curl --location --request DELETE 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}' \
--header 'accept: */*' \
--header 'Authorization: Bearer {access_token}' \
--header 'x-seller-identifier: {seller_identifier}' \
--header 'Cookie: csncidcf=69DB9F96-EB3A-49F9-A600-50504FA6627E'
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}', {
method: 'DELETE',
headers: {
'accept': '*/*',
'Authorization': 'Bearer {access_token}',
'x-seller-identifier': '{seller_identifier}',
'Cookie': 'csncidcf=69DB9F96-EB3A-49F9-A600-50504FA6627E'
}
}).then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using Newtonsoft.Json;
...
async static void CreateVehicle()
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("x-seller-identifier", '{seller_identifier}');
client.DefaultRequestHeaders.Add("Cookie", 'csncidcf=69DB9F96-EB3A-49F9-A600-50504FA6627E');
client.DefaultRequestHeaders.Add("accept", '*/*');
var uri = "http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}";
var response = await client.DeleteAsync(uri);
string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
$client = new GuzzleHttp\Client();
$response = $client->request('DELETE', 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/{InventoryIdentifier}', [
'headers' => [
'accept' => '*/*',
'Authorization' => 'Bearer {access_token}',
'x-seller-identifier' => '{seller_identifier}',
'Cookie' => 'csncidcf=69DB9F96-EB3A-49F9-A600-50504FA6627E'
]
]);
echo $response->getStatusCode(); // 200
Hemos habilitado un endpoint para puedas obtener el inventario de una sucursal especifica.
curl --location --request GET 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/active_items?page=1&limit=100' \
--header 'accept: */*' \
--header 'Content-Type: application/merge-patch+json' \
--header 'Authorization: Bearer {{token}}' \
--header 'x-seller-identifier: {{seller_identifier}}' \
--data-raw ''
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/active_items?page=1&limit=100', {
headers: {
'accept': '*/*',
'Content-Type': 'application/merge-patch+json',
'Authorization': 'Bearer {{token}}',
'x-seller-identifier': '{{seller_identifier}}'
}
});
})
using System.Net.Http.Headers;
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/active_items?page=1&limit=100");
request.Headers.Add("accept", "*/*");
request.Headers.Add("Authorization", "Bearer {{token}}");
request.Headers.Add("x-seller-identifier", "{{seller_identifier}}");
request.Content = new StringContent("");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/merge-patch+json");
HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/vehicles/active_items?page=1&limit=100');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headers = array();
$headers[] = 'Accept: */*';
$headers[] = 'Content-Type: application/merge-patch+json';
$headers[] = 'Authorization: Bearer {{token}}';
$headers[] = 'X-Seller-Identifier: {{seller_identifier}}';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
Al enviar el inventario, seguidamente los datos deben ser validados con el endpoint de especificaciones previamente gestionado.
curl --location --request GET 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/makes' \
--header 'Authorization: Bearer {access_token}' \
--header 'Content-Type: application/json' \
--data-raw ''
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/makes', {
method: 'GET',
headers: {
'Authorization': 'Bearer {access_token}'
'Content-Type': 'application/json',
},
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using System.Threading.Tasks;
async static void Search()
{
//...
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("Content-Type", 'application/json');
string uri = 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/makes';
HttpResponseMessage response = await client.GetAsync(uri);
string contentString = await response.Content.ReadAsStringAsync();
dynamic parsedJson = JsonConvert.DeserializeObject(contentString);
Console.WriteLine(parsedJson);
}
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/makes', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access_token}'
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
curl --location --request GET 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/makes/BMW/models' \
--header 'Authorization: Bearer {access_token}' \
--header 'Content-Type: application/json' \
--data-raw ''
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/makes/BMW/models', {
method: 'GET',
headers: {
'Authorization': 'Bearer {access_token}'
'Content-Type': 'application/json',
},
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
async static void Search()
{
//...
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("Content-Type", 'application/json');
string uri = 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/makes/BMW/models';
HttpResponseMessage response = await client.GetAsync(uri);
string contentString = await response.Content.ReadAsStringAsync();
dynamic parsedJson = JsonConvert.DeserializeObject(contentString);
Console.WriteLine(parsedJson);
}
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/makes/BMW/models', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access_token}'
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
curl --location --request GET 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/body_types' \
--header 'Authorization: Bearer {access_token}' \
--header 'Content-Type: application/json' \
--data-raw ''
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/body_types', {
method: 'GET',
headers: {
'Authorization': 'Bearer {access_token}'
'Content-Type': 'application/json',
},
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using System.Threading.Tasks;
async static void Search()
{
//...
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("Content-Type", 'application/json');
string uri = 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/body_types';
HttpResponseMessage response = await client.GetAsync(uri);
string contentString = await response.Content.ReadAsStringAsync();
dynamic parsedJson = JsonConvert.DeserializeObject(contentString);
Console.WriteLine(parsedJson);
}
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/body_types', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access_token}'
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
curl --location --request GET 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/fuel_types' \
--header 'Authorization: Bearer {access_token}' \
--header 'Content-Type: application/json' \
--data-raw ''
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/fuel_types', {
method: 'GET',
headers: {
'Authorization': 'Bearer {access_token}'
'Content-Type': 'application/json',
},
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using System.Threading.Tasks;
async static void Search()
{
//...
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("Content-Type", 'application/json');
string uri = 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/fuel_types';
HttpResponseMessage response = await client.GetAsync(uri);
string contentString = await response.Content.ReadAsStringAsync();
dynamic parsedJson = JsonConvert.DeserializeObject(contentString);
Console.WriteLine(parsedJson);
}
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/fuel_types', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access_token}'
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
curl --location --request GET 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/gear_types' \
--header 'Authorization: Bearer {access_token}' \
--header 'Content-Type: application/json' \
--data-raw ''
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/gear_types', {
method: 'GET',
headers: {
'Authorization': 'Bearer {access_token}'
'Content-Type': 'application/json',
},
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using System.Threading.Tasks;
async static void Search()
{
//...
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("Content-Type", 'application/json');
string uri = 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/gear_types';
HttpResponseMessage response = await client.GetAsync(uri);
string contentString = await response.Content.ReadAsStringAsync();
dynamic parsedJson = JsonConvert.DeserializeObject(contentString);
Console.WriteLine(parsedJson);
}
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/gear_types', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access_token}'
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
curl --location --request GET 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/colours' \
--header 'Authorization: Bearer {access_token}' \
--header 'Content-Type: application/json' \
--data-raw ''
fetch('http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/colours', {
method: 'GET',
headers: {
'Authorization': 'Bearer {access_token}'
'Content-Type': 'application/json',
},
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
using System;
using System.Net.Http;
using System.Threading.Tasks;
async static void Search()
{
//...
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", 'Bearer {access_token}');
client.DefaultRequestHeaders.Add("Content-Type", 'application/json');
string uri = 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/colours';
HttpResponseMessage response = await client.GetAsync(uri);
string contentString = await response.Content.ReadAsStringAsync();
dynamic parsedJson = JsonConvert.DeserializeObject(contentString);
Console.WriteLine(parsedJson);
}
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'http://globalinventory-publicapi.stg.core.csnglobal.net/v1/specifications/cl/car/colours', [
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access_token}'
]
]);
echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody(); // '{"Key":"Value", ...}'
var_export($response->json()); // Outputs the JSON decoded data
A través del navegador, visite esta URL para validar si su aviso fue publicado correctamente. Para ello será necesario:
http://ds-integration-ore.s.core.csnglobal.net/detalle/_/{{advert_identifier}}?site=encoauto.chileautos.cl
// Example
http://ds-integration-ore.s.core.csnglobal.net/detalle/_/63473424-0689-4DB1-A3BD-6724FEADD8F0?site=encoauto.chileautos.cl
Sabemos lo importante que es recibir de manera inmediata cada uno de los leads generados en el sitio, es por eso que ofrecemos la opción de integrarnos con tu sistema mediante el uso de webhooks.
Gracias a los webhooks, podrás recibir notificaciones HTTP en tiempo real sobre los leads que se generen en tus avisos. ¿ Como funciona? Veamos el siguiente diagrama:
Creación de un punto de conexión
Es responsabilidad de cada cliente proporcionar un punto de conexión real para que podamos enviar las notificaciones.
Tu punto de conexión debe tener la capacidad de procesar solicitudes HTTPS. Tu servidor debe tener un certificado TLS o SSL válido, correctamente configurado e instalado. No se admiten los certificados autofirmados.
Las notificaciones las enviamos a tu punto de conexión con una solicitud POST con una carga json que contiene toda la información del lead.
La autorización del HTTP POST para eso debes configurar tu punto de conexión con headers personalizados (fijos) específicos o parámetros query strings (fijos).
Ejemplo:
access_token: 123
Authorization: Basic abc
Configuración del punto de conexión
Una vez hayas finalizado tu desarrollo debes hacernos llegar email a soporte@chileautos.cl con la siguientes información:
1. Url del punto de conexión
2. Headers (en caso de que sea necesario)
3. Lista de agencias que estarán suscriptas a este punto de conexión.
La estructura de los leads se basa en este DTO carsales/csn-dto en particular esta estructura https://github.com/carsales/csn-dto/blob/master/Csn.Public.Dto/Lead/Lead.cs
using System;
using System.Collections.Generic;
namespace Csn.Public.Dto
{
public class Lead
{
public Lead()
{
Prospect = new Customer();
Environment = new Environment();
}
/* required */
public Guid Identifier { get; set; }
/* ISO Short two char country codes, e.g. AU, NZ, US etc. */
public string CountryCode { get; set; }
public Customer Seller { get; set; }
/* coded name provided for the company sending the lead e.g. CARSALES */
public string Source { get; set; }
/*
Type = [GENERAL, ITEM]
Should it be expected to have an item attached (ITEM) or not (GENERAL).
Note that ServiceRequests handle what services are being enquired on e.g. finance, insurance, service, sales etc.
Item.ListingType handles whether the item is new, used or demo etc.
*/
public string Type { get; set; }
/* Status = [New, Contact, Commitment, Sold, Lost, Duplicate, Unworkable] */
public string Status { get; set; }
public Environment Environment { get; set; }
public Customer Prospect { get; set; }
public string Comments { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime? ModifiedUtc { get; set; }
/*
Labels is replacing Tags, and provides a means to add labels of various types
Type = [Private, System, Device, User]
Value is used to denote the actual label itself.
*/
public List Labels { get; set; }
/* ServiceRequest.Type = [Finance, Insurance etc] */
public List ServiceRequests { get; set; }
public TelephoneCall PhoneCall { get; set; }
public Vehicle Item { get; set; }
public Vehicle TradeIn { get; set; }
public List History { get; set; }
public Assignment Assignment { get; set; }
public List ExtendedProperties { get; set; }
}
public class Assignment
{
public Guid? Identifier { get; set; }
public string Email { get; set; }
public string Name { get; set; }
public DateTime AssignedUtc { get; set; }
}
public class HistoryItem
{
public Guid? Identifier { get; set; }
public string Type { get; set; }
public DateTime CreatedUtc { get; set; }
public string Note { get; set; }
public string Status { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
public class Environment
{
/* location name of where the lead was submitted from */
public string Source { get; set; }
/* domain name of the site sending the lead */
public string Url { get; set; }
/* IP address of the users device submitting the lead - helpful in tracking spam etc. */
public string IpAddress { get; set; }
/* an identifier of the session for the user submitting the lead - assists with lead tracking */
public string SessionId { get; set; }
}
}
{
"identifier": "00000000-0000-0000-0000-000000000000",
"uniqueIdentifier": null,
"id": 0,
"country": null,
"tenant": null,
"itemId": null,
"sellerId": null,
"service": null,
"leadType": null,
"requestType": null,
"itemType": null,
"environment": {
"source": null,
"url": null,
"ipAddress": null,
"sessionId": null
},
"prospect": {
"title": null,
"firstName": null,
"lastName": null,
"companyName": null,
"email": null,
"suburb": null,
"state": null,
"postcode": null,
"mobilePhone": null,
"homePhone": null,
"workPhone": null,
"identificationNumbers": [
{
"type": null,
"value": null
}
],
"memberTrackingId": "00000000-0000-0000-0000-000000000000"
},
"subscription": {
"newsletter": false,
"financeQuote": false,
"insuranceQuote": false,
"confirmResponse": false,
"survey": false
},
"tradeIn": {
"make": null,
"model": null,
"year": null,
"kms": null,
"detailsUrl": null,
"colour": null,
"type": null
},
"extendedProperties": [
{
"name": null,
"value": null
}
],
"fraudInfo": {
"ServerVariables": [
{
"Key": null,
"Value": null
}
]
},
"comments": null,
"created": "0001-01-01T00:00:00",
"tags": [null],
"item": {
"id": null,
"make": null,
"model": null,
"description": null,
"year": null,
"price": null,
"spotId": null,
"registrationNumber": null,
"transmission": null,
"colour": null,
"bodyType": null,
"odometer": null,
"fuelType": null,
"detailsUrl": null,
"identifier": null,
"photoPath": null,
"engineDescription": null
},
"history": [
{
"identifier": null,
"type": null,
"createdUtc": "0001-01-01T00:00:00",
"note": null,
"status": null,
"name": null,
"email": null
}
],
"assignment": {
"identifier": null,
"email": null,
"name": null,
"assignedUtc": "0001-01-01T00:00:00"
},
"status": null,
"labels": [{
"type": null,
"value": null
}
],
"serviceRequests": [
{
"type": null,
"value": null
}
],
"createdUtc": "0001-01-01T00:00:00",
"modifiedUtc": null
}
{
"identifier": "83ff5b22-5767-4759-bb6b-aab13c28992b",
"uniqueIdentifier": "448b6a1c-cd6c-44aa-9ff1-f05f150831aa",
"id": 0,
"country": "CL",
"tenant": "chileautos",
"itemId": "CP-AD-7948621",
"sellerId": "58d7f9e1-59c1-401f-bf51-9cdf44c4b8b5",
"service": "chileautos",
"leadType": "Usado",
"requestType": null,
"itemType": "CAR",
"environment": {
"source": "chileautos",
"url": "https://chileautos.cl /vehiculos/detalles/2018-nissan-np300-np-300-xe-2-3-mt-4x2-dsl-dc-e5-jyvj37/CP-AD-7948621/?Cr=1",
"ipAddress": "181.42.18.41",
"sessionId": null
},
"prospect": {
"title": "2018 Nissan Np300 NP 300 XE 2.3 MT 4X2 DSL DC E5 JYVJ37",
"firstName": "Deidy",
"lastName": "Perez",
"email": "deidy.perez@carsales.com",
"suburb": null,
"state": null,
"postcode": null,
"mobilePhone": "+56951063788",
"homePhone": null,
"workPhone": null,
"identificationNumbers": [
{
"type": "RUT",
"value": "11111111-1"
}
],
"memberTrackingId": "00000000-0000-0000-0000-000000000000"
},
"extendedProperties": [
{
"name": "TRIGGERSECTION",
"value": "topright"
},
{
"name": "SellerId",
"Value": "CL-SELLER-99"
},
{
"name": "NetworkId",
"value": "CP-AD-7948621"
}
],
"comments": "Esto es una prueba, no contactar",
"created": "2022-03-16T22:29:47.902934Z",
"item": {
"id": "CP-AD-7948621",
"make": "Nissan",
"model": "Np300",
"description": "2018 Nissan Np300 NP 300 XE 2.3 MT 4X2 DSL DC E5 JYVJ37",
"year": 2018,
"price": 30500000,
"registrationNumber": "ABCD12",
"transmission": "Manual",
"colour": "Black",
"bodyType": "SUV",
"odometer": 2550,
"fuelType": "Bencina",
"detailsUrl": "https://chileautos.cl /vehiculos/detalles/2018-nissan-np300-np-300-xe-2-3-mt-4x2-dsl-dc-e5-jyvj37/CP-AD-7948621/?Cr=1",
"identifier": "fdea1e50-1108-4842-a6c4-5af1f5903aa0",
"photoPath": "/cars/dealer/48qcu14si23njjiuxg3rykx23.jpg"
},
"status": "New",
"createdUtc": "2022-10-04T18:25:12.2",
"modifiedUtc": "0001-01-01T00:00:00"
}
Dependiendo de los servicios contratados podrás recibir leads de diferentes fuentes, entre estas fuentes tenemos:
Chileautos: Son los leads que provienen de nuestro sitio.
WhatsApp: Son los leads generados mediante nuestro servicio de Whatsapp Premium.
Para diferenciar uno de otro solo es necesario validar la información incluida en el campo Source
Solicitud inválida
Falla de autenticación / credenciales erróneas
El servidor aceptó y completó la solicitud como se esperaba.
El servidor falló al intentar completar la solicitud debido a un error interno.
El servicio solicitado no está disponible.
Para más información, por favor escribir a soporte@chileautos.cl