added url to whatsapp notif, email soon
This commit is contained in:
@@ -8,81 +8,94 @@ use Illuminate\Support\Str;
|
||||
|
||||
class WhatsappHelper
|
||||
{
|
||||
public static function approveExpense($phones, $expense_number)
|
||||
public static function approveExpense($phones, $expense_number, $url = null)
|
||||
{
|
||||
$client = new Client();
|
||||
$client = new Client();
|
||||
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah disetujui. Silahkan buka website untuk melihat detailnya.',
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
// Ensure the URL is formatted correctly
|
||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'json' => [
|
||||
'data' => $data
|
||||
]
|
||||
]);
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah disetujui. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
|
||||
return $response->getBody()->getContents();
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'json' => [
|
||||
'data' => $data
|
||||
]
|
||||
]);
|
||||
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
public static function rejectExpense($phones, $expense_number)
|
||||
{
|
||||
$client = new Client();
|
||||
public static function rejectExpense($phones, $expense_number, $url = null)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditolak. Silahkan buka website untuk melihat detailnya.',
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'json' => [
|
||||
'data' => $data
|
||||
]
|
||||
]);
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditolak. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'json' => [
|
||||
'data' => $data
|
||||
]
|
||||
]);
|
||||
|
||||
public static function finalApprove($phones, $expense_number)
|
||||
{
|
||||
$client = new Client();
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditutup karena telah selesai diproses. Silahkan buka website untuk melihat detailnya.',
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
public static function finalApprove($phones, $expense_number, $url = null)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'json' => [
|
||||
'data' => $data
|
||||
]
|
||||
]);
|
||||
if ($url && !preg_match('/^https?:\/\//', $url)) {
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
$data = [];
|
||||
foreach ($phones as $phone) {
|
||||
$data[] = [
|
||||
'phone' => $phone,
|
||||
'message' => 'Pengajuan pengeluaran anda dengan nomor *' . $expense_number . '* telah ditutup karena telah selesai diproses. Silahkan buka link berikut untuk melihat detailnya: ' . $url,
|
||||
'source' => 'web'
|
||||
];
|
||||
}
|
||||
|
||||
$response = $client->post(env('WABLAS_HOST') . '/api/v2/send-message', [
|
||||
'headers' => [
|
||||
'Authorization' => env('WABLAS_TOKEN'),
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
'json' => [
|
||||
'data' => $data
|
||||
]
|
||||
]);
|
||||
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user