amribrahim34/bosta-laravel

此包用于与埃及快递公司Bosta集成

dev-main 2024-08-05 18:44 UTC

This package is auto-updated.

Last update: 2024-09-05 18:49:10 UTC


README

描述

一个用于与埃及Bosta快递服务集成的Laravel包

安装

  1. 通过Composer安装此包
    composer require amribrahim34/laravel-bosta-egypt
    

配置

  1. 发布配置文件
    php artisan vendor:publish --provider="YourNamespace\BostaEgypt\BostaEgyptServiceProvider"
    
  2. 将您的Bosta API密钥添加到.env文件中
    BOSTA_API_KEY=your_api_key_here
    

使用方法

基本用法

use YourNamespace\BostaEgypt\BostaEgypt;

$bosta = new BostaEgypt(config('bosta-egypt.api_key'));

示例

计算运费

$result = $bosta->pricing->calculateShipment([
    'dropOffCity' => 'cairo',
    'pickupCity' => 'cairo',
    'cod' => 500,
    'size' => 'Normal'
]);

创建配送

$deliveryData = [
    'type' => 10,
    'specs' => [
        'packageType' => 'Parcel',
        'size' => 'MEDIUM',
        'packageDetails' => [
            'itemsCount' => 2,
            'description' => 'Desc.'
        ]
    ],
    // ... other delivery details
];

$result = $bosta->deliveries->create($deliveryData);

可用方法

定价

  • calculateShipment

配送

  • create

DeliveryBuilder使用

DeliveryBuilder 类提供了一个流畅的接口来构建Bosta埃及的配送数据。

示例

<?php

use amribrahim34\BostaEgypt\DeliveryBuilder;
use amribrahim34\BostaEgypt\BostaEgypt;

$bosta = new BostaEgypt('your-api-key-here');

$deliveryData = (new DeliveryBuilder())
    ->setType(10)
    ->setSpecs('Parcel', 'MEDIUM', 2, 'Desc.')
    ->setNotes('Welcome Note')
    ->setCod(50)
    ->setDropOffAddress('Helwan', 'NQz5sDOeG', 'aiJudRHeOt', 'Helwan street x', 'Near to Bosta school', '123', '4', '2')
    ->setPickupAddress('Helwan', 'NQz5sDOeG', 'aiJudRHeOt', 'Helwan street x', 'Near to Bosta school', '123', '4', '2')
    ->setReturnAddress('Helwan', 'NQz5sDOeG', 'aiJudRHeOt', 'Maadi', 'Nasr City', '123', '4', '2')
    ->setBusinessReference('43535252')
    ->setReceiver('Sasuke', 'Uchiha', '01065685435', 'ahmed@ahmed.com')
    ->setWebhookUrl('https://www.google.com/')
    ->build();

$result = $bosta->deliveries->create($deliveryData);


## Testing

Run the following command to execute tests:

vendor/bin/phpunit


## Contributing

1. Fork the repository
2. Create your feature branch
3. Commit your changes
4. Push to the branch
5. Create a new Pull Request

## License

MIT

## Authors

- Amr Ibrahim (amramr3434@gmail.com)