Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jansenfelipe/loggi-php

Abstraction layer PHP to integrate with a Loggi API
https://github.com/jansenfelipe/loggi-php

loggi

Last synced: about 2 months ago
JSON representation

Abstraction layer PHP to integrate with a Loggi API

Awesome Lists containing this project

README

        

# LoggiPHP
[![Travis](https://travis-ci.org/jansenfelipe/loggi-php.svg?branch=master)](https://travis-ci.org/jansenfelipe/loggi-php)

Abstraction layer PHP to integrate with a Loggi API.

Read More https://docs.api.loggi.com/docs

## HowTo Use

First, install library:

```ssh
$ composer require jansenfelipe/loggi-php
```

Just instantiate the resource you want to consume.

In the example below I'm looking for all the Shops:

```php
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.

By default, the request will be sent in the production environment.

If you want, you can instantiate the `LoggiClient` manually and inject into the resource.

For example:

```php
[
'edges' => [
'node' => ['pk', 'name', 'slug']
]
]
]);

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

```

## License

The MIT License (MIT)