@@ -61,8 +61,9 @@ discard block |
||
61 | 61 | $this->endpoint = $endpoint; |
62 | 62 | $this->client = $client; |
63 | 63 | |
64 | - if(is_null($this->client)) |
|
65 | - $this->client = new Client(); |
|
64 | + if(is_null($this->client)) { |
|
65 | + $this->client = new Client(); |
|
66 | + } |
|
66 | 67 | |
67 | 68 | $this->headers['x-application-key'] = $this->client->getParameter( |
68 | 69 | PayGoTransactionParameterConst::PAYGO_TRANSACTIONS_TOKEN); |
@@ -70,8 +71,9 @@ discard block |
||
70 | 71 | $baseUrl = $this->client->getParameter( |
71 | 72 | PayGoTransactionParameterConst::PAYGO_TRANSACTIONS_HOST); |
72 | 73 | |
73 | - if(!empty($endpoint)) |
|
74 | - $baseUrl = sprintf("%s%s/", $baseUrl, $endpoint); |
|
74 | + if(!empty($endpoint)) { |
|
75 | + $baseUrl = sprintf("%s%s/", $baseUrl, $endpoint); |
|
76 | + } |
|
75 | 77 | |
76 | 78 | $this->httpClient = new GuzzleHttp\Client([ |
77 | 79 | 'base_url' => $baseUrl, |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | $this->params[PayGoTransactionParameterConst::PAYGO_TRANSACTIONS_TOKEN] = |
77 | 77 | getenv('PAYGO_TRANSACTIONS_TOKEN'); |
78 | 78 | |
79 | - if(!is_null($params)) |
|
80 | - foreach ($params as $key => $param) |
|
79 | + if(!is_null($params)) { |
|
80 | + foreach ($params as $key => $param) |
|
81 | 81 | { |
82 | 82 | if(!in_array($key, [ |
83 | 83 | PayGoTransactionParameterConst::PAYGO_TRANSACTIONS_HOST, |
@@ -85,11 +85,13 @@ discard block |
||
85 | 85 | PayGoTransactionParameterConst::PAYGO_TRANSACTIONS_TOKEN, |
86 | 86 | ])) |
87 | 87 | throw new \Exception(sprintf("Parâmetro %s inválido", $key)); |
88 | + } |
|
88 | 89 | } |
89 | 90 | |
90 | 91 | if(!is_null($params) && is_array($params)){ |
91 | - foreach ($params as $key => $value) |
|
92 | - $this->params[$key] = $value; |
|
92 | + foreach ($params as $key => $value) { |
|
93 | + $this->params[$key] = $value; |
|
94 | + } |
|
93 | 95 | } |
94 | 96 | } |
95 | 97 |
@@ -109,25 +109,29 @@ |
||
109 | 109 | public function jsonSerialize() |
110 | 110 | { |
111 | 111 | $data = []; |
112 | - if(!empty($this->fromDate)) |
|
113 | - $data = array_merge($data, [ |
|
112 | + if(!empty($this->fromDate)) { |
|
113 | + $data = array_merge($data, [ |
|
114 | 114 | "From" => $this->fromDate->format('Y-m-d'), |
115 | 115 | ]); |
116 | + } |
|
116 | 117 | |
117 | - if(!empty($this->endDate)) |
|
118 | - $data = array_merge($data, [ |
|
118 | + if(!empty($this->endDate)) { |
|
119 | + $data = array_merge($data, [ |
|
119 | 120 | "End" => $this->endDate->format('Y-m-d'), |
120 | 121 | ]); |
122 | + } |
|
121 | 123 | |
122 | - if(!empty($this->fromDateTime)) |
|
123 | - $data = array_merge($data, [ |
|
124 | + if(!empty($this->fromDateTime)) { |
|
125 | + $data = array_merge($data, [ |
|
124 | 126 | "From" => $this->fromDateTime->format('Y-m-d H:i:s'), |
125 | 127 | ]); |
128 | + } |
|
126 | 129 | |
127 | - if(!empty($this->endDateTime)) |
|
128 | - $data = array_merge($data, [ |
|
130 | + if(!empty($this->endDateTime)) { |
|
131 | + $data = array_merge($data, [ |
|
129 | 132 | "End" => $this->endDateTime->format('Y-m-d H:i:s'), |
130 | 133 | ]); |
134 | + } |
|
131 | 135 | |
132 | 136 | return array_filter($data, function($val) { return !empty($val); }); |
133 | 137 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | return $this->httpClient->post("transactions", [ |
36 | 36 | 'body' => json_encode($query) |
37 | 37 | ]); |
38 | - }catch (\Exception $ex){ |
|
38 | + } catch (\Exception $ex){ |
|
39 | 39 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex); |
40 | 40 | } |
41 | 41 | } |