Completed
Push — master ( ac28ba...d1c608 )
by Adriano
05:00
created
src/Integracao/ControlPay/API/PedidoApi.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function insert(Pedido\InserirRequest $inserirRequest)
32 32
     {
33
-        try{
33
+        try {
34 34
 
35 35
             foreach ($inserirRequest->getProdutosPedido() as $key => $produto)
36 36
             {
37
-                if(empty($produto->getId()))
38
-                    $inserirRequest->getProdutosPedido()[$key]->setId(
37
+                if (empty($produto->getId()))
38
+                    $inserirRequest->getProdutosPedido()[ $key ]->setId(
39 39
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID)
40 40
                     );
41 41
             }
42 42
 
43
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
43
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
44 44
                 'body' => json_encode($inserirRequest),
45 45
             ]);
46 46
 
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
         }catch (RequestException $ex) {
52 52
             $this->response = $ex->getResponse();
53 53
             $responseBody = $ex->getResponse()->json();
54
-            throw new \Exception($responseBody['message']);
55
-        }catch (\Exception $ex){
54
+            throw new \Exception($responseBody[ 'message' ]);
55
+        }catch (\Exception $ex) {
56 56
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
57 57
         }
58 58
     }
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function getByFiltros(Pedido\GetByFiltrosRequest $getByFiltrosRequest)
66 66
     {
67
-        try{
68
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
67
+        try {
68
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
69 69
                 'body' => json_encode($getByFiltrosRequest),
70 70
             ]);
71 71
 
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
         }catch (RequestException $ex) {
77 77
             $this->response = $ex->getResponse();
78 78
             $responseBody = $ex->getResponse()->json();
79
-            throw new \Exception($responseBody['message']);
80
-        }catch (\Exception $ex){
79
+            throw new \Exception($responseBody[ 'message' ]);
80
+        }catch (\Exception $ex) {
81 81
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
82 82
         }
