Skip to content

Commit

Permalink
initaial pathao bd courier service
Browse files Browse the repository at this point in the history
  • Loading branch information
dipudey committed Aug 29, 2022
0 parents commit d5e8670
Show file tree
Hide file tree
Showing 12 changed files with 672 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
160 changes: 160 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<p align="center">
<img src="https://pathao.com/wp-content/uploads/2019/02/Pathao-logo.svg">
</p>

<h1 align="center">Pathao Courier Banagladesh</h1>
<p align="center" >
<img src="https://img.shields.io/packagist/dt/codeboxr/pathao-courier">
<img src="https://img.shields.io/packagist/stars/codeboxr/pathao-courier">
</p>


## Requirements

- PHP >=7.2
- Laravel >= 6

## Installation

```bash
composer require codeboxr/pathao-courier
```

### vendor publish (config)
```bash
php artisan vendor:publish --provider="Codeboxr\PathaoCourier\PathaoCourierServiceProvider"
```

After publish config file setup your credential. you can see this in your config directory pathao.php file
```
"sandbox" => env("PATHAO_SANDBOX", false), // for sandbox mode use true
"client_id" => env("PATHAO_CLIENT_ID", ""),
"client_secret" => env("PATHAO_CLIENT_SECRET", ""),
"username" => env("PATHAO_USERNAME", ""),
"password" => env("PATHAO_PASSWORD", "")
```

### Set .env configuration
```
PATHAO_SANDBOX=true // for production mode use false
PATHAO_CLIENT_ID=""
PATHAO_CLIENT_SECRET=""
PATHAO_USERNAME=""
PATHAO_PASSWORD=""
```


## Usage

### 1. Get pathao delivery city list

```
use Codeboxr\PathaoCourier\Facade\PathaoCourier
return PathaoCourierFacade::area()->city();
```

### 2. To get pathao zone list

```
use Codeboxr\PathaoCourier\Facade\PathaoCourier
return PathaoCourier::area()->zone($cityId); // City ID
```

### 3. To get pathao delivery area list

```
use Codeboxr\PathaoCourier\Facade\PathaoCourier
return PathaoCourier::area()->area($zoneId); // Zone ID
```


### 4. Create new store

```
use Codeboxr\PathaoCourier\Facade\PathaoCourier
return PathaoCourier::store()
->create([
"name" => "", // Store Name
"contact_name" => "", // Store contact person name
"contact_number" => "", // Contact person number
"address" => "", // Store address
"secondary_contact" => "", // Contact person secondary number not mandatory
"city_id" => "", // Find in city method
"zone_id" => "", // Find in zone method
"area_id" => "", // Find in Area method
]);
```

### 5. Get Store List

```
use Codeboxr\PathaoCourier\Facade\PathaoCourier
return PathaoCourier::store()->list();
```

### 6. Create new parcel

```
use Codeboxr\PathaoCourier\Facade\PathaoCourier
return PathaoCourier::order()
->create([
"store_id" => "", // Find in store list,
"merchant_order_id" => "", // Unique order id
"recipient_name" => "", // Customer name
"recipient_phone" => "", // Customer phone
"recipient_address" => "", // Customer address
"recipient_city" => "", // Find in city method
"recipient_zone" => "", // Find in zone method
"recipient_area" => "", // Find in Area method
"delivery_type" => "", // 48 for normal delivery or 12 for on demand delivery
"item_type" => "", // 1 for document,
2 for parcel
"special_instruction" => "",
"item_quantity" => "", // item quantity
"item_weight" => "", // parcel weight
"amount_to_collect" => "", // amount to collect
"item_description" => "" // product details
]);
```

### 7. Get Order Details

```
use Codeboxr\PathaoCourier\Facade\PathaoCourier
return PathaoCourier::order()->orderDetails($consignmentId); // After successfully create order they given a consignment_id
```















## Contributing

Contributions to the Pathao package are welcome. Please note the following guidelines before submitting your pull request.

- Follow [PSR-4](http://www.php-fig.org/psr/psr-4/) coding standards.
- Read Pathao API documentations first

## License

Pathao package is licensed under the [MIT License](http://opensource.org/licenses/MIT).

Copyright 2022 [Codeboxr](https://codeboxr.com)
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "codeboxr/pathao-courier",
"description": "Bangladeshi Pathao courier service api package",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Codeboxr\\PathaoCourier\\": "src/"
}
},
"authors": [
{
"name": "Codeboxr"
}
],
"minimum-stability": "dev",
"require": {
"php": "^7.2|^7.3|^8.0|^8.1",
"illuminate/support": "~6|~7|~8",
"guzzlehttp/guzzle": "^7.0.1"
},
"extra": {
"laravel": {
"providers": [
"Codeboxr\\PathaoCourier\\PathaoCourierServiceProvider"
]
}
}
}
9 changes: 9 additions & 0 deletions config/pathao.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
"sandbox" => env("PATHAO_SANDBOX", false),
"client_id" => env("PATHAO_CLIENT_ID", ""),
"client_secret" => env("PATHAO_CLIENT_SECRET", ""),
"username" => env("PATHAO_USERNAME", ""),
"password" => env("PATHAO_PASSWORD", "")
];
52 changes: 52 additions & 0 deletions src/Apis/AreaApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Codeboxr\PathaoCourier\Apis;

use GuzzleHttp\Exception\GuzzleException;
use Codeboxr\PathaoCourier\Exceptions\PathaoException;

class AreaApi extends BaseApi
{
/**
* get city List
*
* @return mixed
* @throws PathaoException
* @throws GuzzleException
*/
public function city()
{
$response = $this->authorization()->send("GET", "aladdin/api/v1/countries/1/city-list");
return $response->data;
}

/**
* Get zone list city wise
*
* @param int $cityId
*
* @return mixed
* @throws GuzzleException
* @throws PathaoException
*/
public function zone($cityId)
{
$response = $this->authorization()->send("GET", "aladdin/api/v1/cities/{$cityId}/zone-list");
return $response->data;
}

/**
* Get area list zone wise
*
* @param int $zoneId
*
* @return mixed
* @throws GuzzleException
* @throws PathaoException
*/
public function area($zoneId)
{
$response = $this->authorization()->send("GET", "aladdin/api/v1/zones/{$zoneId}/area-list");
return $response->data;
}
}
Loading

0 comments on commit d5e8670

Please sign in to comment.