Completed
Push — master ( 5bc038...a8048c )
by Adriano
06:06
created
src/Integracao/ControlPay/API/VendaApi.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -42,40 +42,40 @@  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)
61 61
                     )
62 62
                 );
63 63
 
64
-            if(!empty($venderRequest->getProdutosVendidos()))
64
+            if (!empty($venderRequest->getProdutosVendidos()))
65 65
                 foreach ($venderRequest->getProdutosVendidos() as $key => $produto)
66 66
                 {
67
-                    if(empty($produto->getId()))
68
-                        $venderRequest->getProdutosVendidos()[$key]->setId(
67
+                    if (empty($produto->getId()))
68
+                        $venderRequest->getProdutosVendidos()[ $key ]->setId(
69 69
                             $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_ID)
70 70
                         );
71 71
 
72
-                    if(empty($produto->getQuantidade()))
73
-                        $venderRequest->getProdutosVendidos()[$key]->setQuantidade(
72
+                    if (empty($produto->getQuantidade()))
73
+                        $venderRequest->getProdutosVendidos()[ $key ]->setQuantidade(
74 74
                             $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_PRODUTO_QTDE)
75 75
                         );
76 76
                 }
77 77
 
78
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
78
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
79 79
                 'body' => json_encode($venderRequest),
80 80
             ]);
81 81
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             );
86 86
         }catch (RequestException $ex) {
87 87
             $this->requestException($ex);
88
-        }catch (\Exception $ex){
88
+        }catch (\Exception $ex) {
89 89
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
90 90
         }
91 91
     }
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function venderComPedido(Contracts\Venda\VenderComPedidoRequest $venderComPedidoRequest)
99 99
     {
100
-        try{
100
+        try {
101 101
             $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest());
102 102
 
103
-            if(empty($response->getPedido()->getId()))
103
+            if (empty($response->getPedido()->getId()))
104 104
                 throw new \Exception("Falha ao inserir pedido");
105 105
 
106 106
             $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId(
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             return $this->vender($venderComPedidoRequest->getInventarioVenderRequest());
111 111
         }catch (RequestException $ex) {
112 112
             $this->requestException($ex);
113
-        }catch (\Exception $ex){
113
+        }catch (\Exception $ex) {
114 114
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
115 115
         }
116 116
     }
@@ -122,19 +122,19 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function cancelarVenda(Contracts\Venda\CancelarVendaRequest $cancelarVendaRequest)
124 124
     {
125
-        try{
125
+        try {
126 126
 
127
-            if(empty($cancelarVendaRequest->getTerminalId()))
127
+            if (empty($cancelarVendaRequest->getTerminalId()))
128 128
                 $cancelarVendaRequest->setTerminalId(
129 129
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID)
130 130
                 );
131 131
 
132
-            if(empty($cancelarVendaRequest->getSenhaTecnica()))
132
+            if (empty($cancelarVendaRequest->getSenhaTecnica()))
133 133
                 $cancelarVendaRequest->setSenhaTecnica(
134 134
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA)
135 135
                 );
136 136
 
137
-            if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao()))
137
+            if (empty($cancelarVendaRequest->isAguardarTefIniciarTransacao()))
138 138
                 $cancelarVendaRequest->setAguardarTefIniciarTransacao(
139 139
                     boolval(
140 140
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF)
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                 );
143 143
 
144 144
 
145
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
145
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
146 146
                 'body' => json_encode($cancelarVendaRequest),
147 147
             ]);
148 148
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             );
153 153
         }catch (RequestException $ex) {
154 154
             $this->requestException($ex);
155
-        }catch (\Exception $ex){
155
+        }catch (\Exception $ex) {
156 156
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
157 157
         }
158 158
     }
Please login to merge, or discard this patch.