Exemplo 5 – Integração com a Trip API
O serviço Freight API pode ser utilizado de forma integrada com a Trip API. O processo consiste em apenas adicionar os parâmetros da Freight API no body da requisição para a Trip API.
Não será necessário incluir o parâmetro distance, já que a própria Trip API fornecerá a informação da distância percorrida.
O exemplo a seguir exibe uma requisição de um rota entre São Paulo – SP e Campinas – SP, a ser percorrida por um caminhão com 4 eixos duplos, incluindo cálculo de pedágios e frete (Carga: Granel sólido / Tipo de operação: D).
Endpoint utilizado: https://api.maplink.global/trip/v1/problems (Método: POST)
A requisição completa encontra-se abaixo:
{ "calculationMode": "THE_FASTEST", "points": [ { "latitude": -23.566329, "longitude": -46.653690, "siteId": "SP" }, { "latitude": -22.910884, "longitude": -47.066027, "siteId": "CAMPINAS" } ], "toll": { "vehicleType": "TRUCK_WITH_FOUR_DOUBLE_AXLES" }, "freight": { "operationType": [ "D" ], "goodsType": [ "GRANEL_SOLIDO" ], "axis": [ "4" ], "roundTrip": false, "backEmpty": false, "otherCosts": [ { "name": "ICMS", "type": "PERCENT", "value": "5" }, { "name": "Lucro", "type": "PERCENT", "value": "20" }, { "name": "TaxaFixa", "type": "FIXED", "value": "500" } ], "date": "2021-10-02" } }
Onde:
- O parâmetro
points
contém as coordenadas para uma roteirização simples entre São Paulo e Campinas; - O parâmetro
toll
contém os dados dos pedágios presentes na rota;. - O parâmetro
freight
contém os dados do frete mínimo para a rota.
{ "id": "65835380bb432a18819d6555", "clientId": "maplink", "totalDistance": 95119, "totalNominalDuration": 5281, "averageSpeed": 51.30, "tollCosts": 98.40, "routeFreightCost": 335232.70, "legs": [ { "distance": 95118, "nominalDuration": 5281, "averageSpeed": 51.3, "points": "vxynCl`w{G_B{AkEgEaEhFiGhIqBgC}@y@mGoC_D{A_@_@[q@eAaC_BsDqDgFkFVk@KMYSWa@Q]E{@gAk@o@q@g@sCwAcGkCsB{@QAa@Uw@o@_@m@Oc@y@wDi@wByCeJqCgHUu@OcAK}@CeAD_A@o@Ko@Ok@k@_Ac@e@YSeC{As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`CaJ|EoBjAaEzBoV|M{JnFiB|@uCbB{JnFeBx@oFdCkG~BeCz@eCt@uO|DgFtAaCz@_C`AiD~AwJdFkPbJeHtDgNnHcExBwHfEwLrGiJ`FwKhGoJhFqLlGiSxKyDpBoPpJqPjK{V~OmLlHuSjMgG|DsHzE}FrDeOlJuGxDuM|GcPvHcFdC_A^kHjDoKdFiOfHiGtCuI`E{DbBeFhCmFdCsG|Ce^xP}MnG}G`DqMhGePvHuI~DoAXaI~Ca@N_@HoB~@kBbA{CtAcPxHeGnCkDbBeCzAyFbEuAt@YLYHc@DYAiAQ_BIaBAq@Me@[[WOGIKi@u@u@o@gJqFoN{HqBq@kBg@aL_Cm@OaFkAA?mAYuFkAeMkCuD{@mGwAyBo@i@I]OoCy@m@_@gIkBoAKmBYsAGCVy@rD_BdJlCj@", "tollCalculation": { "tolls": [ { "id": "13", "name": "Pedágio - Campo Limpo", "address": "SP 348 - Rod. dos Bandeirantes - Km 39", "city": "Cajamar", "state": { "name": "São Paulo", "code": "SP" }, "country": "Brasil", "concession": "Autoban", "direction": "NORTH", "coordinates": { "latitude": -23.3260346, "longitude": -46.8231453 }, "serviceTypes": [ { "serviceId": "48", "name": "Via Facil" }, { "serviceId": "35351600323810101", "name": "ANTTCODE" } ], "price": 49.60 }, { "id": "73", "name": "Pedágio - Valinhos Norte", "address": "SP 330 - Rod. Anhanguera - Km 82 Valinhos", "city": "Valinhos", "state": { "name": "São Paulo", "code": "SP" }, "country": "Brasil", "concession": "Autoban", "direction": "NORTHWEST", "coordinates": { "latitude": -23.01295484, "longitude": -47.0230555 }, "serviceTypes": [ { "serviceId": "50", "name": "Via Facil" }, { "serviceId": "35353300820000101", "name": "ANTTCODE" } ], "price": 48.80 } ], "legTotalCost": 98.40, "vehicleType": "TRUCK_WITH_FOUR_DOUBLE_AXLES" } } ], "freight": { "source": "RESOLUÇÃO No 5.949, DE 13 DE JULHO DE 2021", "results": { "D": { "4": { "GRANEL_SOLIDO": { "value": 267707.43, "otherCosts": { "ICMS": 13385.38, "Lucro": 53541.49, "TaxaFixa": 500 } } } } }, "minimumFreight": 267707.43, "minimumFreightWithCosts": 335134.30 }, "source": "MAPLINK" }