-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bryan
committed
Mar 7, 2023
0 parents
commit 69e6384
Showing
8 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Online Identity & Solutions B.V. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Laravel Channable API connector | ||
|
||
## About | ||
This package creates a wrapper around [onlineidentity/channable](https://github.com/onlineidentity/channable/) for ease of use in the [Laravel framework](https://laravel.com). | ||
|
||
## Installation | ||
|
||
`composer require onlineidentity/laravel-channable` | ||
|
||
(Optional) Publish the config file with `php artisan vendor:publish --tag=channable` | ||
|
||
Set your .env variables | ||
```dotenv | ||
CHANNABLE_API_TOKEN='{API_TOKEN}' | ||
CHANNABLE_COMPANY_ID={COMPANY_ID} | ||
CHANNABLE_PROJECT_ID={PROJECT_ID} #default, swappable after initialization | ||
``` | ||
|
||
## Usage | ||
|
||
````php | ||
#Examples | ||
|
||
# app()->make(); | ||
|
||
$channable = app()->make('channable'); | ||
|
||
//Get all orders | ||
$channable->orders()->allOrders(); | ||
|
||
$order_id = 12345678; | ||
$channable->orders()->shipment($order_id, [ | ||
'tracking_code' => '3S1234567890', | ||
'transporter' => 'POSTNL', | ||
'order_item_ids' => [ | ||
1, | ||
2 | ||
] | ||
]); | ||
|
||
//Get all returns with queryParameters | ||
$channable->returns()->allReturns(['limit' => 2, 'last_modified_after' => '2022-01-01']); | ||
|
||
//update returns status | ||
$return_id = 12345678; | ||
$status_accepted = \OnlineIdentity\Enums\ReturnsType::ACCEPTED; | ||
$channable->returns()->updateReturnStatus($return_id, $status_accepted); | ||
|
||
# Using the facade | ||
|
||
//get all orders | ||
$orders = \OnlineIdentity\LaravelChannable\Facades\Channable::orders()->allOrders(); | ||
|
||
//change project id | ||
\OnlineIdentity\LaravelChannable\Facades\Channable::setProjectId(123456); | ||
|
||
\OnlineIdentity\LaravelChannable\Facades\Channable::orders()->shipment($order_id, [ | ||
'tracking_code' => '3S1234567890', | ||
'transporter' => 'POSTNL', | ||
'order_item_ids' => [ | ||
1, | ||
2 | ||
]); | ||
|
||
```` | ||
For more details and options visit the offical channable docs https://api.channable.com/v1/docs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "onlineidentity/laravel-channable", | ||
"description": "Laravel wrapper for OnlineIdentity Channable API connector", | ||
"type": "library", | ||
"keywords": ["api","channable","connector","laravel"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Bryan Schreuder", | ||
"email": "bryan@onlineidentity.nl" | ||
}, | ||
{ | ||
"name": "Joeri Aben", | ||
"email": "joeri@onlineidentity.nl" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.1", | ||
"onlineidentity/channable": "dev-master", | ||
"illuminate/support": "^6|^7|^8|^9|^10" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"OnlineIdentity\\LaravelChannable\\": "src/" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"OnlineIdentity\\LaravelChannable\\ChannableServiceProvider" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
return [ | ||
'api_token' => env('CHANNABLE_API_TOKEN'), | ||
'company_id' => env('CHANNABLE_COMPANY_ID'), | ||
'project_id' => env('CHANNABLE_PROJECT_ID'), | ||
'base_url' => env('CHANNABLE_BASE_URL', 'https://api.channable.com'), | ||
'version' => env('CHANNABLE_VERSION', 'v1') | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace OnlineIdentity\LaravelChannable; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use OnlineIdentity\Channable\Channable; | ||
use OnlineIdentity\Channable\ChannableConfig; | ||
|
||
class ChannableServiceProvider extends ServiceProvider | ||
{ | ||
public function register() | ||
{ | ||
$this->mergeConfigFrom( | ||
__DIR__ . '/../config/channable.php', 'channable' | ||
); | ||
|
||
$this->app->bind('channable', function ($app) { | ||
|
||
$config = new ChannableConfig( | ||
api_token: config('channable.api_token'), | ||
company_id: config('channable.company_id'), | ||
project_id: config('channable.project_id'), | ||
version: config('channable.version'), | ||
base_url: config('channable.base_url') | ||
); | ||
|
||
return new Channable($config); | ||
}); | ||
} | ||
|
||
public function boot(): void | ||
{ | ||
$this->publishes([ | ||
__DIR__ . "/config" => config_path() | ||
], 'channable'); | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array<string> | ||
*/ | ||
public function provides(): array | ||
{ | ||
return ['channable']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace OnlineIdentity\LaravelChannable; | ||
|
||
use Illuminate\Support\Facades\Facade as IlluminateFacade; | ||
|
||
/** | ||
* @method static \OnlineIdentity\Channable\Channable orders() | ||
* @method static \OnlineIdentity\Channable\Channable stockUpdates() | ||
* @method static \OnlineIdentity\Channable\Channable returns() | ||
* @method static \OnlineIdentity\Channable\Channable transporters() | ||
* @method static \OnlineIdentity\Channable\Channable statistics() | ||
* @method static \OnlineIdentity\Channable\Channable setProjectId() | ||
* @method static \OnlineIdentity\Channable\Channable setConfig() | ||
*/ | ||
class Channable extends IlluminateFacade | ||
{ | ||
/** | ||
* Get the registered name of the component. | ||
*/ | ||
protected static function getFacadeAccessor(): string | ||
{ | ||
return 'channable'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace OnlineIdentity\LaravelChannable\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade as IlluminateFacade; | ||
|
||
|
||
/** | ||
* @method static \OnlineIdentity\Channable\Channable orders() | ||
* @method static \OnlineIdentity\Channable\Channable stockUpdates() | ||
* @method static \OnlineIdentity\Channable\Channable returns() | ||
* @method static \OnlineIdentity\Channable\Channable transporters() | ||
* @method static \OnlineIdentity\Channable\Channable statistics() | ||
* @method static \OnlineIdentity\Channable\Channable setProjectId() | ||
* @method static \OnlineIdentity\Channable\Channable setConfig() | ||
*/ | ||
class Channable extends IlluminateFacade | ||
{ | ||
/** | ||
* Get the registered name of the component. | ||
*/ | ||
protected static function getFacadeAccessor(): string | ||
{ | ||
return 'channable'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
return [ | ||
'api_token' => env('CHANNABLE_API_TOKEN'), | ||
'company_id' => env('CHANNABLE_COMPANY_ID'), | ||
'project_id' => env('CHANNABLE_PROJECT_ID'), | ||
'base_url' => env('CHANNABLE_BASE_URL', 'https://api.channable.com'), | ||
'version' => env('CHANNABLE_VERSION', 'v1') | ||
]; |