ozoriotsn / kangu-php-sdk
Kangu SDK for PHP
1.0.0
2024-02-29 12:01 UTC
Requires
- php: ~8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.7
Requires (Dev)
- phpunit/phpunit: ^10.5
README
Kangu PHP SDK
Free webservice for shipping quotation kangu
Installation
Composer install
composer require ozoriotsn/kangu-php-sdk
Usage
<?php require __DIR__ . '/vendor/autoload.php'; use Ozoriotsn\Kangu\Kangu; $kangu = new Kangu('API_KEY');
Simulate Delivery Cost
<?php $data = [ "cepOrigem" => "90035-076", "cepDestino" => "94415-730", "vlrMerc" => 5, // float "pesoMerc" => 1, // float "produtos" => [ [ "peso" => 1,//kg "altura" => 2,//cm "largura" => 11,//cm "comprimento" => 30,//cm "valor" => 5, "quantidade" => 1 ] ], "servicos" => [ "E",// Entrega normal "X",// Entrega expressa "M",// Mini Envios "R" // Retirada ], "ordernar" => "preco" // ‘preco’ ou ‘prazo’ ]; $simulate = $kangu->simulate($data); echo ($simulate); /******************** * Return quatation ******************** [ { "vlrFrete": 10.88, "prazoEnt": 2, "prazoEntMin": 2, "dtPrevEnt": "2024-02-29 14:28:28", "dtPrevEntMin": "2024-02-29 14:28:28", "tarifas": [ { "valor": 10.88, "descricao": "Frete Peso + Seguro" } ], "error": { "codigo": "", "mensagem": "" }, "idSimulacao": 1037357473, "idTransp": 9900, "cnpjTransp": "99999999000000", "idTranspResp": 9900, "cnpjTranspResp": "99999999000000", "alertas": [], "nf_obrig": "N", "url_logo": "https://portal.kangu.com.br/ged/documento/download/file/3962/Logo_Correios.png", "transp_nome": "Correios Sedex", "descricao": "Correios Sedex via Kangu", "servico": "X", "referencia": "kangu_X_99999999000000_1037357473" } ] */
Track Back
<?php $trackback = $kangu->trackback('CODE'); echo ($trackback); /*********************** * Return track back ***********************/ /* { "situacao": { "ocorrencia": "Entregue", "data": "2019-11-22", "dataHora": "2019-11-22 16:55:00", "observacao": "Mercadoria de PET SHOP NOVO MUNDO foi entregue.", "recebedor": "PET SHOP NOVO MUNDO", "acao": "E", "produto": "POSTAGEM" }, "historico": [ { "ocorrencia": "Entregue", "data": "2019-11-22", "dataHora": "2019-11-22 16:55:00", "observacao": "Mercadoria de PET SHOP NOVO MUNDO foi entregue.", "recebedor": "PET SHOP NOVO MUNDO", "acao": "E", "produto": "POSTAGEM" }, { "ocorrencia": "Postado", "data": "2019-11-21", "dataHora": "2019-11-21 17:25:00", "observacao": "Mercadoria recebida por PET SHOP NOVO MUNDO.", "recebedor": "PET SHOP NOVO MUNDO", "acao": "C", "produto": "POSTAGEM" } ], "error": { "codigo": "", "mensagem": "" }, "dtPrevEnt": "22\/11\/2019 16:55:00" } */
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
./vendor/bin/phpunit/ tests
Contributing
Please see CONTRIBUTING
License
The MIT License (MIT). Please see License File for more information.