This commit is contained in:
merdan 2022-01-29 12:29:14 +05:00
parent 9149b18f34
commit 353eef2256
8 changed files with 116 additions and 10 deletions

View File

@ -30,7 +30,8 @@
"october/system": "1.1.*",
"october/backend": "1.1.*",
"october/cms": "1.1.*",
"laravel/framework": "~6.0"
"laravel/framework": "~6.0",
"franzose/laravel-smpp": "^1.4"
},
"require-dev": {
"phpunit/phpunit": "^8.4|^9.3.3",

View File

@ -155,7 +155,7 @@ return [
'providers' => array_merge(include(base_path('modules/system/providers.php')), [
// 'Illuminate\Html\HtmlServiceProvider', // Example
'LaravelSmpp\LaravelSmppServiceProvider',
'System\ServiceProvider',
]),

80
config/laravel-smpp.php Normal file
View File

@ -0,0 +1,80 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default SMPP settings
|--------------------------------------------------------------------------
|
| 1. "sender" is the SMS message sender, either phone number or something like ABCDEF.
| 2. "source_ton" is the sender's type of number
| 3. "source_npi" is the sender's numbering plan identification
| 4. "destination_ton" is the receiver's type of number
| 5. "destination_npi" is the receiver's numbering plan identification
|
| Usually SMPP providers provide these settings to their clients.
| Please refer to official SMPP protocol specification v3.4 to learn more about TON and NPI settings.
|
*/
'defaults' => [
'sender' => env('SMPP_SENDER'),
'source_ton' => env('SMPP_SOURCE_TON'),
'source_npi' => env('SMPP_SOURCE_NPI'),
'destination_ton' => env('SMPP_DESTINATION_TON'),
'destination_npi' => env('SMPP_DESTINATION_NPI')
],
/*
|--------------------------------------------------------------------------
| Custom SMPP provider settings
|--------------------------------------------------------------------------
|
| Most of the time, settings shown under the "example" key are be provided by your SMPP provider.
| So if you don't have any of these settings, please contact your SMPP provider.
|
*/
'default' => env('SMPP_DEFAULT_PROVIDER'),
'providers' => [
'example' => [
'host' => '217.174.228.218',
'port' => 5019,
'timeout' => 90,
'login' => 'birja',
'password' => 'Birj@1'
]
],
/*
|--------------------------------------------------------------------------
| SMPP transport settings
|--------------------------------------------------------------------------
|
| For all SMPP errors listed in "transport.catchables", exceptions
| thrown by SMPP will be suppressed and just logged.
|
*/
'transport' => [
'catchables' => [
SMPP::ESME_RBINDFAIL,
SMPP::ESME_RINVCMDID
],
'force_ipv4' => true,
'debug' => false
],
/*
|--------------------------------------------------------------------------
| SMPP client settings
|--------------------------------------------------------------------------
*/
'client' => [
'system_type' => 'default',
'null_terminate_octetstrings' => false,
'debug' => false
]
];

View File

@ -8,10 +8,15 @@ use Illuminate\Support\Facades\Validator;
class NotificationsApiController extends Controller
{
public function index(Request $request) {
public function __construct()
{
if (!$user = \JWTAuth::parseToken()->authenticate()) {
return response()->json('Unauthorized', 401);
}
}
public function index(Request $request) {
$validator = Validator::make($request->all(), [
'records_per_page' => 'numeric',
@ -39,10 +44,6 @@ class NotificationsApiController extends Controller
*/
public function markAsRead($id)
{
if (!$user = \JWTAuth::parseToken()->authenticate()) {
return response()->json('Unauthorized', 401);
}
$notification = $user->notifications()
->applyUnread()
->find($id);
@ -65,4 +66,4 @@ class NotificationsApiController extends Controller
],
], 300);
}
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace AhmadFatoni\ApiGenerator\Controllers\API;
use Cms\Classes\Controller;
use LaravelSmpp\SmppServiceInterface;
class SmsController extends Controller
{
public function index(SmppServiceInterface $smpp) {
$this->smpp->sendOne(99363432211, 'Hi, this SMS was send via SMPP protocol');
return 'success';
}
}

View File

@ -10,6 +10,7 @@ Route::group(['prefix' =>'api/v1','namespace' =>'AhmadFatoni\ApiGenerator\Contro
Route::get('products', ['as' => 'products.index', 'uses' => 'ProductsApiController@index']);
Route::get('products/{id}', ['as' => 'products.show', 'uses' => 'ProductsApiController@show']);
Route::get('test',['as' => 'test', 'uses' => 'SmsController@index']);
// Route::get('products/{id}/delete', ['as' => 'products.delete', 'uses' => 'ProductsApiController@destroy']);

View File

@ -1,4 +1,11 @@
<?php return array (
'franzose/laravel-smpp' =>
array (
'providers' =>
array (
0 => 'LaravelSmpp\\LaravelSmppServiceProvider',
),
),
'laravel/tinker' =>
array (
'providers' =>

View File

@ -28,7 +28,8 @@
24 => 'October\\Rain\\Argon\\ArgonServiceProvider',
25 => 'October\\Rain\\Redis\\RedisServiceProvider',
26 => 'October\\Rain\\Validation\\ValidationServiceProvider',
27 => 'System\\ServiceProvider',
27 => 'LaravelSmpp\\LaravelSmppServiceProvider',
28 => 'System\\ServiceProvider',
),
'eager' =>
array (
@ -43,7 +44,8 @@
8 => 'October\\Rain\\Filesystem\\FilesystemServiceProvider',
9 => 'October\\Rain\\Html\\UrlServiceProvider',
10 => 'October\\Rain\\Argon\\ArgonServiceProvider',
11 => 'System\\ServiceProvider',
11 => 'LaravelSmpp\\LaravelSmppServiceProvider',
12 => 'System\\ServiceProvider',
),
'deferred' =>
array (