PHP code example of yemenifree / pick-service-api

1. Go to this page and download the library: Download yemenifree/pick-service-api 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/ */

    

yemenifree / pick-service-api example snippets


$service = new PickService('Live Token');

$sandBoxService = new PickService('Sandbox Token', true);

$result = $service->request('service', 'action', ...$arg);

// check if request seccess.
if (!$result->isSuccess()) {
    // there are error
    $error = $result->json();
}

// All right.
$invoice = $result->json();     

// create Order
$order = new Order();
// set up order info.
$order->setItems(Order::ITEM_HOUSEHOLD)
    ->setPrice(200)
    ->setPickupTime(Carbon::now()->addDays(1))
    ->setPaymentType(Order::PAYMENT_PRE_PAID)
    ->setPickupLocation(24.697168165551115, 46.70957565307617)
    ->setReceiverName('Salah Alkhwlani')
    ->setReceiverPhone('966500484350');

// send create request.
$result = $service->request('orders', 'create', $order);

// check if request seccess.
if (!$result->isSuccess()) {
    $error = $result->json();
}

// All right.
$invoice = $result->json();     

$orderID = 1;
$result = $service->request('orders', 'delete', $orderID);

$orderID = 1;
$result = $service->request('orders', 'view', $orderID);

$query = 'keyword';
$order = '';
$result = $service->request('orders', 'search', $query, $order);

$orderID = 1;
$orderModel = new Order();
// set up new order info.
$orderModel->setItems(Order::ITEM_HOUSEHOLD)
    ->setPrice(210)
    ->setPickupTime(Carbon::now()->addDays(1))
    ->setPaymentType(Order::PAYMENT_PRE_PAID)
    ->setPickupLocation(24.697168165551115, 46.70957565307617)
    ->setReceiverName('Salah Alkhwlani')
    ->setReceiverPhone('966500484350');

$result = $service->request('orders', 'edit', $orderID, $orderModel);

$result = $service->request('orders', 'cancel', $orderID,$orderModel);