{"id":2758,"date":"2023-12-20T21:02:36","date_gmt":"2023-12-20T21:02:36","guid":{"rendered":"https:\/\/developers.maplink.global\/example-6-integration-with-the-toll-for-maps-api\/"},"modified":"2024-03-04T13:28:28","modified_gmt":"2024-03-04T13:28:28","slug":"example-6-integration-with-the-toll-for-maps-api","status":"publish","type":"post","link":"https:\/\/developers.maplink.global\/en\/example-6-integration-with-the-toll-for-maps-api\/","title":{"rendered":"Example 6 &#8211; Integration with the Toll for Maps API"},"content":{"rendered":"\n<p>The Freight API service can be integrated with the <a href=\"https:\/\/developers.maplink.global\/en\/building-requests-for-the-toll-for-maps-api\/\" data-type=\"post\" data-id=\"1151\">Toll for Maps API<\/a>, so in addition to the return of toll rates, the freight calculation will also be provided.<\/p>\n\n<p>The process consists of simply adding the Freight API parameters to the body of the request to the Toll for Maps APIs.  <\/p>\n\n<p>You don&#8217;t need to include the parameter <code>distance<\/code>, as the distance traveled will already be in the Directions API response.<\/p>\n\n<p>The following example shows a request for a route between S\u00e3o Paulo &#8211; SP and Campinas &#8211; SP, to be traveled by a truck with 4 double axles, including calculation of tolls and freight (Cargo: Solid bulk \/ Type of operation: D).  <\/p>\n\n<p><strong>Endpoint used:<\/strong><a href=\"https:\/\/api.maplink.global\/toll\/v1\/directions?vehicleType=%7BTIPO_VEICULO%7D\">https:\/\/api.maplink.global\/toll\/v1\/directions?vehicleType={TIPO_VEICULO}<\/a> (M\u00e9todo: <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">POST<\/mark><\/strong>)<\/p>\n\n<p>The body of the request must contain the <a href=\"https:\/\/developers.google.com\/maps\/documentation\/directions\/overview?hl=pt-br\" data-type=\"link\" data-id=\"https:\/\/developers.google.com\/maps\/documentation\/directions\/overview?hl=pt-br\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Directions API<\/a> response, plus the Freight API parameters, as shown in the example below:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \/\/Resposta da Directions API \n    \"maplink\": {\n        \"freight\": {\n            \"operationType\": [\n                \"D\"\n            ],\n            \"goodsType\": [\n                \"GRANEL_SOLIDO\"\n            ],\n            \"axis\": [\n                \"4\"\n            ],\n            \"roundTrip\": false,\n            \"backEmpty\": false,\n            \"otherCosts\": [\n                {\n                    \"name\": \"ICMS\",\n                    \"type\": \"PERCENT\",\n                    \"value\": \"5\"\n                },\n                {\n                    \"name\": \"Lucro\",\n                    \"type\": \"PERCENT\",\n                    \"value\": \"20\"\n                },\n                {\n                    \"name\": \"TaxaFixa\",\n                    \"type\": \"FIXED\",\n                    \"value\": \"500\"\n                }\n            ],\n            \"date\": \"2021-10-02\"\n        }\n    }\n}<\/pre>\n\n<p>The full response can be found below:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"results\": [\n        {\n            \"legs\": [\n                {\n                    \"tolls\": [\n                        {\n                            \"id\": \"13\",\n                            \"name\": \"Ped\u00e1gio - Campo Limpo\",\n                            \"address\": \"SP 348 - Rod. dos Bandeirantes\",\n                            \"city\": \"Campo Limpo\",\n                            \"state\": {\n                                \"name\": \"S\u00e3o Paulo\",\n                                \"code\": \"SP\"\n                            },\n                            \"country\": \"Brasil\",\n                            \"concession\": \"Autoban\",\n                            \"direction\": \"NORTH\",\n                            \"coordinates\": {\n                                \"latitude\": -23.3260346,\n                                \"longitude\": -46.8231453\n                            },\n                            \"serviceTypes\": [\n                                {\n                                    \"serviceId\": \"48\",\n                                    \"name\": \"Via Facil\"\n                                },\n                                {\n                                    \"serviceId\": \"35353480390470101\",\n                                    \"name\": \"ANTTCODE\"\n                                }\n                            ],\n                            \"price\": 31.80\n                        },\n                        {\n                            \"id\": \"73\",\n                            \"name\": \"Ped\u00e1gio - Valinhos Norte\",\n                            \"address\": \"SP 330 - Rod. Anhanguera Km 82\",\n                            \"city\": \"Valinhos\",\n                            \"state\": {\n                                \"name\": \"S\u00e3o Paulo\",\n                                \"code\": \"SP\"\n                            },\n                            \"country\": \"Brasil\",\n                            \"concession\": \"Autoban\",\n                            \"direction\": \"NORTHWEST\",\n                            \"coordinates\": {\n                                \"latitude\": -23.01295484,\n                                \"longitude\": -47.0230555\n                            },\n                            \"serviceTypes\": [\n                                {\n                                    \"serviceId\": \"50\",\n                                    \"name\": \"Via Facil\"\n                                },\n                                {\n                                    \"serviceId\": \"35353300820000101\",\n                                    \"name\": \"ANTTCODE\"\n                                }\n                            ],\n                            \"price\": 31.50\n                        }\n                    ],\n                    \"legTotalCost\": 63.30\n                }\n            ],\n            \"freight\": {\n                \"source\": \"RESOLU\u00c7\u00c3O No 5.949, DE 13 DE JULHO DE 2021\",\n                \"results\": {\n                    \"D\": {\n                        \"4\": {\n                            \"GRANEL_SOLIDO\": {\n                                \"value\": 369.97,\n                                \"otherCosts\": {\n                                    \"ICMS\": 18.50,\n                                    \"Lucro\": 74.00,\n                                    \"TaxaFixa\": 500\n                                }\n                            }\n                        }\n                    }\n                },\n                \"minimumFreight\": 369.97,\n                \"minimumFreightWithCosts\": 962.47\n            },\n            \"totalCost\": 63.30,\n            \"routeFreightCost\": 1025.77\n        }\n    ]\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Freight API service can be integrated with the Toll for Maps API, so in addition to the return of toll rates, the freight calculation will also be provided. The process consists of simply adding the Freight API parameters to the body of the request to the Toll for Maps APIs. You don&#8217;t need to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[167],"tags":[],"class_list":["post-2758","post","type-post","status-publish","format-standard","hentry","category-freight-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/comments?post=2758"}],"version-history":[{"count":1,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2758\/revisions"}],"predecessor-version":[{"id":2759,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2758\/revisions\/2759"}],"wp:attachment":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/media?parent=2758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/categories?post=2758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/tags?post=2758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}