Code Duplication    Length = 36-65 lines in 2 locations

src/Integracao/ControlPay/API/PagamentoExternoApi.php 1 location

@@ 15-50 (lines=36) @@
12
 * Class PagamentoExternoApi
13
 * @package Integracao\ControlPay\API
14
 */
15
class PagamentoExternoApi extends AbstractAPI
16
{
17
18
    /**
19
     * PagamentoExternoApi constructor.
20
     */
21
    public function __construct(Client $client = null)
22
    {
23
        parent::__construct('pagamentoExterno', $client);
24
    }
25
26
    /**
27
     * @param Contracts\PagamentoExterno\GetByFiltrosRequest $getByFiltrosRequest
28
     * @return Contracts\PagamentoExterno\GetByFiltrosResponse
29
     * @throws \Exception
30
     */
31
    public function getByFiltros(Contracts\PagamentoExterno\GetByFiltrosRequest $getByFiltrosRequest)
32
    {
33
        try{
34
            $response = $this->_httpClient->post(__FUNCTION__,[
35
                'body' => json_encode($getByFiltrosRequest),
36
            ]);
37
38
            return SerializerHelper::denormalize(
39
                $response->json(),
40
                Contracts\PagamentoExterno\GetByFiltrosResponse::class
41
            );
42
        }catch (RequestException $ex) {
43
            $responseBody = $ex->getResponse()->json();
44
            throw new \Exception($responseBody['message']);
45
        }catch (\Exception $ex){
46
            throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
47
        }
48
    }
49
50
}

src/Integracao/ControlPay/API/VendaApi.php 1 location

@@ 21-85 (lines=65) @@
18
 * Class VenderApi
19
 * @package Integracao\ControlPay\API
20
 */
21
class VendaApi extends AbstractAPI
22
{
23
24
    /**
25
     * VenderApi constructor.
26
     */
27
    public function __construct(Client $client = null)
28
    {
29
        parent::__construct('venda', $client);
30
    }
31
32
    /**
33
     * @param Contracts\Venda\VenderRequest $venderRequest
34
     * @return Contracts\Venda\VenderResponse
35
     * @throws \Exception
36
     */
37
    public function vender(Contracts\Venda\VenderRequest $venderRequest)
38
    {
39
        try{
40
            $response = $this->_httpClient->post(__FUNCTION__,[
41
                'body' => json_encode($venderRequest),
42
            ]);
43
44
            return SerializerHelper::denormalize(
45
                $response->json(),
46
                Contracts\Venda\VenderResponse::class
47
            );
48
        }catch (RequestException $ex) {
49
            $responseBody = $ex->getResponse()->json();
50
            throw new \Exception($responseBody['message']);
51
        }catch (\Exception $ex){
52
            throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
53
        }
54
    }
55
56
//    /**
57
//     * API Provavelmente descontinuada
58
//     *
59
//     * @return Contracts\Venda\ConsultarVendasResponse
60
//     * @throws \Exception
61
//     */
62
//    public function consultarVendas(array $ids = [])
63
//    {
64
//        try{
65
//            $response = $this->_httpClient->post(__FUNCTION__, [
66
//                'body' => json_encode(array_map(function($id){
67
//                    return [
68
//                        'Id' => (string)$id
69
//                    ];
70
//                },$ids))
71
//            ]);
72
//
73
//            return SerializerHelper::denormalize(
74
//                $response->json(),
75
//                Contracts\Venda\ConsultarVendasResponse::class
76
//            );
77
//        }catch (RequestException $ex) {
78
//            $responseBody = $ex->getResponse()->json();
79
//            throw new \Exception($responseBody['message']);
80
//        }catch (\Exception $ex){
81
//            throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
82
//        }
83
//    }
84
85
}