From 353eef22568ec6e2ce08d5b788f4f42fa88b8b9c Mon Sep 17 00:00:00 2001 From: merdan Date: Sat, 29 Jan 2022 12:29:14 +0500 Subject: [PATCH] sms test --- composer.json | 3 +- config/app.php | 2 +- config/laravel-smpp.php | 80 +++++++++++++++++++ .../api/NotificationsApiController.php | 13 +-- .../controllers/api/SmsController.php | 14 ++++ plugins/ahmadfatoni/apigenerator/routes.php | 1 + storage/framework/packages.php | 7 ++ storage/framework/services.php | 6 +- 8 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 config/laravel-smpp.php create mode 100644 plugins/ahmadfatoni/apigenerator/controllers/api/SmsController.php diff --git a/composer.json b/composer.json index f9ca9ad03..99f6c53fd 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/config/app.php b/config/app.php index 95d9d98a1..6418a2744 100644 --- a/config/app.php +++ b/config/app.php @@ -155,7 +155,7 @@ return [ 'providers' => array_merge(include(base_path('modules/system/providers.php')), [ // 'Illuminate\Html\HtmlServiceProvider', // Example - + 'LaravelSmpp\LaravelSmppServiceProvider', 'System\ServiceProvider', ]), diff --git a/config/laravel-smpp.php b/config/laravel-smpp.php new file mode 100644 index 000000000..3618cccb3 --- /dev/null +++ b/config/laravel-smpp.php @@ -0,0 +1,80 @@ + [ + '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 + ] +]; diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/NotificationsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/NotificationsApiController.php index 0f336456b..b868d134d 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/NotificationsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/NotificationsApiController.php @@ -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); } -} \ No newline at end of file +} diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/SmsController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/SmsController.php new file mode 100644 index 000000000..95879b4ce --- /dev/null +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/SmsController.php @@ -0,0 +1,14 @@ +smpp->sendOne(99363432211, 'Hi, this SMS was send via SMPP protocol'); + return 'success'; + } +} diff --git a/plugins/ahmadfatoni/apigenerator/routes.php b/plugins/ahmadfatoni/apigenerator/routes.php index d38b78139..feec61fcd 100644 --- a/plugins/ahmadfatoni/apigenerator/routes.php +++ b/plugins/ahmadfatoni/apigenerator/routes.php @@ -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']); diff --git a/storage/framework/packages.php b/storage/framework/packages.php index eff9b08d6..7e25de3e5 100644 --- a/storage/framework/packages.php +++ b/storage/framework/packages.php @@ -1,4 +1,11 @@ + array ( + 'providers' => + array ( + 0 => 'LaravelSmpp\\LaravelSmppServiceProvider', + ), + ), 'laravel/tinker' => array ( 'providers' => diff --git a/storage/framework/services.php b/storage/framework/services.php index d3d9c46d6..60170b8b7 100644 --- a/storage/framework/services.php +++ b/storage/framework/services.php @@ -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 (