Skip to content

Commit 51c8f2a

Browse files
committed
Melhorado cs
1 parent effa459 commit 51c8f2a

File tree

3 files changed

+72
-59
lines changed

3 files changed

+72
-59
lines changed

src/Cielo/API30/Ecommerce/Payment.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class Payment implements \JsonSerializable
110110

111111
private $instructions;
112112

113+
private $paymentFacilitator;
114+
113115
/**
114116
* Payment constructor.
115117
*
@@ -168,6 +170,10 @@ public function populate(\stdClass $data)
168170
$this->externalAuthentication->populate($data->ExternalAuthentication);
169171
}
170172

173+
if (isset($data->PaymentFacilitator)) {
174+
$this->paymentFacilitator()->populate($data->paymentFacilitator);
175+
}
176+
171177
$this->expirationDate = isset($data->ExpirationDate) ? $data->ExpirationDate : null;
172178
$this->url = isset($data->Url) ? $data->Url : null;
173179
$this->boletoNumber = isset($data->BoletoNumber) ? $data->BoletoNumber : null;
@@ -1154,4 +1160,33 @@ public function setInstructions($instructions)
11541160

11551161
return $this;
11561162
}
1163+
1164+
public function paymentFacilitator()
1165+
{
1166+
if (is_null($this->paymentFacilitator)) {
1167+
$this->setPaymentFacilitator(new PaymentFacilitator());
1168+
}
1169+
1170+
return $this->getPaymentFacilitator();
1171+
}
1172+
1173+
/**
1174+
* Get the value of paymentFacilitator
1175+
*/
1176+
public function getPaymentFacilitator()
1177+
{
1178+
return $this->paymentFacilitator;
1179+
}
1180+
1181+
/**
1182+
* Set the value of paymentFacilitator
1183+
*
1184+
* @return self
1185+
*/
1186+
public function setPaymentFacilitator($paymentFacilitator)
1187+
{
1188+
$this->paymentFacilitator = $paymentFacilitator;
1189+
1190+
return $this;
1191+
}
11571192
}

src/Cielo/API30/Ecommerce/PaymentFacilitator.php

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,24 @@
33
namespace Cielo\API30\Ecommerce;
44

55
/**
6-
* Class Payment
6+
* Class PaymentFacilitator
77
*
88
* @package Cielo\API30\Ecommerce
99
*/
10-
11-
1210
class PaymentFacilitator implements \JsonSerializable
1311
{
14-
15-
private $paymentFacilitator;
16-
1712
private $subEstablishment;
18-
1913

20-
public function __construct($paymentFacilitator)
14+
public function __construct($subEstablishment = null)
2115
{
22-
$this->paymentFacilitator = $paymentFacilitator;
23-
}
24-
25-
/**
26-
* @param $json
27-
*
28-
* @return PaymentFacilitator
29-
*/
30-
public static function fromJson($json)
31-
{
32-
$paymentFacilitator = new PaymentFacilitator(json_decode($json));
33-
$paymentFacilitator->populate(json_decode($json));
34-
35-
return $paymentFacilitator;
16+
$this->subEstablishment = $subEstablishment;
3617
}
3718

3819
/**
3920
* @param \stdClass $data
4021
*/
4122
public function populate(\stdClass $data)
4223
{
43-
$this->paymentFacilitator = $data->paymentFacilitator ?? $data->paymentFacilitator;
4424
$this->subEstablishment = new SubEstablishment();
4525
$this->subEstablishment->populate($data);
4626
}
@@ -53,29 +33,18 @@ public function jsonSerialize()
5333
return get_object_vars($this);
5434
}
5535

56-
/**
57-
* Get the value of paymentFacilitator
58-
*/
59-
public function getPaymentFacilitator()
36+
public function subEstablishment()
6037
{
61-
return $this->paymentFacilitator;
62-
}
63-
64-
/**
65-
* Set the value of paymentFacilitator
66-
*
67-
* @return self
68-
*/
69-
public function setPaymentFacilitator($paymentFacilitator)
70-
{
71-
$this->paymentFacilitator = $paymentFacilitator;
72-
73-
return $this;
38+
if (is_null($this->subEstablishment)) {
39+
$this->setSubEstablishment(new SubEstablishment());
40+
}
41+
42+
return $this->getSubEstablishment();
7443
}
7544

7645
/**
7746
* Get the value of subEstablishment
78-
*/
47+
*/
7948
public function getSubEstablishment()
8049
{
8150
return $this->subEstablishment;
@@ -85,8 +54,8 @@ public function getSubEstablishment()
8554
* Set the value of subEstablishment
8655
*
8756
* @return self
88-
*/
89-
public function setSubEstablishment($subEstablishment)
57+
*/
58+
public function setSubEstablishment(SubEstablishment $subEstablishment)
9059
{
9160
$this->subEstablishment = $subEstablishment;
9261

src/Cielo/API30/Ecommerce/SubEstablishment.php

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,52 @@
33
namespace Cielo\API30\Ecommerce;
44

55
/**
6-
* Class Payment
6+
* Class SubEstablishment
77
*
88
* @package Cielo\API30\Ecommerce
99
*/
10-
11-
1210
class SubEstablishment implements \JsonSerializable
1311
{
12+
const DEFAULT_COUTRY_CODE = "076";
13+
1414
private $establishmentCode;
1515
private $identity;
1616
private $mcc;
1717
private $address;
1818
private $city;
1919
private $state;
20-
private $countryCode;
2120
private $postalCode;
21+
private $countryCode;
2222
private $phoneNumber;
2323

24-
2524
public function __construct()
2625
{
27-
$this->countryCode = "076";
26+
$this->countryCode = self::DEFAULT_COUTRY_CODE;
27+
$this->establishmentCode = null;
28+
$this->identity = null;
29+
$this->mcc = null;
30+
$this->address = null;
31+
$this->city = null;
32+
$this->state = null;
33+
$this->countryCode = null;
34+
$this->postalCode = null;
35+
$this->phoneNumber = null;
2836
}
37+
2938
/**
3039
* @param \stdClass $data
3140
*/
3241
public function populate(\stdClass $data)
3342
{
34-
$this->establishmentCode = $data->establishmentCode ?? $data->establishmentCode;
35-
$this->identity = $data->identity ?? $data->identity;
36-
$this->mcc = $data->mcc ?? $data->mcc;
37-
$this->address = $data->address ?? $data->address;
38-
$this->city = $data->city ?? $data->city;
39-
$this->state = $data->state ?? $data->state;
40-
$this->countryCode = $data->countryCode ?? $data->countryCode;
41-
$this->postalCode = $data->postalCode ?? $data->postalCode;
42-
$this->phoneNumber = $data->phoneNumber ?? $data->phoneNumber;
43+
$this->establishmentCode = $data->EstablishmentCode ?? null;
44+
$this->identity = $data->Identity ?? null;
45+
$this->mcc = $data->Mcc ?? null;
46+
$this->address = $data->Address ?? null;
47+
$this->city = $data->City ?? null;
48+
$this->state = $data->State ?? null;
49+
$this->countryCode = $data->CountryCode ?? null;
50+
$this->postalCode = $data->PostalCode ?? null;
51+
$this->phoneNumber = $data->PhoneNumber ?? null;
4352
}
4453

4554
public function jsonSerialize()
@@ -227,4 +236,4 @@ public function setPhoneNumber($phoneNumber)
227236

228237
return $this;
229238
}
230-
}
239+
}

0 commit comments

Comments
 (0)