83 83
     }
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function getByPessoaIdByReferencia($pessoaId, $pedidoReferencia)
92 92
     {
93
-        try{
94
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
93
+        try {
94
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
95 95
                 'query' => $this->addQueryAdditionalParameters([
96 96
                     'pessoaId' => $pessoaId,
97 97
                     'pedidoReferencia' => $pedidoReferencia
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
         }catch (RequestException $ex) {
106 106
             $this->response = $ex->getResponse();
107 107
             $responseBody = $ex->getResponse()->json();
108
-            throw new \Exception($responseBody['message']);
109
-        }catch (\Exception $ex){
108
+            throw new \Exception($responseBody[ 'message' ]);
109
+        }catch (\Exception $ex) {
110 110
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
111 111
         }
112 112
     }
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function getPedidosByPessoaId($pessoaVendedorId, $pedidoId)
121 121
     {
122
-        try{
123
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
122
+        try {
123
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
124 124
                 'query' => $this->addQueryAdditionalParameters([
125 125
                     'pessoaVendedorId' => $pessoaVendedorId,
126 126
                     'pedidoId' => $pedidoId
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
         }catch (RequestException $ex) {
135 135
             $this->response = $ex->getResponse();
136 136
             $responseBody = $ex->getResponse()->json();
137
-            throw new \Exception($responseBody['message']);
138
-        }catch (\Exception $ex){
137
+            throw new \Exception($responseBody[ 'message' ]);
138
+        }catch (\Exception $ex) {
139 139
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
140 140
         }
141 141
     }
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function cancelar($pedidoId)
149 149
     {
150
-        try{
151
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
150
+        try {
151
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
152 152
                 'query' => $this->addQueryAdditionalParameters([
153 153
                     'pedidoId' => $pedidoId
154 154
                 ])
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
         }catch (RequestException $ex) {
162 162
             $this->response = $ex->getResponse();
163 163
             $responseBody = $ex->getResponse()->json();
164
-            throw new \Exception($responseBody['message']);
165
-        }catch (\Exception $ex){
164
+            throw new \Exception($responseBody[ 'message' ]);
165
+        }catch (\Exception $ex) {
166 166
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
167 167
         }
168 168
     }
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function getById($pedidoId)
176 176
     {
177
-        try{
178
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
177
+        try {
178
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
179 179
                 'query' => $this->addQueryAdditionalParameters([
180 180
                     'pedidoId' => $pedidoId
181 181
                 ])
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
         }catch (RequestException $ex) {
189 189
             $this->response = $ex->getResponse();
190 190
             $responseBody = $ex->getResponse()->json();
191
-            throw new \Exception($responseBody['message']);
192
-        }catch (\Exception $ex){
191
+            throw new \Exception($responseBody[ 'message' ]);
192
+        }catch (\Exception $ex) {
193 193
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
194 194
         }
195 195
     }
Please login to merge, or discard this patch.
src/Integracao/ControlPay/API/VendaApi.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -42,19 +42,19 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function vender(Contracts\Venda\VenderRequest $venderRequest)
44 44
     {
45
-        try{
45
+        try {
46 46
 
47
-            if(empty($venderRequest->getTerminalId()))
47
+            if (empty($venderRequest->getTerminalId()))
48 48
                 $venderRequest->setTerminalId(
49 49
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID)
50 50
                 );
51 51
 
52
-            if(empty($venderRequest->getFormaPagamentoId()))
52
+            if (empty($venderRequest->getFormaPagamentoId()))
53 53
                 $venderRequest->setFormaPagamentoId(
54 54
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID)
55 55
                 );
56 56
 
57
-            if(empty($venderRequest->isAguardarTefIniciarTransacao()))
57
+            if (empty($venderRequest->isAguardarTefIniciarTransacao()))
58 58
                 $venderRequest->setAguardarTefIniciarTransacao(
59 59
                     boolval(
60 60
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF)
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 
64 64
             foreach ($venderRequest->getProdutosVendidos() as $key => $produto)
65 65
             {
66
-                if(empty($produto->getId()))
67
-                    $venderRequest->getProdutosVendidos()[$key]->setId(
66
+                if (empty($produto->getId()))
67
+                    $venderRequest->getProdutosVendidos()[ $key ]->setId(
68 68
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID)
69 69
                     );
70 70
             }
71 71
 
72
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
72
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
73 73
                 'body' => json_encode($venderRequest),
74 74
             ]);
75 75
 
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
         }catch (RequestException $ex) {
81 81
             $this->response = $ex->getResponse();
82 82
             $responseBody = $ex->getResponse()->json();
83
-            throw new \Exception($responseBody['message']);
84
-        }catch (\Exception $ex){
83
+            throw new \Exception($responseBody[ 'message' ]);
84
+        }catch (\Exception $ex) {
85 85
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
86 86
         }
87 87
     }
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function venderComPedido(Contracts\Venda\VenderComPedidoRequest $venderComPedidoRequest)
95 95
     {
96
-        try{
96
+        try {
97 97
             $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest());
98 98
 
99
-            if(empty($response->getPedido()->getId()))
99
+            if (empty($response->getPedido()->getId()))
100 100
                 throw new \Exception("Falha ao inserir pedido");
101 101
 
102 102
             $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId(
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
         }catch (RequestException $ex) {
108 108
             $this->response = $ex->getResponse();
109 109
             $responseBody = $ex->getResponse()->json();
110
-            throw new \Exception($responseBody['message']);
111
-        }catch (\Exception $ex){
110
+            throw new \Exception($responseBody[ 'message' ]);
111
+        }catch (\Exception $ex) {
112 112
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
113 113
         }
114 114
     }
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Client.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function getParameter($key)
72 72
     {
73
-        return isset($this->_params[$key]) ? $this->_params[$key] : null;
73
+        return isset($this->_params[ $key ]) ? $this->_params[ $key ] : null;
74 74
     }
75 75
 
76 76
     /**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function setParameter($key, $value)
84 84
     {
85
-        $this->_params[$key] = $value;
85
+        $this->_params[ $key ] = $value;
86 86
         $this->loadParameters($this->_params, $this->authentication);
87 87
         return $this;
88 88
     }
@@ -96,22 +96,22 @@  discard block
 block discarded – undo
96 96
      */
97 97
     private function loadParameters($params, IAuthentication $authentication = null)
98 98
     {
99
-        $this->_params[ControlPayParameterConst::CONTROLPAY_HOST] = getenv('CONTROLPAY_HOST');
100
-        $this->_params[ControlPayParameterConst::CONTROLPAY_TIMEOUT] = getenv('CONTROLPAY_TIMEOUT');
101
-        $this->_params[ControlPayParameterConst::CONTROLPAY_USER] = getenv('CONTROLPAY_USER');
102
-        $this->_params[ControlPayParameterConst::CONTROLPAY_PWD] = getenv('CONTROLPAY_PWD');
103
-        $this->_params[ControlPayParameterConst::CONTROLPAY_KEY] = getenv('CONTROLPAY_KEY');
104
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_PESSOA_ID] = getenv('CONTROLPAY_DEFAULT_PESSOA_ID');
105
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID] = getenv('CONTROLPAY_DEFAULT_TERMINAL_ID');
106
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID] = getenv('CONTROLPAY_DEFAULT_PRODUTO_ID');
107
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID] = getenv('CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID');
108
-        $this->_params[ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF] = getenv('CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF');
109
-        $this->_params[ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE] = KeyQueryStringAuthentication::class;
110
-
111
-        if(!is_null($params))
99
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_HOST ] = getenv('CONTROLPAY_HOST');
100
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_TIMEOUT ] = getenv('CONTROLPAY_TIMEOUT');
101
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_USER ] = getenv('CONTROLPAY_USER');
102
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_PWD ] = getenv('CONTROLPAY_PWD');
103
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_KEY ] = getenv('CONTROLPAY_KEY');
104
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_PESSOA_ID ] = getenv('CONTROLPAY_DEFAULT_PESSOA_ID');
105
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID ] = getenv('CONTROLPAY_DEFAULT_TERMINAL_ID');
106
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID ] = getenv('CONTROLPAY_DEFAULT_PRODUTO_ID');
107
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID ] = getenv('CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID');
108
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF ] = getenv('CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF');
109
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE ] = KeyQueryStringAuthentication::class;
110
+
111
+        if (!is_null($params))
112 112
             foreach ($params as $key => $param)
