Skip to content

Commit e52674b

Browse files
Merge pull request #4 from retargeting/development
Development
2 parents 747a81e + c2ac128 commit e52674b

38 files changed

+2083
-230
lines changed

lib/AbstractCredentials.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
namespace RetargetingSDK;
4+
5+
/**
6+
* Class AbstractCredentials
7+
*/
8+
abstract class AbstractCredentials
9+
{
10+
/**
11+
* @var string
12+
*/
13+
private $trackingApiKey;
14+
15+
/**
16+
* @var string
17+
*/
18+
private $restApiKey;
19+
20+
/**
21+
* @return string
22+
*/
23+
public function getTrackingApiKey()
24+
{
25+
return $this->trackingApiKey;
26+
}
27+
28+
/**
29+
* @param string $trackingApiKey
30+
* @return $this
31+
*/
32+
public function setTrackingApiKey($trackingApiKey)
33+
{
34+
$this->trackingApiKey = $trackingApiKey;
35+
36+
return $this;
37+
}
38+
39+
/**
40+
* @return bool
41+
*/
42+
public function hasTrackingApiKey()
43+
{
44+
return !empty($this->trackingApiKey);
45+
}
46+
47+
/**
48+
* @return string
49+
*/
50+
public function getRestApiKey()
51+
{
52+
return $this->restApiKey;
53+
}
54+
55+
/**
56+
* @param string $restApiKey
57+
* @return $this
58+
*/
59+
public function setRestApiKey($restApiKey)
60+
{
61+
$this->restApiKey = $restApiKey;
62+
63+
return $this;
64+
}
65+
66+
/**
67+
* @return bool
68+
*/
69+
public function hasRestApiKey()
70+
{
71+
return !empty($this->restApiKey);
72+
}
73+
}

lib/Brand.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,23 @@ public function setName($name)
4848
}
4949

5050
/**
51-
* Prepare brand information
52-
* @return string
51+
* @param bool $encoded
52+
* @return array|bool|\stdClass|string|null
5353
*/
54-
public function prepareBrandInformation()
54+
public function getData($encoded = true)
5555
{
56-
return $this->toJSON(BrandHelper::validate([
56+
$brand = BrandHelper::validate([
5757
'id' => $this->getId(),
5858
'name' => $this->getProperFormattedString($this->getName())
59-
]));
59+
]);
60+
61+
if(!empty($brand))
62+
{
63+
return $encoded ? $this->toJSON($brand) : $brand;
64+
}
65+
else
66+
{
67+
return null;
68+
}
6069
}
6170
}

lib/Category.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,19 @@ public function setBreadcrumb(array $breadcrumb)
113113
}
114114

115115
/**
116-
* Prepare category data
117-
* @return string
116+
* @param bool $encoded
117+
* @return array|string
118118
*/
119-
public function prepareCategoryData()
119+
public function getData($encoded = true)
120120
{
121-
return $this->toJSON([
121+
$category = [
122122
'id' => $this->getId(),
123123
'name' => $this->getName(),
124124
'url' => $this->getUrl(),
125125
'parent' => $this->getParent(),
126126
'breadcrumb' => $this->getBreadcrumb()
127-
]);
127+
];
128+
129+
return $encoded ? $this->toJSON($category) : $category;
128130
}
129131
}

lib/Checkout.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public function setProductIds(array $productIds)
3131
}
3232

3333
/**
34-
* Prepare checkout ids
35-
* @return string
34+
* @param bool $encoded
35+
* @return array|string
3636
*/
37-
public function prepareCheckoutIds()
37+
public function getData($encoded = true)
3838
{
39-
return $this->toJSON(
40-
$this->getProductIds()
41-
);
39+
$checkout = $this->getProductIds();
40+
41+
return $encoded ? $this->toJSON($checkout) : $checkout;
4242
}
4343
}

lib/Customer.php

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?php
2+
3+
namespace RetargetingSDK;
4+
5+
use RetargetingSDK\Helpers\EmailHelper;
6+
7+
/**
8+
* Class Customer
9+
* @package RetargetingSDK
10+
*/
11+
class Customer extends AbstractRetargetingSDK
12+
{
13+
/**
14+
* @var string
15+
*/
16+
protected $firstName;
17+
18+
/**
19+
* @var string
20+
*/
21+
protected $lastName;
22+
23+
/**
24+
* @var string
25+
*/
26+
protected $email;
27+
28+
/**
29+
* @var string
30+
*/
31+
protected $phone;
32+
33+
/**
34+
* @var boolean
35+
*/
36+
protected $status;
37+
38+
/**
39+
* @return string
40+
*/
41+
public function getFirstName()
42+
{
43+
return $this->firstName;
44+
}
45+
46+
/**
47+
* @param string $firstName
48+
*/
49+
public function setFirstName($firstName)
50+
{
51+
$this->firstName = $this->getProperFormattedString($firstName);
52+
}
53+
54+
/**
55+
* @return string
56+
*/
57+
public function getLastName()
58+
{
59+
return $this->lastName;
60+
}
61+
62+
/**
63+
* @param string $lastName
64+
*/
65+
public function setLastName($lastName)
66+
{
67+
$this->lastName = $this->getProperFormattedString($lastName);
68+
}
69+
70+
/**
71+
* @return string
72+
*/
73+
public function getEmail()
74+
{
75+
return $this->email;
76+
}
77+
78+
/**
79+
* @param $email
80+
* @throws \Exception
81+
*/
82+
public function setEmail($email)
83+
{
84+
$this->email = EmailHelper::validate($email);
85+
}
86+
87+
/**
88+
* @return string
89+
*/
90+
public function getPhone()
91+
{
92+
return $this->phone;
93+
}
94+
95+
/**
96+
* @param string $phone
97+
*/
98+
public function setPhone($phone)
99+
{
100+
$this->phone = $this->getProperFormattedString($phone);
101+
}
102+
103+
/**
104+
* @return bool
105+
*/
106+
public function getStatus()
107+
{
108+
return $this->status;
109+
}
110+
111+
/**
112+
* @param bool $status
113+
*/
114+
public function setStatus($status)
115+
{
116+
$this->status = is_bool($status) ? $status : false;
117+
}
118+
119+
/**
120+
* @param bool $encoded
121+
* @return array|string
122+
*/
123+
public function getData($encoded = true)
124+
{
125+
$data = [
126+
'firstname' => $this->getFirstName(),
127+
'lastname' => $this->getLastName(),
128+
'email' => $this->getEmail(),
129+
'phone' => $this->getPhone(),
130+
'status' => $this->getStatus()
131+
];
132+
133+
return $encoded ? $this->toJSON($data) : $data;
134+
}
135+
}

0 commit comments

Comments
 (0)