Skip to content

roblesterjr04/Laravel-Sendle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Sendle

Actions Status Latest Stable Version Packagist Packagist

A simple API wrapper for the Sendle shipping APIs

Installation

Install via composer

composer require rob-lester-jr04/laravel-sendle

Basic Usage

This package has a Facade for being used Standalone, in addition to Models that can be instantiated.

Create an order in Sendle

<?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([
	...
]);

Retrieve Order

<?php

use Sendle\Models\Order;

Order::find('####');

Get Product Catelog

<?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);

Packages Trait

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);

License

Laravel Sendle is open-sourced software licensed under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages