Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrouh committed Mar 20, 2023
1 parent 22a421b commit 25bab7d
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/BaseClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@

class BaseClass
{
const Base_Url = 'https://4jawaly.net/api';
const Base_Url_New = 'https://api-sms.4jawaly.com/api/v1/account/area/sms/send';
const Base_Url = 'https://api-sms.4jawaly.com/api/v1/account/area';

public function getBalance()
{
try {
$data = [
'username' => config('sms4jawaly.username'),
'password' => config('sms4jawaly.password'),
'return' => 'json'
];

$response = Http::withOptions(['verify' => false])->get(self::Base_Url . '/getbalance.php', $data);
$response = json_decode($response);
return ['status' => true, 'response' => $response->currentuserpoints, 'message' => $response->MessageIs];
} catch (Exception $error) {
return ['status' => false, 'response' => $error, 'message' => 'error'];
$query = [];
$query["is_active"] = 1; // get active only
$query["order_by"] = "id"; // package_points, current_points, expire_at or id (default)
$query["order_by_type"] = "desc"; // desc or asc
$query["page"] = 1;
$query["page_size"] = 10;
$query["return_collection"] = 1; // if you want to get all collection
$response = Http::withBasicAuth(config('sms4jawaly.username'), config('sms4jawaly.password'))
->withHeaders([
'Accept' => 'application/json',
'Content-Type' => 'application/json',
])
->get(self::Base_Url . '/me/packages?' . http_build_query($query));
$response = (array)json_decode($response);

if ($response['code'] == 200) {
return ['status' => true, 'response' => $response['total_balance'], 'message' => $response['message']];
} else {
return ['status' => false, 'response' => 'error', 'message' => $response['message']];
}
}

Expand All @@ -36,7 +42,7 @@ public function sendSms($message, $phoneNumber, $phoneCode)
$messages["messages"][0]["sender"] = config('sms4jawaly.sender_name');

$response = Http::withBasicAuth(config('sms4jawaly.username'), config('sms4jawaly.password'))
->post(self::Base_Url_New, $messages);
->post(self::Base_Url . '/sms/send', $messages);

return json_decode($response);
}
Expand Down

0 comments on commit 25bab7d

Please sign in to comment.