2017 © Pedro Peláez
 

library lalamove-php-api

PHP client for the Lalamove API

image

foodkit/lalamove-php-api

PHP client for the Lalamove API

  • Tuesday, May 8, 2018
  • by coreymcmahon
  • Repository
  • 1 Watchers
  • 1 Stars
  • 175 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 600 % Grown

The README.md

Lalamove PHP API

This provides a PHP wrapper around the Lalamove API., (*1)

Built and maintained by Foodkit., (*2)

Design goals

  • Lean on the IDE. We should leverage the IDE (autocompletion) to help the developer to use the library.
  • Hide the transport mechanism (HTTP) as much as possible. Except when absolutely necessary (e.g endpoint configuration, request timeouts), the end user should not be worried about HTTP concepts when using the library.
  • Interface should be pleasant (or at least unobtrusive) to use. The library should remove as much friction from the development process as possible.

Running the tests

$ ./vendor/bin/phpunit tests/
PHPUnit 7.0.2 by Sebastian Bergmann and contributors.

...........                                                       11 / 11 (100%)

Time: 116 ms, Memory: 4.00MB

OK (11 tests, 23 assertions)

Using the library

<?php

$settings = new \Lalamove\Client\Settings(
    'https://sandbox-rest.lalamove.com',
    // These are fake, don't try and use them:
    'wgmsqqh208fxic9vcqwruk2tciicielf', // customerId
    'kGEX69NLd33+J/FQGdx8jOLAO1JZVPrHzQpuZDrWGxlftbu2tKFiVkptTSfPaj==', // privateKey
    \Lalamove\Client\Settings::COUNTRY_SINGAPORE // country
);

$client = new Lalamove\Client\Client($settings);

// Create a quote:
$quotation = new \Lalamove\Quotation();
// ...prepare the quotation object...
$quotationResponse = $client->quotations()->create($quotation);

// Create an order:
$order = \Lalamove\Order::makeFromQuote($quotation, $quotationResponse, 'unique-order-id', false);
$orderResponse = $client->orders()->create($order);

// Fetch order details:
$details = $client->orders()->details($orderResponse->customerOrderId);

// Get the driver:
$driver = $client->drivers()->get($orderResponse->customerOrderId, $details->driverId);
$driverLocation = $client->drivers()->getLocation($orderResponse->customerOrderId, $details->driverId);

// Cancel the order:
$details = $client->orders()->cancel($orderResponse->customerOrderId);

Errors

The client library will throw exceptions in the case of request (or server) errors., (*3)

try {
    $client->orders()->create($order);
} catch (\Lalamove\Exceptions\PaymentRequiredException $ex) {
    echo 'Error: not enough funds in Lalamove wallet to create the order';
}

You can handle these independently (see exceptions in src/Exceptions/), or just catch the supertype Lalamove\Exceptions\LalamoveException to handle all failure cases., (*4)

try {
    $client->orders()->create($order);
} catch (\Lalamove\Exceptions\LalamoveException $ex) {
    echo "Error: I don't know what happened, but the request failed for some reason.";
}

Contributing

Open a PR against master. Please use PSR-x conventions for everything and include tests., (*5)

The Versions

08/05 2018

dev-master

9999999-dev

PHP client for the Lalamove API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Corey Mcmahon

08/05 2018

1.0.0

1.0.0.0

PHP client for the Lalamove API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Corey Mcmahon

04/05 2018

0.0.6

0.0.6.0

PHP client for the Lalamove API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Corey Mcmahon

27/04 2018

0.0.5

0.0.5.0

PHP client for the Lalamove API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Corey Mcmahon

26/04 2018

0.0.4

0.0.4.0

PHP client for the Lalamove API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Corey Mcmahon

26/04 2018

0.0.3

0.0.3.0

PHP client for the Lalamove API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Corey Mcmahon

26/04 2018

0.0.2

0.0.2.0

PHP client for the Lalamove API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Corey Mcmahon

19/04 2018

0.0.1

0.0.1.0

PHP client for the Lalamove API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Corey Mcmahon