<?php
namespace App\RequestManager;
use GuzzleHttp\Exception\GuzzleException;
use Paynetics\Exception\ApiException;
use Paynetics\HttpRequest\ApiHttpRequestService;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
class RiskRequestManager extends ApiHttpRequestService
{
protected const SERVICE = 'RISK_SERVICE';
/**
* @return mixed|ResponseInterface|HttpException
* @throws ApiException
* @throws GuzzleException
* @throws \JsonException
*/
public function checks()
{
return $this->get('/v1/company/risks/checks');
}
/**
* @param string $code
* @return mixed|ResponseInterface|HttpException
* @throws ApiException
* @throws GuzzleException
* @throws \JsonException
*/
public function show(string $code)
{
return $this->get('/v1/company/risks/{code}/definitions', compact('code'));
}
/**
* @throws ApiException
* @throws GuzzleException
* @throws \JsonException
*/
public function showRiskHistory(string $merchant, int $from = 1, int $limit = 20)
{
return $this->get('/v1/company/risks/list/{from}/{limit}', compact('from', 'limit'), compact('merchant'));
}
/**
* @throws GuzzleException
* @throws ApiException
*/
public function update($data)
{
return $this->put('/v1/company/risks/definitions/{id}', $data, ['id' => $data['id']]);
}
/**
* @throws ApiException
* @throws GuzzleException
*/
public function remove($id)
{
return $this->delete('/v1/company/risks/definitions/{id}', [], compact('id'));
}
/**
* @throws ApiException
* @throws GuzzleException
*/
public function create($data)
{
$data = $this->serialize($data, [AbstractObjectNormalizer::SKIP_NULL_VALUES => true]);
return $this->post('/v1/company/risks/definitions', $data);
}
/**
* @return mixed|ResponseInterface|HttpException
* @throws ApiException
* @throws GuzzleException
* @throws \JsonException
*/
public function showLevels()
{
return $this->get('/v1/person/risks/levels');
}
/**
* @param $data
* @return mixed|ResponseInterface|HttpException|null
* @throws ApiException
* @throws GuzzleException
*/
public function updateLevels($data)
{
return $this->post('/v1/person/risks/levels', $data, [], true);
}
public function showPersonRisk($type)
{
return $this->get('/v1/person/risks/{type}/definition', compact('type'));
}
public function removePerson($id)
{
return $this->delete('/v1/person/risks/definitions/{id}', [], compact('id'));
}
public function createPerson($data)
{
$data = $this->serialize($data, [AbstractObjectNormalizer::SKIP_NULL_VALUES => true]);
return $this->post('/v1/person/risks/definitions', $data);
}
public function updatePerson($data, $id)
{
return $this->put('/v1/person/risks/definitions/{id}', $data, compact('id'));
}
}