protected function execute(InputInterface $input, OutputInterface $output)
 {
     $userResource = new UserResource($this->sourceClient);
     $result = $userResource->getList(1, 1000);
     foreach ($result['items'] as $user) {
         $data[] = ['username' => $user['username'], 'email' => isset($user['email']) ? $user['email'] : '', 'roles' => join(',', $user['roles'])];
     }
     $table = new Table($output);
     $table->setHeaders(['name', 'email', 'roles'])->setRows($data);
     $table->render();
 }
Ejemplo n.º 2
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use Survos\Client\SurvosClient;
use Survos\Client\Resource\UserResource;
$config = json_decode(file_get_contents(__DIR__ . '/config.json'), true);
$client = new SurvosClient($config['endpoint']);
if (!$client->authorize($config['username'], $config['password'])) {
    throw new \Exception('Wrong credentials!');
}
//user save
$data = ['username' => 'john85210101', 'email' => '*****@*****.**', 'name' => 'Nick'];
$resource = new UserResource($client);
$item = $resource->save($data);
$id = $item['id'];
//user getById
$item = $resource->getById($id);
//user getList
$page = 1;
$maxPerPage = 10;
$criteria = ['id' => $id];
$response = $resource->getList($page, $maxPerPage, $criteria);
//user delete
$result = $resource->deleteById($id);