PHP code example of jansenfelipe / loggi-php

1. Go to this page and download the library: Download jansenfelipe/loggi-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jansenfelipe / loggi-php example snippets




use JansenFelipe\LoggiPHP\Presto\ShopResource;
use JansenFelipe\LoggiPHP\Presto\OrderResource;
use JansenFelipe\LoggiPHP\Presto\Entities\LocationEntity;

$shopResource = new ShopResource();

$result = $shopResource->all();

foreach ($result as $shop) {
    
    echo $shop->id;
    echo $shop->pk;
    echo $shop->name;
}

/*
 * Now, I will estimate the price to deliver at a certain point
 */

$from = $result[0]; //Get a first shop

$orderResource = new OrderResource();

$to = new LocationEntity();
$to->latitude = -19.8579253;
$to->longitude = -43.94522380000001;

$result = $orderResource->estimation($from, $to);

echo 'Estimated price: '. $result->price;




use JansenFelipe\LoggiPHP\Presto\ShopResource;
use JansenFelipe\LoggiPHP\LoggiClient;

$client = new LoggiClient(LoggiClient::SANDBOX, '[email protected]', 'my-key-api');

$shopResource = new ShopResource($client);




use JansenFelipe\LoggiPHP\LoggiClient;
use JansenFelipe\LoggiPHP\Query;

$client = new LoggiClient(LoggiClient::SANDBOX, '[email protected]', 'my-key-api');

$query = new Query([
    'allCities' => [
        'edges' => [
            'node' => ['pk', 'name', 'slug']
        ]
    ]
]);

$response = $client->executeQuery($query);

ssh
$ composer