One Hat Cyber Team
Your IP:
216.73.216.171
Server IP:
198.54.114.155
Server:
Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
Server Software:
LiteSpeed
PHP Version:
5.6.40
Create File
|
Create Folder
Execute
Dir :
~
/
home
/
fluxyjvi
/
public_html
/
assets
/
images
/
Edit File:
Account.tar
VoicePrice.php 0000644 00000000621 15107506645 0007315 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Account; class VoicePrice extends Price { /** * @var string */ protected $priceMethod = 'getOutboundVoicePrice'; } ClientFactory.php 0000644 00000001631 15107506645 0010035 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Account; use Psr\Container\ContainerInterface; use Vonage\Client\APIResource; use Vonage\Client\Credentials\Handler\BasicHandler; use Vonage\Client\Credentials\Handler\BasicQueryHandler; class ClientFactory { public function __invoke(ContainerInterface $container): Client { /** @var APIResource $accountApi */ $accountApi = $container->make(APIResource::class); $accountApi ->setBaseUrl($accountApi->getClient()->getRestUrl()) ->setIsHAL(false) ->setBaseUri('/account') ->setAuthHandler(new BasicQueryHandler()) ; return new Client($accountApi); } } Client.php 0000644 00000013702 15107506645 0006507 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Account; use Psr\Http\Client\ClientExceptionInterface; use Vonage\Client\APIClient; use Vonage\Client\APIResource; use Vonage\Client\Exception as ClientException; use Vonage\Client\Exception\Request as ClientRequestException; use Vonage\Entity\Filter\KeyValueFilter; use function count; use function is_null; use function json_decode; /** * @todo Unify the exception handling to avoid duplicated code and logic (ie: getPrefixPricing()) */ class Client implements APIClient { public function __construct(protected ?APIResource $accountAPI = null) { } public function getAPIResource(): APIResource { return clone $this->accountAPI; } /** * Returns pricing based on the prefix requested * * @return array<PrefixPrice> */ public function getPrefixPricing($prefix): array { $api = $this->getAPIResource(); $api->setBaseUri('/account/get-prefix-pricing/outbound'); $api->setCollectionName('prices'); $data = $api->search(new KeyValueFilter(['prefix' => $prefix])); if (count($data) === 0) { return []; } // Multiple countries can match each prefix $prices = []; foreach ($data as $p) { $prefixPrice = new PrefixPrice(); $prefixPrice->fromArray($p); $prices[] = $prefixPrice; } return $prices; } /** * Get SMS Pricing based on Country * * @throws ClientExceptionInterface * @throws ClientRequestException * @throws ClientException\Exception * @throws ClientException\Server */ public function getSmsPrice(string $country): SmsPrice { $body = $this->makePricingRequest($country, 'sms'); $smsPrice = new SmsPrice(); $smsPrice->fromArray($body); return $smsPrice; } /** * Get Voice pricing based on Country * * @throws ClientExceptionInterface * @throws ClientRequestException * @throws ClientException\Exception * @throws ClientException\Server */ public function getVoicePrice(string $country): VoicePrice { $body = $this->makePricingRequest($country, 'voice'); $voicePrice = new VoicePrice(); $voicePrice->fromArray($body); return $voicePrice; } /** * @throws ClientRequestException * @throws ClientException\Exception * @throws ClientException\Server * @throws ClientExceptionInterface * * @todo This should return an empty result instead of throwing an Exception on no results */ protected function makePricingRequest($country, $pricingType): array { $api = $this->getAPIResource(); $api->setBaseUri('/account/get-pricing/outbound/' . $pricingType); $results = $api->search(new KeyValueFilter(['country' => $country])); $pageData = $results->getPageData(); if (is_null($pageData)) { throw new ClientException\Server('No results found'); } return $pageData; } /** * Gets the accounts current balance in Euros * * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Server * * @todo This needs further investigated to see if '' can even be returned from this endpoint */ public function getBalance(): Balance { $data = $this->getAPIResource()->get('get-balance', [], ['accept' => 'application/json']); if (is_null($data)) { throw new ClientException\Server('No results found'); } return new Balance($data['value'], $data['autoReload']); } /** * @throws ClientExceptionInterface * @throws ClientException\Exception */ public function topUp($trx): void { $api = $this->getAPIResource(); $api->setBaseUri('/account/top-up'); $api->submit(['trx' => $trx]); } /** * Return the account settings * * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Server */ public function getConfig(): Config { $api = $this->getAPIResource(); $api->setBaseUri('/account/settings'); $body = $api->submit(); if ($body === '') { throw new ClientException\Server('Response was empty'); } $body = json_decode($body, true); return new Config( $body['mo-callback-url'], $body['dr-callback-url'], $body['max-outbound-request'], $body['max-inbound-request'], $body['max-calls-per-second'] ); } /** * Update account config * * @throws ClientExceptionInterface * @throws ClientException\Exception * @throws ClientException\Server */ public function updateConfig(array $options): Config { // supported options are SMS Callback and DR Callback $params = []; if (isset($options['sms_callback_url'])) { $params['moCallBackUrl'] = $options['sms_callback_url']; } if (isset($options['dr_callback_url'])) { $params['drCallBackUrl'] = $options['dr_callback_url']; } $api = $this->getAPIResource(); $api->setBaseUri('/account/settings'); $rawBody = $api->submit($params); if ($rawBody === '') { throw new ClientException\Server('Response was empty'); } $body = json_decode($rawBody, true); return new Config( $body['mo-callback-url'], $body['dr-callback-url'], $body['max-outbound-request'], $body['max-inbound-request'], $body['max-calls-per-second'] ); } } Balance.php 0000644 00000002027 15107506645 0006614 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Account; use Vonage\Entity\Hydrator\ArrayHydrateInterface; class Balance implements ArrayHydrateInterface { /** * @var array */ protected array $data; public function __construct($balance, $autoReload) { $this->data['balance'] = $balance; $this->data['auto_reload'] = $autoReload; } public function getBalance() { return $this->data['balance']; } public function getAutoReload() { return $this->data['auto_reload']; } public function fromArray(array $data): void { $this->data = [ 'balance' => $data['value'], 'auto_reload' => $data['autoReload'] ]; } public function toArray(): array { return $this->data; } } Config.php 0000644 00000005215 15107506645 0006476 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Account; use Vonage\Entity\Hydrator\ArrayHydrateInterface; use function is_null; class Config implements ArrayHydrateInterface { /** * @var array<string, mixed> */ protected $data = []; /** * @param string|int|null $max_outbound_request * @param string|int|null $max_inbound_request * @param string|int|null $max_calls_per_second */ public function __construct( ?string $sms_callback_url = null, ?string $dr_callback_url = null, $max_outbound_request = null, $max_inbound_request = null, $max_calls_per_second = null ) { if (!is_null($sms_callback_url)) { $this->data['sms_callback_url'] = $sms_callback_url; } if (!is_null($dr_callback_url)) { $this->data['dr_callback_url'] = $dr_callback_url; } if (!is_null($max_outbound_request)) { $this->data['max_outbound_request'] = $max_outbound_request; } if (!is_null($max_inbound_request)) { $this->data['max_inbound_request'] = $max_inbound_request; } if (!is_null($max_calls_per_second)) { $this->data['max_calls_per_second'] = $max_calls_per_second; } } public function getSmsCallbackUrl(): ?string { return $this->data['sms_callback_url']; } public function getDrCallbackUrl(): ?string { return $this->data['dr_callback_url']; } /** * @return string|int|null */ public function getMaxOutboundRequest() { return $this->data['max_outbound_request']; } /** * @return string|int|null */ public function getMaxInboundRequest() { return $this->data['max_inbound_request']; } /** * @return string|int|null */ public function getMaxCallsPerSecond() { return $this->data['max_calls_per_second']; } public function fromArray(array $data): void { $this->data = [ 'sms_callback_url' => $data['sms_callback_url'], 'dr_callback_url' => $data['dr_callback_url'], 'max_outbound_request' => $data['max_outbound_request'], 'max_inbound_request' => $data['max_inbound_request'], 'max_calls_per_second' => $data['max_calls_per_second'], ]; } public function toArray(): array { return $this->data; } } SmsPrice.php 0000644 00000000615 15107506645 0007015 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Account; class SmsPrice extends Price { /** * @var string */ protected $priceMethod = 'getOutboundSmsPrice'; } Price.php 0000644 00000007516 15107506646 0006342 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Account; use JsonSerializable; use RuntimeException; use Vonage\Entity\EntityInterface; use Vonage\Entity\Hydrator\ArrayHydrateInterface; use Vonage\Entity\JsonResponseTrait; use Vonage\Entity\JsonSerializableInterface; use Vonage\Entity\JsonSerializableTrait; use Vonage\Entity\JsonUnserializableInterface; use Vonage\Entity\NoRequestResponseTrait; use Vonage\Network; use function array_key_exists; use function ltrim; use function preg_replace; use function strtolower; abstract class Price implements EntityInterface, ArrayHydrateInterface { use JsonSerializableTrait; use NoRequestResponseTrait; use JsonResponseTrait; /** * @var array<string, mixed> */ protected $data = []; public function getCountryCode() { return $this->data['country_code']; } public function getCountryDisplayName(): ?string { return $this->data['country_display_name']; } public function getCountryName(): ?string { return $this->data['country_name']; } public function getDialingPrefix() { return $this->data['dialing_prefix']; } public function getDefaultPrice() { if (isset($this->data['default_price'])) { return $this->data['default_price']; } if (!array_key_exists('mt', $this->data)) { throw new RuntimeException( 'Unknown pricing for ' . $this->getCountryName() . ' (' . $this->getCountryCode() . ')' ); } return $this->data['mt']; } public function getCurrency(): ?string { return $this->data['currency']; } public function getNetworks() { return $this->data['networks']; } public function getPriceForNetwork($networkCode) { $networks = $this->getNetworks(); if (isset($networks[$networkCode])) { return $networks[$networkCode]->{$this->priceMethod}(); } return $this->getDefaultPrice(); } public function fromArray(array $data): void { // Convert CamelCase to snake_case as that's how we use array access in every other object $storage = []; foreach ($data as $k => $v) { $k = strtolower(ltrim(preg_replace('/[A-Z]([A-Z](?![a-z]))*/', '_$0', $k), '_')); // PrefixPrice fixes switch ($k) { case 'country': $k = 'country_code'; break; case 'name': $storage['country_display_name'] = $v; $storage['country_name'] = $v; break; case 'prefix': $k = 'dialing_prefix'; break; } $storage[$k] = $v; } // Create objects for all the nested networks too $networks = []; if (isset($data['networks'])) { foreach ($data['networks'] as $n) { if (isset($n['code'])) { $n['networkCode'] = $n['code']; unset($n['code']); } if (isset($n['network'])) { $n['networkName'] = $n['network']; unset($n['network']); } $network = new Network($n['networkCode'], $n['networkName']); $network->fromArray($n); $networks[$network->getCode()] = $network; } } $storage['networks'] = $networks; $this->data = $storage; } public function toArray(): array { return $this->data; } } PrefixPrice.php 0000644 00000001133 15107506646 0007505 0 ustar 00 <?php /** * Vonage Client Library for PHP * * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 */ declare(strict_types=1); namespace Vonage\Account; use Vonage\Client\Exception\Exception as ClientException; class PrefixPrice extends Price { protected $priceMethod = 'getPrefixPrice'; /** * @throws ClientException */ public function getCurrency(): ?string { throw new ClientException('Currency is unavailable from this endpoint'); } }
Simpan