This commit is contained in:
Naden
2026-04-25 04:41:23 +07:00
commit 7e9668a552
195 changed files with 20254 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace ArelAyudhi\DhivaProdevWa;
/**
* @property Broadcast $broadcast
*/
const SEND_GROUP = "T2vGHuNWqwUQFtk2D96xt9Hkq8dyHEXVwBXPMz8_oaA";
const SEND_INSTAN = "T2vGHuNWqwUQFtk2D96xt3hwktFc4t7cTiz74HCwOaM";
class Broadcast extends ProdevMessagesAbstract
{
/** @param array{ daftar_group: string, daftar_pesan_id: string } $data */
public function sendGroup(string $daftar_group, string $daftar_pesan_id): array
{
$form = [
'daftar_group' => $daftar_group,
'daftar_pesan_id' => $daftar_pesan_id
];
$response = $this->client->request(
'POST',
SEND_GROUP,
[
'form_params' => $this->getform($form)
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function sendInstan(array $data): array
{
$response = $this->client->request(
'POST',
SEND_INSTAN,
[
'form_params' => $this->getform($data)
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace ArelAyudhi\DhivaProdevWa;
/**
* @property Group $multiple
*/
const GET_ALL = "4YsZVeivKQDHNbC9QapHxA";
const INSERT = "ucdyZBMN9J7hivfx1AQIeg";
const UPDATE = "H9w1hTiHDGgiINLIVCgqOg/";
class Group extends ProdevMessagesAbstract
{
public function getAll()
{
$response = $this->client->request(
'POST',
GET_ALL,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body);
}
}
/** @param array{ nama_group: string, isi_pesan: string } $data */
public function insert(string $nama_group, string $isi_pesan = '')
{
$form = [
'nama_group' => $nama_group,
'isi_pesan' => $isi_pesan
];
$response = $this->client->request(
'POST',
INSERT,
[
'form_params' => $this->getform($form)
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function update(string $nama_group, string $daftar_group_id): array
{
$form = [
'nama_group' => $nama_group,
];
$response = $this->client->request(
'POST',
UPDATE . $daftar_group_id,
[
'form_params' => $this->getform($form)
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body);
}
}
}

View File

@@ -0,0 +1,108 @@
<?php
namespace ArelAyudhi\DhivaProdevWa;
/**
* @property ListMessage $listmessage
*/
const GET_ALL = "380XyFK0cI_hY_wHrP4SjA";
const INSERT = "jn2GXQvR98hGPHIDqgqN8g";
const UPDATE = "sS9omGVprCLnzt1lq-7QQw/";
const SHOW_PESAN_BY_PESAN_ID = "RkL2559LgadI185K5-IthjCqvZSBEhWUEOj1AaxD6so/";
const DELETE = "F5y8aFIoVgS8zx5hmiVPEw/";
class ListMessage extends ProdevMessagesAbstract
{
public function getAll(): array
{
$response = $this->client->request(
'POST',
GET_ALL,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function insert(string $daftar_pesan_isi, string $judul_pesan): array
{
$form = $this->getform(
[
'daftar_pesan_isi' => $daftar_pesan_isi,
'judul_pesan' => $judul_pesan
]
);
$response = $this->client->request(
'POST',
INSERT,
[
'form_params' => $this->getform($form)
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function update(string $daftar_pesan_isi, string $judul_pesan, string $daftar_pesan_id): array
{
$form = $this->getform(
[
'daftar_pesan_isi' => $daftar_pesan_isi,
'judul_pesan' => $judul_pesan
]
);
$response = $this->client->request(
'POST',
UPDATE . $daftar_pesan_id,
[
'form_params' => $this->getform($form)
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function showByid(string $daftar_pesan_id): array
{
$response = $this->client->request(
'POST',
SHOW_PESAN_BY_PESAN_ID . $daftar_pesan_id,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function delete(string $daftar_pesan_id): array
{
$response = $this->client->request(
'POST',
DELETE . $daftar_pesan_id,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace ArelAyudhi\DhivaProdevWa;
/**
* @property Multiple $multiple
*/
class Multiple extends ProdevMessagesAbstract
{
public function sendText(string $username, string $password): array
{
$response = $this->client->request('POST', '/api/v2/send-message', [
'form_params' => [
'username' => $username,
'password' => $password,
'date' => $this->getMillisecond(),
],
]);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return (array)$body;
} else {
return $this->errorCode($body['errcode']);
}
}
}

View File

@@ -0,0 +1,84 @@
<?php
namespace ArelAyudhi\DhivaProdevWa;
// const URL = "http://localhost/adhivasindo/wa-api/index.php/RMuumzsQWg5HtzQb/";
const URL = "https://blast.awh.co.id/index.php/RMuumzsQWg5HtzQb/";
/**
* @property Group $group
* @property Multiple $multiple
* @property ListMessage $listmessage
* @property Broadcast $broadcast
* @property UserList $userlist
*/
class ProdevMessages
{
/**
* @var string
*/
private $ProdevToken = '';
/**
* @var \GuzzleHttp\Client
*/
private $client;
public function __construct(string $ProdevToken)
{
$headers = [
'Content-Type' => 'application/x-www-form-urlencoded'
];
$this->ProdevToken = $ProdevToken;
$this->client = new \GuzzleHttp\Client(
[
'base_uri' => URL,
'headers' => $headers,
],
);
}
protected $container = [];
protected $providers = [
"multiple" => Multiple::class,
"group" => Group::class,
"listmessage" => ListMessage::class,
"broadcast" => Broadcast::class,
"userlist" => UserList::class,
];
/**
* @param $name
* @return mixed
* @throws \Exception
*/
public function __get($name)
{
if (!isset($this->providers[$name])) {
throw new \Exception("class not found");
} else {
if (!isset($this->container[$name]) || !$this->container[$name] instanceof ProdevMessagesAbstract) {
try {
$this->container["{$name}"] = new $this->providers[$name]($this->ProdevToken, $this->client);
} catch (\Exception $e) {
throw new $e;
}
}
return $this->container["{$name}"];
}
}
static function getDateTimeMillisecond(string $dateTime): int
{
$dateTime = $dateTime . ".0";
list($usec, $sec) = explode(".", $dateTime);
$date = strtotime($usec);
$return_data = str_pad($date . $sec, 13, "0", STR_PAD_RIGHT);
return (int)$return_data;
}
/**
* @param string $dateTime
* @return int
*/
}

View File

@@ -0,0 +1,122 @@
<?php
namespace ArelAyudhi\DhivaProdevWa;
/**
* @property Group $group
* @property Multiple $multiple
*/
const error_code =
[
/**
* Account Error Code
*/
1 => "proses gagal",
10000 => "invalid client_id",
10001 => "invalid client",
10003 => "invalid token",
10004 => "invalid access",
10007 => "username atau password salah",
10011 => "invalid refresh token",
20002 => "not lock admin",
30002 => "invalid username, hanya huruf latin yang diperbolehkan",
30003 => "user sudah ada",
30004 => "invalid userid to delete",
30005 => "password harus md5 encrypted",
30006 => "exceeds the restrictions of API call number",
80000 => "date harus waktu sekarang, dalam 5 menit",
80002 => "invalid json format",
90000 => "internal server error",
-3 => "invalid parameter",
-2018 => "permission denied",
-4063 => "Please delete/transfer all yours locks first",
/**
* Lock Error Code
*/
-1003 => "lock tidak ada",
-2025 => "lock frozen, tidak bisa dioperasikan",
-3011 => "Cannot Transfer Lock(s) to Yourself",
-4043 => "The function is not supported for this lock",
-4056 => "run out of memory",
-4067 => "NB Device tidak terdaftar",
-4082 => "waktu auto locking tidak sah",
/**
* Gateway Error Code
*/
-2012 => "Lock tidak terhubung ke gateway manapun",
-3002 => "The gateway is offline. Please check and try again.",
-3003 => "gateway sibuk, coba lagi",
-3016 => "Cannot Transfer Gateway(s) to Yourself.",
-3034 => "Network not configed. Please config the network and try again.",
-3035 => "Wifi lock is in power saving mode, please turn off power saving and try again",
-3036 => "The lock is offline. Please check and try again",
-3037 => "The lock is busy. Please try again later",
-4037 => "No such Gateway exists",
/**
* RFID / IC Card Error Code
*/
-1021 => "This IC Card does not exist",
-1023 => "This Fingerprint does not exist",
/**
* Passcode Error Code
*/
-1007 => "No password data of this lock",
-2009 => "Invalid Password",
-3006 => "Invalid Passcode. Passcode should be between 6 - 9 Digits in length",
-3007 => "The same passcode already exists. Please use another one",
-3008 => "A Passcode that has never been used on the Lock cannot be changed",
-3009 => "There is NO SPACE to store Customized Passcodes. Please Delete Un-Used Customized Passcodes and try again",
];
/**
* Class BaseAbstract
*/
abstract class ProdevMessagesAbstract
{
/**
* @var string
*/
protected $ProdevToken = '';
/**
* @var \GuzzleHttp\Client
*/
protected $client;
final function __construct(string $ProdevToken, \GuzzleHttp\Client $client)
{
$this->ProdevToken = $ProdevToken;
$this->client = $client;
}
protected function getMillisecond()
{
list($t1, $t2) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000);
}
protected static function errorCode(int $code)
{
$data = [
'code' => $code,
'message' => error_code[$code]
];
return $data;
}
static function queryBuildier($get)
{
(string)$string = '';
foreach ($get as $key => $value) {
$string .= $key . '=' . $value . '&';
}
return substr_replace($string, "", -1);
}
function getform($form = [])
{
$option = [
'AccessToken' => $this->ProdevToken
];
if ($form) {
foreach ($form as $v => $d) {
$option[$v] = $d;
}
}
return $option;
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace ArelAyudhi\Prodev;
/**
* @property QrPayment $QrPayment
*/
const URL = "https://api.xendit.co/";
class ProdevXendit
{
/**
* @var string
*/
private $ProdevToken = '';
/**
* @var \GuzzleHttp\Client
*/
private $client;
public function __construct($xendit_key)
{
$headers = [
'Content-Type' => 'application/json',
'api-version' => ' 2022-07-31',
];
$this->client = new \GuzzleHttp\Client(
[
'base_uri' => URL,
'headers' => $headers,
'auth' => [$xendit_key, ''],
],
);
}
protected $container = [];
protected $providers = [
"QrPayment" => QrPayment::class,
"VirtualAccount" => VirtualAccount::class,
];
/**
* @param $name
* @return mixed
* @throws \Exception
*/
public function __get($name)
{
if (!isset($this->providers[$name])) {
throw new \Exception("class not found");
} else {
if (!isset($this->container[$name]) || !$this->container[$name] instanceof ProdevXenditAbstract) {
try {
$this->container["{$name}"] = new $this->providers[$name]($this->client);
} catch (\Exception $e) {
throw new $e;
}
}
return $this->container["{$name}"];
}
}
static function getDateTimeMillisecond(string $dateTime): int
{
$dateTime = $dateTime . ".0";
list($usec, $sec) = explode(".", $dateTime);
$date = strtotime($usec);
$return_data = str_pad($date . $sec, 13, "0", STR_PAD_RIGHT);
return (int)$return_data;
}
/**
* @param string $dateTime
* @return int
*/
}

View File

@@ -0,0 +1,121 @@
<?php
namespace ArelAyudhi\Prodev;
/**
* @property Group $group
* @property Multiple $multiple
*/
const error_code =
[
/**
* Account Error Code
*/
1 => "proses gagal",
10000 => "invalid client_id",
10001 => "invalid client",
10003 => "invalid token",
10004 => "invalid access",
10007 => "username atau password salah",
10011 => "invalid refresh token",
20002 => "not lock admin",
30002 => "invalid username, hanya huruf latin yang diperbolehkan",
30003 => "user sudah ada",
30004 => "invalid userid to delete",
30005 => "password harus md5 encrypted",
30006 => "exceeds the restrictions of API call number",
80000 => "date harus waktu sekarang, dalam 5 menit",
80002 => "invalid json format",
90000 => "internal server error",
-3 => "invalid parameter",
-2018 => "permission denied",
-4063 => "Please delete/transfer all yours locks first",
/**
* Lock Error Code
*/
-1003 => "lock tidak ada",
-2025 => "lock frozen, tidak bisa dioperasikan",
-3011 => "Cannot Transfer Lock(s) to Yourself",
-4043 => "The function is not supported for this lock",
-4056 => "run out of memory",
-4067 => "NB Device tidak terdaftar",
-4082 => "waktu auto locking tidak sah",
/**
* Gateway Error Code
*/
-2012 => "Lock tidak terhubung ke gateway manapun",
-3002 => "The gateway is offline. Please check and try again.",
-3003 => "gateway sibuk, coba lagi",
-3016 => "Cannot Transfer Gateway(s) to Yourself.",
-3034 => "Network not configed. Please config the network and try again.",
-3035 => "Wifi lock is in power saving mode, please turn off power saving and try again",
-3036 => "The lock is offline. Please check and try again",
-3037 => "The lock is busy. Please try again later",
-4037 => "No such Gateway exists",
/**
* RFID / IC Card Error Code
*/
-1021 => "This IC Card does not exist",
-1023 => "This Fingerprint does not exist",
/**
* Passcode Error Code
*/
-1007 => "No password data of this lock",
-2009 => "Invalid Password",
-3006 => "Invalid Passcode. Passcode should be between 6 - 9 Digits in length",
-3007 => "The same passcode already exists. Please use another one",
-3008 => "A Passcode that has never been used on the Lock cannot be changed",
-3009 => "There is NO SPACE to store Customized Passcodes. Please Delete Un-Used Customized Passcodes and try again",
];
/**
* Class BaseAbstract
*/
abstract class ProdevXenditAbstract
{
/**
* @var string
*/
protected $ProdevToken = '';
/**
* @var \GuzzleHttp\Client
*/
protected $client;
final function __construct(\GuzzleHttp\Client $client)
{
$this->client = $client;
}
protected function getMillisecond()
{
list($t1, $t2) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000);
}
protected static function errorCode(int $code)
{
$data = [
'code' => $code,
'message' => error_code[$code]
];
return $data;
}
static function queryBuildier($get)
{
(string)$string = '';
foreach ($get as $key => $value) {
$string .= $key . '=' . $value . '&';
}
return substr_replace($string, "", -1);
}
function getform($form = [])
{
$option = [
'AccessToken' => $this->ProdevToken
];
if ($form) {
foreach ($form as $v => $d) {
$option[$v] = $d;
}
}
return $option;
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace ArelAyudhi\Prodev;
/**
* @property QrPayment $QrPayment
*/
const CREATE_QR = "qr_codes";
const CHECK_QR = "qr_codes/";
class QrPayment extends ProdevXenditAbstract
{
/** @param array{ nama_penerima[0]: string, nomor_penerima[0]: string, nomor_penerima[0]: string } $data */
public function create_qr(array $data): array
{
// print_r($this->client);die;
$response = $this->client->request(
'POST',
CREATE_QR,
[
'body' => json_encode($data)
]
);
$body = json_decode($response->getBody()->getContents(), true);
return $body;
}
public function check_qr(string $data): array
{
$response = $this->client->request(
'GET',
CHECK_QR . $data,
);
$body = json_decode($response->getBody()->getContents(), true);
return $body;
}
}

View File

@@ -0,0 +1,161 @@
<?php
namespace ArelAyudhi\DhivaProdevWa;
/**
* @property UserList $userlist
*/
const USER_LIST_GET_ALL = "eXvZjC3J1L3eNrqTEfc8mQ";
const USER_LIST_ALL_BY_GROUP_ID = "O7skdKVrEKhNkzkJm2WjaQms5SWijPt7b7yclfXwFvrTksqxEylS7tZC-Yff4RsW/";
const USER_LIST_ALL_BY_NAMA = "O7skdKVrEKhNkzkJm2WjaYhTwxA7MOeaqdT04OR6P0o/";
const USER_LIST_ALL_BY_NOMOR_TELEPON = "O7skdKVrEKhNkzkJm2WjaZ4hncBYJmRW5G5UynOx7JXLKLtvEhDJI4Ql2wG5mB--/";
const USER_LIST_SHOW_BY_NAMA_ID = "o3O-xMLw9O65qs2ibXvUkXPd5nqGKyYF39S_Y3LVuaQoPq4rsejLJPHi93ha_ilo/";
const USER_LIST_INSERT = "omj4wqnUSftatKfOYM5jyFcmIBSCJuwm3XQAR-jeTVw";
const USER_LIST_UPDATE = "mcJ9dTuItmpxsD5CuSswKgVqCDFIj2sLeqvY_JkCNQw/";
const GET_ALL = "eXvZjC3J1L3eNrqTEfc8mQ";
const USER_LIST_DELETE = "ucenwGz_ed9qVf6QxFxExZb1nnBvKxdxdbAiDZUdup4/";
class UserList extends ProdevMessagesAbstract
{
public function getAll(): array
{
$response = $this->client->request(
'POST',
GET_ALL,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function allByGroupId(string $group_penerima): array
{
$response = $this->client->request(
'POST',
USER_LIST_ALL_BY_GROUP_ID . $group_penerima,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function allByNama(string $nama_penerima): array
{
$response = $this->client->request(
'POST',
USER_LIST_ALL_BY_NAMA . $nama_penerima,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function allByNomorTelepon(string $nomor_penerima): array
{
$response = $this->client->request(
'POST',
USER_LIST_ALL_BY_NOMOR_TELEPON . $nomor_penerima,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function showByNamaId(string $daftar_penerima_id): array
{
$response = $this->client->request(
'POST',
USER_LIST_SHOW_BY_NAMA_ID . $daftar_penerima_id,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
/** @param array{ nama_penerima[0]: string, nomor_penerima[0]: string, nomor_penerima[0]: string } $data */
public function insert(array $data): array
{
$response = $this->client->request(
'POST',
USER_LIST_INSERT,
[
'form_params' => $this->getform($data)
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function update(string $nama_penerima = '', int $nomor_penerima, string $group_penerima = '', string $daftar_penerima_id): array
{
$form = [];
if ($nama_penerima) {
$form['nama_penerima'] = $nama_penerima;
}
if ($nomor_penerima) {
$form['nomor_penerima'] = $nomor_penerima;
}
if ($group_penerima) {
$form['group_penerima'] = $group_penerima;
}
$response = $this->client->request(
'POST',
USER_LIST_UPDATE . $daftar_penerima_id,
[
'form_params' => $this->getform($form)
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
public function delete(string $daftar_penerima_id): array
{
$response = $this->client->request(
'POST',
USER_LIST_DELETE . $daftar_penerima_id,
[
'form_params' => $this->getform()
]
);
$body = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200) {
return $body;
} else {
return $this->errorCode($body['errcode']);
}
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace ArelAyudhi\Prodev;
/**
* @property VirtualAccount $VirtualAccount
*/
const CREATE_VA = "callback_virtual_accounts";
const CHECK_VA = "callback_virtual_accounts/";
class VirtualAccount extends ProdevXenditAbstract
{
/** @param array{ nama_penerima[0]: string, nomor_penerima[0]: string, nomor_penerima[0]: string } $data */
public function create_va(array $data): array
{
// print_r($this->client);die;
$response = $this->client->request(
'POST',
CREATE_VA,
[
'body' => json_encode($data)
]
);
$body = json_decode($response->getBody()->getContents(), true);
return $body;
}
public function check_va(string $data): array
{
$response = $this->client->request(
'GET',
CHECK_VA . $data,
);
$body = json_decode($response->getBody()->getContents(), true);
return $body;
}
}

View File

@@ -0,0 +1,11 @@
{
"name": "arelayudhi/dhiva-prodev-wa",
"description": "Dhiva WA",
"minimum-stability": "stable",
"prefer-stable": true,
"autoload": {
"psr-4": {
"ArelAyudhi\\DhivaProdevWa\\": "src/"
}
}
}