Completed
Push — master ( 741114...78e68a )
by Adriano
09:10
created
src/Integracao/ControlPay/API/VendaApi.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             );
80 80
         }catch (RequestException $ex) {
81 81
             $this->requestException($ex);
82
-        }catch (\Exception $ex){
82
+        }catch (\Exception $ex) {
83 83
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
84 84
         }
85 85
     }
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function venderComPedido(Contracts\Venda\VenderComPedidoRequest $venderComPedidoRequest)
93 93
     {
94
-        try{
94
+        try {
95 95
             $response = $this->pedidoApi->insert($venderComPedidoRequest->getPedidoInserirRequest());
96 96
 
97
-            if(empty($response->getPedido()->getId()))
97
+            if (empty($response->getPedido()->getId()))
98 98
                 throw new \Exception("Falha ao inserir pedido");
99 99
 
100 100
             $venderComPedidoRequest->getInventarioVenderRequest()->setPedidoId(
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             return $this->vender($venderComPedidoRequest->getInventarioVenderRequest());
105 105
         }catch (RequestException $ex) {
106 106
             $this->requestException($ex);
107
-        }catch (\Exception $ex){
107
+        }catch (\Exception $ex) {
108 108
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
109 109
         }
110 110
     }
@@ -116,19 +116,19 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function cancelarVenda(Contracts\Venda\CancelarVendaRequest $cancelarVendaRequest)
118 118
     {
119
-        try{
119
+        try {
120 120
 
121
-            if(empty($cancelarVendaRequest->getTerminalId()))
121
+            if (empty($cancelarVendaRequest->getTerminalId()))
122 122
                 $cancelarVendaRequest->setTerminalId(
123 123
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_TERMINAL_ID)
124 124
                 );
125 125
 
126
-            if(empty($cancelarVendaRequest->getSenhaTecnica()))
126
+            if (empty($cancelarVendaRequest->getSenhaTecnica()))
127 127
                 $cancelarVendaRequest->setSenhaTecnica(
128 128
                     $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_SENHA_TECNICA)
129 129
                 );
130 130
 
131
-            if(empty($cancelarVendaRequest->isAguardarTefIniciarTransacao()))
131
+            if (empty($cancelarVendaRequest->isAguardarTefIniciarTransacao()))
132 132
                 $cancelarVendaRequest->setAguardarTefIniciarTransacao(
133 133
                     boolval(
134 134
                         $this->_client->getParameter(ControlPayParameterConst::CONTROLPAY_DEFAULT_FORMA_AGUARDA_TEF)
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                 );
137 137
 
138 138
 
139
-            $this->response = $this->_httpClient->post(__FUNCTION__,[
139
+            $this->response = $this->_httpClient->post(__FUNCTION__, [
140 140
                 'body' => json_encode($cancelarVendaRequest),
141 141
             ]);
142 142
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             );
147 147
         }catch (RequestException $ex) {
148 148
             $this->requestException($ex);
149
-        }catch (\Exception $ex){
149
+        }catch (\Exception $ex) {
150 150
             throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
151 151
         }
152 152
     }
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Contracts/Venda/CancelarVendaResponse.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
     {
63 63
         $this->intencaoVenda = $intencaoVenda;
64 64
 
65
-        if(is_array($this->intencaoVenda))
65
+        if (is_array($this->intencaoVenda))
66 66
             $this->intencaoVenda = SerializerHelper::denormalize($this->intencaoVenda, IntencaoVenda::class);
67 67
 
68 68
         return $this;
Please login to merge, or discard this patch.
src/Integracao/ControlPay/Client.php 1 patch
Spacing   +20 added lines, -20 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,23 +96,23 @@  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_DEFAULT_SENHA_TECNICA] = getenv('CONTROLPAY_DEFAULT_SENHA_TECNICA');
110
-        $this->_params[ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE] = KeyQueryStringAuthentication::class;
111
-
112
-        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_DEFAULT_SENHA_TECNICA ] = getenv('CONTROLPAY_DEFAULT_SENHA_TECNICA');
110
+        $this->_params[ ControlPayParameterConst::CONTROLPAY_OAUTH_TYPE ] = KeyQueryStringAuthentication::class;
111
+
112
+        if (!is_null($params))
113 113
             foreach ($params as $key => $param)
114 114
             {
115
-                if(!in_array($key, [
115
+                if (!in_array($key, [
116 116
                     ControlPayParameterConst::CONTROLPAY_HOST,
117 117
                     ControlPayParameterConst::CONTROLPAY_TIMEOUT,
118 118
                     ControlPayParameterConst::CONTROLPAY_USER,
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
                     throw new \Exception(sprintf("Parâmetro %s inválido", $key));
130 130
             }
131 131
 
132
-        if(!is_null($params) && is_array($params))
132
+        if (!is_null($params) && is_array($params))
133 133
             foreach ($params as $key => $value)
134
-                $this->_params[$key] = $value;
134
+                $this->_params[ $key ] = $value;
135 135
 
136
-        if(is_null($authentication))
136
+        if (is_null($authentication))
137 137
         {
138 138
             $this->authentication = AuthenticationFactory::getInstance($this->_params, $this);
139 139
             return;
Please login to merge, or discard this patch.