A simple API wrapper for the Sendle shipping APIs
Install via composer
composer require rob-lester-jr04/laravel-sendle
This package has a Facade for being used Standalone, in addition to Models that can be instantiated.
<?php
use Sendle\Models\Order;
$order = new Order([
'receiver' => [
'contact' => [
'name' => 'John Smith',
'email' => '[email protected]',
],
'address' => [
'address_line1' => '123 Main Street',
'suburb' => 'New York',
'postcode' => '10010',
'state_name' => 'NY',
'country' => 'US'
],
'instructions' => 'Leave it on the step',
],
'description' => 'test package',
'product_code' => 'STANDARD-PICKUP',
'weight' => [
'value' => 14,
'units' => 'oz',
]
]);
$order->create();
// OR....
Order::create([
...
]);
<?php
use Sendle\Models\Order;
Order::find('####');
<?php
use Sendle\Models\Product;
use Sendle\Models\Entity;
$receiver = new Entity([
'contact' => [
'name' => 'John Smith',
'email' => '[email protected]',
],
'address' => [
'address_line1' => '123 Main Street',
'suburb' => 'New York',
'postcode' => '10010',
'state_name' => 'NY',
'country' => 'US'
],
'instructions' => 'Leave it on the step',
]);
$weight = 26.0;
$products = Product::get($weight, $receiver);
You can include the SendsPackages
trait on your models, such as a Client
model or User
model
<?php
namespace App\Models;
use Sendle\Traits\SendsPackages;
class User extends Model
{
use SendsPackages;
protected $sendleOrderCreate = [
// Map your users address fields to sendle. sendle=>model
'address_line1' => 'street_address',
'suburb' => 'city',
'state_name' => 'state',
];
//...
}
//.........//
$user = User::find(4);
$user->sendleOrderCreate('grandmas china', 36.0);
//.........//
$reciever = new Entity([
'contact' => [ /** */],
'address' => [
/** */
],
]);
$user->sendleOrderCreate('grandmas china', 42, $receiver);
Laravel Sendle is open-sourced software licensed under the MIT license.