@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace Integracao\ControlPay\Contracts\Pedido; |
4 | 4 | |
5 | 5 | use Integracao\ControlPay\Helpers\SerializerHelper; |
6 | -use Integracao\ControlPay\Model\IntencaoVenda; |
|
7 | 6 | use Integracao\ControlPay\Model\Pedido; |
8 | 7 | |
9 | 8 | /** |
@@ -63,7 +63,7 @@ |
||
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; |
@@ -63,8 +63,9 @@ |
||
63 | 63 | { |
64 | 64 | $this->pedido = $pedido; |
65 | 65 | |
66 | - if(is_array($this->pedido)) |
|
67 | - $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class); |
|
66 | + if(is_array($this->pedido)) { |
|
67 | + $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class); |
|
68 | + } |
|
68 | 69 | |
69 | 70 | return $this; |
70 | 71 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @param \DateTime $data |
47 | - * @return InserirResponse |
|
47 | + * @return GetByFiltrosResponse |
|
48 | 48 | */ |
49 | 49 | public function setData($data) |
50 | 50 | { |
@@ -67,7 +67,7 @@ |
||
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 | } |
@@ -66,8 +66,9 @@ |
||
66 | 66 | */ |
67 | 67 | public function setPedidos($pedidos) |
68 | 68 | { |
69 | - foreach ($pedidos as $pedido) |
|
70 | - $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class); |
|
69 | + foreach ($pedidos as $pedido) { |
|
70 | + $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class); |
|
71 | + } |
|
71 | 72 | |
72 | 73 | return $this; |
73 | 74 | } |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace Integracao\ControlPay\Contracts\Pedido; |
4 | 4 | |
5 | 5 | use Integracao\ControlPay\Helpers\SerializerHelper; |
6 | -use Integracao\ControlPay\Model\IntencaoVenda; |
|
7 | 6 | use Integracao\ControlPay\Model\Pedido; |
8 | 7 | |
9 | 8 | /** |
@@ -63,7 +63,7 @@ |
||
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; |
@@ -63,8 +63,9 @@ |
||
63 | 63 | { |
64 | 64 | $this->pedido = $pedido; |
65 | 65 | |
66 | - if(is_array($this->pedido)) |
|
67 | - $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class); |
|
66 | + if(is_array($this->pedido)) { |
|
67 | + $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class); |
|
68 | + } |
|
68 | 69 | |
69 | 70 | return $this; |
70 | 71 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @param \DateTime $data |
47 | - * @return InserirResponse |
|
47 | + * @return GetByPessoaIdByReferenciaResponse |
|
48 | 48 | */ |
49 | 49 | public function setData($data) |
50 | 50 | { |
@@ -67,7 +67,7 @@ |
||
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 | } |
@@ -66,8 +66,9 @@ |
||
66 | 66 | */ |
67 | 67 | public function setPedidos($pedidos) |
68 | 68 | { |
69 | - foreach ($pedidos as $pedido) |
|
70 | - $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class); |
|
69 | + foreach ($pedidos as $pedido) { |
|
70 | + $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class); |
|
71 | + } |
|
71 | 72 | |
72 | 73 | return $this; |
73 | 74 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @param \DateTime $data |
47 | - * @return InserirResponse |
|
47 | + * @return GetPedidosByPessoaIdResponse |
|
48 | 48 | */ |
49 | 49 | public function setData($data) |
50 | 50 | { |
@@ -67,7 +67,7 @@ |
||
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 | } |
@@ -66,8 +66,9 @@ |
||
66 | 66 | */ |
67 | 67 | public function setPedidos($pedidos) |
68 | 68 | { |
69 | - foreach ($pedidos as $pedido) |
|
70 | - $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class); |
|
69 | + foreach ($pedidos as $pedido) { |
|
70 | + $this->pedidos[] = SerializerHelper::denormalize($pedido, Pedido::class); |
|
71 | + } |
|
71 | 72 | |
72 | 73 | return $this; |
73 | 74 | } |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Integracao\ControlPay\Contracts\Pedido; |
4 | 4 | |
5 | -use Integracao\ControlPay\Helpers\SerializerHelper; |
|
6 | 5 | use Integracao\ControlPay\Model\Produto; |
7 | 6 | |
8 | 7 | /** |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace Integracao\ControlPay\Contracts\Pedido; |
4 | 4 | |
5 | 5 | use Integracao\ControlPay\Helpers\SerializerHelper; |
6 | -use Integracao\ControlPay\Model\IntencaoVenda; |
|
7 | 6 | use Integracao\ControlPay\Model\Pedido; |
8 | 7 | |
9 | 8 | /** |
@@ -63,7 +63,7 @@ |
||
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; |
@@ -63,8 +63,9 @@ |
||
63 | 63 | { |
64 | 64 | $this->pedido = $pedido; |
65 | 65 | |
66 | - if(is_array($this->pedido)) |
|
67 | - $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class); |
|
66 | + if(is_array($this->pedido)) { |
|
67 | + $this->pedido = SerializerHelper::denormalize($this->pedido, Pedido::class); |
|
68 | + } |
|
68 | 69 | |
69 | 70 | return $this; |
70 | 71 | } |
@@ -30,17 +30,17 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -34,10 +34,11 @@ discard block |
||
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 | |
43 | 44 | $this->response = $this->_httpClient->post(__FUNCTION__,[ |
@@ -48,11 +49,11 @@ discard block |
||
48 | 49 | $this->response->json(), |
49 | 50 | Pedido\InserirResponse::class |
50 | 51 | ); |
51 | - }catch (RequestException $ex) { |
|
52 | + } catch (RequestException $ex) { |
|
52 | 53 | $this->response = $ex->getResponse(); |
53 | 54 | $responseBody = $ex->getResponse()->json(); |
54 | 55 | throw new \Exception($responseBody['message']); |
55 | - }catch (\Exception $ex){ |
|
56 | + } catch (\Exception $ex){ |
|
56 | 57 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
57 | 58 | } |
58 | 59 | } |
@@ -73,11 +74,11 @@ discard block |
||
73 | 74 | $this->response->json(), |
74 | 75 | Pedido\GetByFiltrosResponse::class |
75 | 76 | ); |
76 | - }catch (RequestException $ex) { |
|
77 | + } catch (RequestException $ex) { |
|
77 | 78 | $this->response = $ex->getResponse(); |
78 | 79 | $responseBody = $ex->getResponse()->json(); |
79 | 80 | throw new \Exception($responseBody['message']); |
80 | - }catch (\Exception $ex){ |
|
81 | + } catch (\Exception $ex){ |
|
81 | 82 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
82 | 83 | } |
83 | 84 | } |
@@ -102,11 +103,11 @@ discard block |
||
102 | 103 | $this->response->json(), |
103 | 104 | Pedido\GetByPessoaIdByReferenciaResponse::class |
104 | 105 | ); |
105 | - }catch (RequestException $ex) { |
|
106 | + } catch (RequestException $ex) { |
|
106 | 107 | $this->response = $ex->getResponse(); |
107 | 108 | $responseBody = $ex->getResponse()->json(); |
108 | 109 | throw new \Exception($responseBody['message']); |
109 | - }catch (\Exception $ex){ |
|
110 | + } catch (\Exception $ex){ |
|
110 | 111 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
111 | 112 | } |
112 | 113 | } |
@@ -131,11 +132,11 @@ discard block |
||
131 | 132 | $this->response->json(), |
132 | 133 | Pedido\GetByPessoaIdByReferenciaResponse::class |
133 | 134 | ); |
134 | - }catch (RequestException $ex) { |
|
135 | + } catch (RequestException $ex) { |
|
135 | 136 | $this->response = $ex->getResponse(); |
136 | 137 | $responseBody = $ex->getResponse()->json(); |
137 | 138 | throw new \Exception($responseBody['message']); |
138 | - }catch (\Exception $ex){ |
|
139 | + } catch (\Exception $ex){ |
|
139 | 140 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
140 | 141 | } |
141 | 142 | } |
@@ -158,11 +159,11 @@ discard block |
||
158 | 159 | $this->response->json(), |
159 | 160 | Pedido\CancelarResponse::class |
160 | 161 | ); |
161 | - }catch (RequestException $ex) { |
|
162 | + } catch (RequestException $ex) { |
|
162 | 163 | $this->response = $ex->getResponse(); |
163 | 164 | $responseBody = $ex->getResponse()->json(); |
164 | 165 | throw new \Exception($responseBody['message']); |
165 | - }catch (\Exception $ex){ |
|
166 | + } catch (\Exception $ex){ |
|
166 | 167 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
167 | 168 | } |
168 | 169 | } |
@@ -185,11 +186,11 @@ discard block |
||
185 | 186 | $this->response->json(), |
186 | 187 | Pedido\GetByIdResponse::class |
187 | 188 | ); |
188 | - }catch (RequestException $ex) { |
|
189 | + } catch (RequestException $ex) { |
|
189 | 190 | $this->response = $ex->getResponse(); |
190 | 191 | $responseBody = $ex->getResponse()->json(); |
191 | 192 | throw new \Exception($responseBody['message']); |
192 | - }catch (\Exception $ex){ |
|
193 | + } catch (\Exception $ex){ |
|
193 | 194 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
194 | 195 | } |
195 | 196 | } |
@@ -42,19 +42,19 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -44,29 +44,33 @@ discard block |
||
44 | 44 | { |
45 | 45 | try{ |
46 | 46 | |
47 | - if(empty($venderRequest->getTerminalId())) |
|
48 | - $venderRequest->setTerminalId( |
|
47 | + if(empty($venderRequest->getTerminalId())) { |
|
48 | + $venderRequest->setTerminalId( |
|
49 | 49 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID) |
50 | 50 | ); |
51 | + } |
|
51 | 52 | |
52 | - if(empty($venderRequest->getFormaPagamentoId())) |
|
53 | - $venderRequest->setFormaPagamentoId( |
|
53 | + if(empty($venderRequest->getFormaPagamentoId())) { |
|
54 | + $venderRequest->setFormaPagamentoId( |
|
54 | 55 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_PAGAMENTO_ID) |
55 | 56 | ); |
57 | + } |
|
56 | 58 | |
57 | - if(empty($venderRequest->isAguardarTefIniciarTransacao())) |
|
58 | - $venderRequest->setAguardarTefIniciarTransacao( |
|
59 | + if(empty($venderRequest->isAguardarTefIniciarTransacao())) { |
|
60 | + $venderRequest->setAguardarTefIniciarTransacao( |
|
59 | 61 | boolval( |
60 | 62 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF) |
61 | 63 | ) |
62 | 64 | ); |
65 | + } |
|
63 | 66 | |
64 | 67 | foreach ($venderRequest->getProdutosVendidos() as $key => $produto) |
65 | 68 | { |
66 | - if(empty($produto->getId())) |
|
67 | - $venderRequest->getProdutosVendidos()[$key]->setId( |
|
69 | + if(empty($produto->getId())) { |
|
70 | + $venderRequest->getProdutosVendidos()[$key]->setId( |
|
68 | 71 | $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID) |
69 | 72 | ); |
73 | + } |
|
70 | 74 | } |
71 | 75 | |
72 | 76 | $this->response = $this->_httpClient->post(__FUNCTION__,[ |
@@ -77,11 +81,11 @@ discard block |
||
77 | 81 | $this->response->json(), |
78 | 82 | Contracts\Venda\VenderResponse::class |
79 | 83 | ); |
80 | - }catch (RequestException $ex) { |
|
84 | + } catch (RequestException $ex) { |
|
81 | 85 | $this->response = $ex->getResponse(); |
82 | 86 | $responseBody = $ex->getResponse()->json(); |
83 | 87 | throw new \Exception($responseBody['message']); |
84 | - }catch (\Exception $ex){ |
|
88 | + } catch (\Exception $ex){ |
|
85 | 89 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
86 | 90 | } |
87 | 91 | } |
@@ -96,19 +100,20 @@ discard block |
||
96 | 100 | try{ |
97 | 101 | $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest()); |
98 | 102 | |
99 | - if(empty($response->getPedido()->getId())) |
|
100 | - throw new \Exception("Falha ao inserir pedido"); |
|
103 | + if(empty($response->getPedido()->getId())) { |
|
104 | + throw new \Exception("Falha ao inserir pedido"); |
|
105 | + } |
|
101 | 106 | |
102 | 107 | $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId( |
103 | 108 | $response->getPedido()->getId() |
104 | 109 | ); |
105 | 110 | |
106 | 111 | return $this->vender($venderComPedidoRequest->getInventarioVenderRequest()); |
107 | - }catch (RequestException $ex) { |
|
112 | + } catch (RequestException $ex) { |
|
108 | 113 | $this->response = $ex->getResponse(); |
109 | 114 | $responseBody = $ex->getResponse()->json(); |
110 | 115 | throw new \Exception($responseBody['message']); |
111 | - }catch (\Exception $ex){ |
|
116 | + } catch (\Exception $ex){ |
|
112 | 117 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
113 | 118 | } |
114 | 119 | } |