承接 paps-app/paps-php-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

paps-app/paps-php-client

Composer 安装命令:

composer require paps-app/paps-php-client

包简介

Paps API Client for PHP

README 文档

README

A PHP client for consuming the Paps API.

This client is targeting the API version v2.

Install

Via Composer

$ composer require paps-app/paps-php-client

The minimum required version of PHP is 5.6

Usage

All the method listed below are the same documented on the RESTful API, so this guide won't be covering any params required for each method. Please, yout can however refer to the Examples sections.

Create the client

First you'll need to initialize the client by providing your API. To get an API, visit the documentation and click on "Get a Key" button.

$client = new Paps\PapsClient([
  'api_key' => '<Your API Key>'
]);

Enter Test Mode

Please consider entering test mode when starting to experiment with this API. Note that under test mode, you have full control over your tasks. You can create, cancel, change your task statues or even delete them. But remember to hack responsibly 😉.

$client = new Paps\PapsClient([
  'api_key' => '<Your API Key>',
  'mode' => 'test'
]);

Create a delivery request linked to your main account on Monespace

You can use this method if you also want to track your orders on the Monespace web client application. Note that you must specify the email address of the account that has access to the application. Again, make sure to read the documentation for params expected by this method

  • Example :
$delivery = new Paps\Resources\Delivery($client);

// Email registered on your Monespace account
$email = "kiamet@example.com"

// Prepare your pickups params
$pickups = [
    [
        "address" => "Almadies, Dakar, Senegal",
        "name" => "Saliou Samb",
        "time" => date('Y-m-d H:i:s', time()),
        "phone" => "+221700000000",
        "job_description" => "Test Saliou"
    ]
];

// Prepare your delivery params
$deliveries = [
    [
        "address" => "Medina, Dakar, Senegal",
        "name" => "Modou Diakahté",
        "time" => date('Y-m-d H:i:s', time()),
        "phone" => "+221700000000",
        "job_description" => "Test Saliou"
    ]
];

// Pass your request
$response = $delivery->createTaskForAPIUser($email, $pickups, $deliveries);

// Read your response, hopefully successful.
echo json_encode($response);

Create a standard Delivery Request with a pickup

Make sure to read the documentation before sending any requests.

  • Example :
$delivery = new Paps\Resources\Delivery($client);

// Prepare your params
$delivery_params = [
  'jobDescription' => 'Commande venant du site de Test',
  'jobPickupPhone' => '778888888',
  'jobPickupName' => 'Test Pickup Name',
  'jobPickupAddress' => 'Medina, Dakar, Sénégal',
  'jobPickupDatetime' => '2019-01-12 12:00:00',
  'jobDeliveryDatetime' => '2019-01-14 12:00:00',
  'customerUsername' => 'Test Delivery Name',
  'customerAddress' => 'Urbam, Dakar, Sénégal',
  'customerPhone' => '779999999'
];

// Pass your request
$response = $delivery->create($delivery_params);

// Read your response, hopefully successful.
echo json_encode($response);

Make a delivery quote request

You can get delivery quotes directly from the API. Usually, the rates are already communicated to you through the contract that you have approved or signed to start using Paps.

  • Example :
$delivery = new Paps\Resources\Delivery($client);

// Prepare your request params
$quotes_params = [
  "origin" => "Medina, Dakar, Senegal",
  "destination" => "Almadies, Dakar, Senegal",
  "packageSize" => "small"
];

// Pass your request
$response = $delivery->submitQuotesRequest($quotes_params);

// Read your response, hopefully successful.
echo json_encode($response);

Read a delivery task's information

You can view a task that has been created using this method.

  • Example :
$delivery = new Paps\Resources\Delivery($client);

// Prepare your request params
$task_id = "7233112";

// Pass your request
$response = $delivery->get($task_id);

// Read your response, hopefully successful.
echo json_encode($response);

Get a list of delivery

You can view a task that has been created using this method.

  • Example :
$delivery = new Paps\Resources\Delivery($client);

// Prepare your request params
$start_date = date('Y-m-d H:i:s'),
$end_date = date('Y-m-d H:i:s'),
$select_by = "intervalle"

// Pass your request
$response = $delivery->listDeliveries(null, $start_date, $end_date, $select_by);

// Read your response, hopefully successful.
echo json_encode($response);

Cancel a delivery

You can cancel a task by providing it's ID. Remember you can't cancel a task that has the following status : IN_PROGRESS and STARTED.

  • Example :
$delivery = new Paps\Resources\Delivery($client);

// Prepare your request params
$task_id = "7233112";

// Pass your request
$response = $delivery->cancel($task_id);

// Read your response, hopefully successful.
echo json_encode($response);

WooCommerce Integration

WooCommerce Paps Integration Plugin

License

The MIT License (MIT).

统计信息

  • 总下载量: 1.59k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固