NASER add jibit and send admin messages to bale
This commit is contained in:
@@ -10,8 +10,11 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
|
||||
|
||||
|
||||
class Controller extends BaseController
|
||||
@@ -69,7 +72,10 @@ class Controller extends BaseController
|
||||
"telegram" => [
|
||||
"token" => self::Config('telegram_bot_token')
|
||||
],
|
||||
|
||||
"bale" => [
|
||||
"token" => self::Config('bale_bot_token')
|
||||
// "token" => Setting::where('key', 'bale_bot_token')->where('is_active', true)->first()->value ?? null
|
||||
],
|
||||
"sms" => [
|
||||
'user_name' => 'ysms1362',
|
||||
'password' => 'tL4w0PfNy2()',
|
||||
@@ -79,7 +85,7 @@ class Controller extends BaseController
|
||||
$platforms = [];
|
||||
$send_sms = true;
|
||||
$user = User::where('mobile', $to)->first() ?: Customer::where('mobile', $to)->first();
|
||||
// if ($user) {
|
||||
if ($user) {
|
||||
//
|
||||
// // Telegram
|
||||
// if (isset($credentials['telegram']) && $user->telegram) {
|
||||
@@ -98,20 +104,20 @@ class Controller extends BaseController
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Bale
|
||||
// if (isset($credentials['bale']) && $user->bale) {
|
||||
// try {
|
||||
// Http::get("https://api.wwwapp.ir/bale_send.php", [
|
||||
// 'botToken' => $credentials['bale']['token'],
|
||||
// 'chatId' => $user->bale,
|
||||
// 'message' => "جناب {$user->name} {$msg}",
|
||||
// ]);
|
||||
// $platforms[] = "bale:{$user->bale}";
|
||||
// $send_sms = false;
|
||||
// } catch (\Exception $e) {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Bale
|
||||
if (isset($credentials['bale']) && $user->bale) {
|
||||
try {
|
||||
Http::withoutVerifying()->get("https://tapi.bale.ai/{$credentials['bale']['token']}/sendMessage", [
|
||||
'chat_id' => $user->bale,
|
||||
'text' => "جناب {$user->name} {$msg}",
|
||||
]);
|
||||
$platforms[] = "bale:{$user->bale}";
|
||||
$send_sms = false;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//SMS
|
||||
if ($send_sms or $force_method=="sms") {
|
||||
@@ -170,4 +176,32 @@ class Controller extends BaseController
|
||||
//
|
||||
// return $settingValue;
|
||||
}
|
||||
|
||||
public static function jibit($method, $p1 = null, $p2 = null, $p3 = null)
|
||||
{
|
||||
$apiData['refresh'] = Http::withoutVerifying()->withoutVerifying()->withToken(Storage::get('refreshTokenGibit'))
|
||||
->post("https://napi.jibit.ir/ide/v1/tokens/generate", ['apiKey' => "J5WxrPxPOg", 'secretKey' => "7dgeE70xQXsQL7r36j3wif6X9",])->json();
|
||||
Storage::put('accessTokenGibit', $apiData['refresh']['accessToken']);
|
||||
|
||||
if (!Storage::exists('accessTokenGibit') || !Storage::exists('refreshTokenGibit')) {
|
||||
Storage::put('accessTokenGibit', 'توکن اولیه');
|
||||
Storage::put('refreshTokenGibit', 'توکن رفرش اولیه');
|
||||
}
|
||||
|
||||
$apiData['cartMatching'] = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))->get("https://napi.jibit.ir/ide/v1/services/matching?cardNumber=$p1&nationalCode=$p2&birthDate=$p3")->json();
|
||||
if ((isset($apiData['cartMatching']['code'])) and $apiData['cartMatching']['code'] == "forbidden") {
|
||||
$apiData['refresh'] = Http::withoutVerifying()->withToken(Storage::get('refreshTokenGibit'))
|
||||
->post("https://napi.jibit.ir/ide/v1/tokens/generate", ['apiKey' => "J5WxrPxPOg", 'secretKey' => "7dgeE70xQXsQL7r36j3wif6X9",])->json();
|
||||
Storage::put('accessTokenGibit', $apiData['refresh']['accessToken']);
|
||||
Storage::put('refreshTokenGibit', $apiData['refresh']['refreshToken']);
|
||||
$apiData['cartMatching'] = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))->get("https://napi.jibit.ir/ide/v1/services/matching?cardNumber=$p1&nationalCode=$p2&birthDate=$p3")->json();
|
||||
}
|
||||
if (isset( $apiData['cartMatching']['matched']) and $apiData['cartMatching']['matched'] == true) {
|
||||
$apiData['cartData'] = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit'))->get("https://napi.jibit.ir/ide/v1/cards?number=$p1&iban=true")->json();
|
||||
return $apiData;
|
||||
} else {
|
||||
throw new UnprocessableEntityHttpException($apiData['cartMatching']['message']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user