113 113
             {
114
-                if(!in_array($key, [
114
+                if (!in_array($key, [
115 115
                     ControlPayParameterConst::CONTROLPAY_HOST,
116 116
                     ControlPayParameterConst::CONTROLPAY_TIMEOUT,
117 117
                     ControlPayParameterConst::CONTROLPAY_USER,
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
                     throw new \Exception(sprintf("Parâmetro %s inválido", $key));
128 128
             }
129 129
 
130
-        if(!is_null($params) && is_array($params))
130
+        if (!is_null($params) && is_array($params))
131 131
             foreach ($params as $key => $value)
132
-                $this->_params[$key] = $value;
132
+                $this->_params[ $key ] = $value;
133 133
 
134
-        if(is_null($authentication))
134
+        if (is_null($authentication))
135 135
         {
136 136
             $this->authentication = AuthenticationFactory::getInstance($this->_params, $this);
137 137
             return;
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Model/Pedido.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     public function setProdutos($produtos)
205 205
     {
206 206
         foreach ($produtos as $produto)
207
-            $this->produtos[] = SerializerHelper::denormalize($produto, Produto::class);
207
+            $this->produtos[ ] = SerializerHelper::denormalize($produto, Produto::class);
208 208
 
209 209
         return $this;
210 210
     }
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
     {
442 442
         $this->pedidoStatus = $pedidoStatus;
443 443
 
444
-        if(is_array($this->pedidoStatus))
444
+        if (is_array($this->pedidoStatus))
445 445
             $this->pedidoStatus = SerializerHelper::denormalize($this->pedidoStatus, PedidoStatus::class);
446 446
 
447 447
         return $this;
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Contracts/Pedido/GetByFiltrosRequest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@
 block discarded – undo
155 155
         return [
156 156
             'status' => $this->status,
157 157
             'dataInicio' => empty($this->dataInicio) ? null : $this->dataInicio->format('d/m/Y H:i:s'),
158
-            'dataFim' => empty($this->dataFim) ? null :$this->dataFim->format('d/m/Y H:i:s'),
158
+            'dataFim' => empty($this->dataFim) ? null : $this->dataFim->format('d/m/Y H:i:s'),
159 159
             'tipo' => $this->tipo,
160 160
             'valorComDivergencia' => $this->valorComDivergencia,
161 161
             'referencia' => $this->referencia
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Contracts/Pedido/InserirResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
     {
64 64
         $this->pedido = $pedido;
65 65
 
66
-        if(is_array($this->pedido))
66
+        if (is_array($this->pedido))
67 67
             $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class);
68 68
 
69 69
         return $this;
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Contracts/Pedido/GetByFiltrosResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
     public function setPedidos($pedidos)
68 68
     {
69 69
         foreach ($pedidos as $pedido)
70
-            $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class);
70
+            $this->pedidos[ ] = SerializerHelper::denormalize($pedido, Pedido::class);
71 71
 
72 72
         return $this;
73 73
     }
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Contracts/Pedido/GetByIdResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
     {
64 64
         $this->pedido = $pedido;
65 65
 
66
-        if(is_array($this->pedido))
66
+        if (is_array($this->pedido))
67 67
             $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class);
68 68
 
69 69
         return $this;
Please login to merge, or discard this patch.
ControlPay/Contracts/Pedido/GetByPessoaIdByReferenciaResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
     public function setPedidos($pedidos)
68 68
     {
69 69
         foreach ($pedidos as $pedido)
70
-            $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class);
70
+            $this->pedidos[ ] = SerializerHelper::denormalize($pedido, Pedido::class);
71 71
 
72 72
         return $this;
73 73
     }
Please login to merge, or discard this patch.