2017 © Pedro Peláez
 

library loggi-php

Abstraction layer PHP to integrate with a Loggi API

image

jansenfelipe/loggi-php

Abstraction layer PHP to integrate with a Loggi API

  • Sunday, February 18, 2018
  • by jansenfelipe
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

LoggiPHP

Travis, (*1)

Abstraction layer PHP to integrate with a Loggi API., (*2)

Read More https://docs.api.loggi.com/docs, (*3)

HowTo Use

First, install library:, (*4)

$ composer require jansenfelipe/loggi-php

Just instantiate the resource you want to consume., (*5)

In the example below I'm looking for all the Shops:, (*6)

<?php

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;

Setup

The above example assumes that the environment variables LOGGI_API_URL, LOGGI_API_EMAIL and LOGGI_API_KEY are configured., (*7)

By default, the request will be sent in the production environment., (*8)

If you want, you can instantiate the LoggiClient manually and inject into the resource., (*9)

For example:, (*10)

<?php

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

$client = new LoggiClient(LoggiClient::SANDBOX, 'my-email@gmail.com', 'my-key-api');

$shopResource = new ShopResource($client);

Available resources

  • Presto
    • ShopResource
      • all() : ShopEntity[]
    • OrderResource
      • estimation(from:ShopEntity, to:LocationEntity) : EstimateEntity

Entities

Standalone

You can run a query without using resources. Just call the executeQuery($query) method of the LoggiClient class., (*11)

For example, let's look at all the cities where Loggi operates:, (*12)

<?php

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

$client = new LoggiClient(LoggiClient::SANDBOX, 'my-email@gmail.com', 'my-key-api');

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

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

License

The MIT License (MIT), (*13)

The Versions

18/02 2018

dev-master

9999999-dev

Abstraction layer PHP to integrate with a Loggi API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jansen Felipe

loggi

18/02 2018

1.0.2

1.0.2.0

Abstraction layer PHP to integrate with a Loggi API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jansen Felipe

loggi

18/02 2018

dev-develop

dev-develop

Abstraction layer PHP to integrate with a Loggi API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jansen Felipe

loggi

18/02 2018

1.0.1

1.0.1.0

Abstraction layer PHP to integrate with a Loggi API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jansen Felipe

loggi

14/02 2018

1.0.0

1.0.0.0

Abstraction layer PHP to integrate with a Loggi API

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Jansen Felipe

loggi