Despachos
Generación de documentos despacho. (Guías de despacho electrónicas), listar despachos generados, detalles incluidos en el despacho. Un despacho, siempre genera una salida de stock cuando hablamos de controlarlo.
Estructura JSON
Al realizar una petición HTTP, el servicio retornara un JSON con la siguiente estructura:
{
"href": "https://api.bsale.cl/v1/shippings/22.json",
"id": 22,
"shippingDate": 1370318400,
"address": null,
"municipality": "",
"city": "",
"recipient": null,
"state": 0,
"office": {
"href": "https://api.bsale.cl/v1/offices/1.json",
"id": "1"
},
"shipping_type": {
"href": "https://api.bsale.cl/v1/shipping_types/1.json",
"id": "1"
},
"guide": {
"href": "https://api.bsale.cl/v1/documents/23.json",
"id": "23"
},
"details": {
"href": "https://api.bsale.cl/v1/shippings/22/details.json"
}
}
href, url del despacho (String).
id, identificador único del despacho (Integer).
shippingDate, fecha del despacho (Integer).
address, dirección del despacho (String).
municipality, comuna del despacho (String).
city, ciudad del despacho (String).
recipient, destinatario del despacho (String).
state, estado del descuento indica si el descuento esta activo(0) o inactivo (1) (Boolean).
office, nodo que indica la relación con la sucursal en la que fue emitida el despacho.
shipping_type, nodo que indica la relación con el tipo de despacho.
guide, nodo que indica el documento guía de despacho.
details, nodo que indica los detalles del despacho.
GET lista de despachos
GET /v1/shippings.json retornara todos los despachos.
Parámetros
limit, limita la cantidad de items de una respuesta JSON, por defecto el limit es 25, el máximo permitido es 50.
offset, permite paginar los items de una respuesta JSON, por defecto el offset es 0.
fields, solo devolver atributos específicos de un recurso
expand, permite expandir instancias y colecciones.
shippingdate, Permite filtrar por fecha de devolución.
officeid, Permite filtrar por sucursal.
shippingtypeid, filtra por documento de referencia.
state, boolean (0 o 1) indica si los documentos están activos(0) inactivos (1).
Ejemplos
GET /v1/shippings.json?limit=10&offset=0
GET /v1/shippings.json?fields=[shippingdate,recipient]
GET /v1/shippings.json?expand=[guide,shipping_type,details]
Respuesta
{
"href": "https://api.bsale.cl/v1/shippings.json",
"count": 13430,
"limit": 3,
"offset": 0,
"items": [
{
"href": "https://api.bsale.cl/v1/shippings/22.json",
"id": 22,
"shippingDate": 1370318400,
"address": null,
"municipality": "",
"city": "",
"recipient": null,
"state": 0,
"office": {
"href": "https://api.bsale.cl/v1/offices/1.json",
"id": "1"
},
"shipping_type": {
"href": "https://api.bsale.cl/v1/shipping_types/1.json",
"id": "1"
},
"guide": {
"href": "https://api.bsale.cl/v1/documents/23.json",
"id": "23"
},
"details": {
"href": "https://api.bsale.cl/v1/shippings/22/details.json"
}
},
{
"href": "https://api.bsale.cl/v1/shippings/23.json",
"id": 23,
"shippingDate": 1370318400,
"address": null,
"municipality": "",
"city": "",
"recipient": null,
"state": 0,
"office": {
"href": "https://api.bsale.cl/v1/offices/1.json",
"id": "1"
},
"shipping_type": {
"href": "https://api.bsale.cl/v1/shipping_types/1.json",
"id": "1"
},
"guide": {
"href": "https://api.bsale.cl/v1/documents/24.json",
"id": "24"
},
"details": {
"href": "https://api.bsale.cl/v1/shippings/23/details.json"
}
},
{
"href": "https://api.bsale.cl/v1/shippings/24.json",
"id": 24,
"shippingDate": 1370318400,
"address": null,
"municipality": "",
"city": "",
"recipient": null,
"state": 0,
"office": {
"href": "https://api.bsale.cl/v1/offices/1.json",
"id": "1"
},
"shipping_type": {
"href": "https://api.bsale.cl/v1/shipping_types/1.json",
"id": "1"
},
"guide": {
"href": "https://api.bsale.cl/v1/documents/25.json",
"id": "25"
},
"details": {
"href": "https://api.bsale.cl/v1/shippings/24/details.json"
}
}
]
}
GET único despacho
GET /v1/shippings/22.json retornara un despacho específico.
Parámetros
expand, permite expandir instancias y colecciones.
Ejemplos
GET /v1/shippings/1.json?expand=[details]
Respuesta
{
"href": "https://api.bsale.cl/v1/shippings/22.json",
"id": 22,
"shippingDate": 1370318400,
"address": null,
"municipality": "",
"city": "",
"recipient": null,
"state": 0,
"office": {
"href": "https://api.bsale.cl/v1/offices/1.json",
"id": "1"
},
"shipping_type": {
"href": "https://api.bsale.cl/v1/shipping_types/1.json",
"id": "1"
},
"guide": {
"href": "https://api.bsale.cl/v1/documents/23.json",
"id": "23"
},
"details": {
"href": "https://api.bsale.cl/v1/shippings/22/details.json"
}
}
GET detalles de un despacho
GET /v1/shippings/22/details.json
{
"href": "https://api.bsale.cl/v1/shippings/22/details.json",
"count": 1,
"limit": 25,
"offset": 0,
"items": [
{
"href": "https://api.bsale.cl/v1/shippings/22/details/31.json",
"id": 31,
"quantity": 1.0,
"variantStock": 28.0,
"variantCost": 0.0,
"variant": {
"href": "https://api.bsale.cl/v1/variants/8.json",
"id": "8"
}
}
]
}
GET un detalle de un despacho
GET /v1/shippings/22/details/31.json
{
"href": "https://api.bsale.cl/v1/shippings/22/details/31.json",
"id": 31,
"quantity": 1.0,
"variantStock": 28.0,
"variantCost": 0.0,
"variant": {
"href": "https://api.bsale.cl/v1/variants/8.json",
"id": "8"
}
}
POST un despacho
POST /v1/shippings.json
Se debe enviar un Json con la siguiente estructura.
{
"documentTypeId": 7,
"officeId": 1,
"emissionDate": 1462527931,
"shippingTypeId": 6,
"municipality": "Puerto Varas",
"city": "Puerto Varas",
"address": "la quebrada 1005",
"declareSii": 1,
"recipient": "Edison Packard",
"details": [
{
"quantity": 500,
"code": "1372685554",
"netUnitValue": 12000
}
],
"client": {
"code": "1-7",
"municipality": "Puerto Montt",
"activity": "Arriendo de maquinaria pesada",
"company": "Maquinarías Express",
"city": "PUERTO MONTT",
"email": "apidespachos@bsale.cl",
"address": "Los Alamos #122"
}
}
Respuesta
{
"href": "https://api.bsale.cl/v1/shippings/1554.json",
"id": 1554,
"shippingDate": 1576454400,
"address": "la quebrada 1005",
"municipality": "Puerto Varas",
"city": "Puerto Varas",
"recipient": "Edison Packard",
"state": 0,
"office": {
"href": "https://api.bsale.cl/v1/offices/1.json",
"id": "1"
},
"user": {
"href": "https://api.bsale.cl/v1/users/257.json",
"id": "257"
},
"shipping_type": {
"href": "https://api.bsale.cl/v1/shipping_types/6.json",
"id": "6"
},
"guide": {
"href": "https://api.bsale.cl/v1/documents/61716.json",
"id": "61716"
},
"details": {
"href": "https://api.bsale.cl/v1/shippings/1554/details.json"
}
}
Si se desea generar una guía a partir de otro documento, se debe enviar el identificador del detalle del documento original:
{
"details": [
{
"detailId": 105,
"quantity": 1
}
],
}
Si se desea generar una guía de traslado interno, se debe agregar al envío
{
"officeId": 1,
"destinationOfficeId":3,
"shippingTypeId": 5
}
officeId, Id de sucursal de origen (integer)
destinationOfficeId, Id de la sucursal de destino, quien recepcionará la guía (integer).
shippingTypeId, id del tipo de despacho asociado a traslado interno (integer).
Ejemplos de casos usando Postman
POST Despacho
Caso 1: Detalles usando SKU
POST Despacho
Caso 2: Detalles usando glosas
POST Despacho
Caso 3: Traslado interno
POST Despacho
Caso 4: Despacho a partir de existente