1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Getnet\API; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Shipping |
7
|
|
|
* |
8
|
|
|
* @package Getnet\API |
9
|
|
|
*/ |
10
|
|
|
class Shipping implements \JsonSerializable |
11
|
|
|
{ |
12
|
|
|
/** @var */ |
13
|
|
|
private $first_name; |
14
|
|
|
|
15
|
|
|
/** @var */ |
16
|
|
|
private $name; |
17
|
|
|
|
18
|
|
|
/** @var */ |
19
|
|
|
private $email; |
20
|
|
|
|
21
|
|
|
/** @var */ |
22
|
|
|
private $phone_number; |
23
|
|
|
|
24
|
|
|
/** @var int */ |
25
|
|
|
private $shipping_amount = 0; |
26
|
|
|
|
27
|
|
|
/** @var */ |
28
|
|
|
private $address; |
29
|
|
|
|
30
|
|
|
public function jsonSerialize() |
31
|
|
|
{ |
32
|
|
|
return get_object_vars($this); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* |
37
|
|
|
* @return mixed |
38
|
|
|
*/ |
39
|
|
|
public function getFirstName() |
40
|
|
|
{ |
41
|
|
|
return $this->first_name; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param $first_name |
46
|
|
|
* @return $this |
47
|
|
|
*/ |
48
|
|
|
public function setFirstName($first_name) |
49
|
|
|
{ |
50
|
|
|
$this->first_name = (string)$first_name; |
51
|
|
|
|
52
|
|
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return mixed |
57
|
|
|
*/ |
58
|
|
|
public function getName() |
59
|
|
|
{ |
60
|
|
|
return $this->name; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param $name |
65
|
|
|
* @return $this |
66
|
|
|
*/ |
67
|
|
|
public function setName($name) |
68
|
|
|
{ |
69
|
|
|
$this->name = (string)$name; |
70
|
|
|
|
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* |
76
|
|
|
* @return mixed |
77
|
|
|
*/ |
78
|
|
|
public function getEmail() |
79
|
|
|
{ |
80
|
|
|
return $this->email; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param $email |
85
|
|
|
* @return $this |
86
|
|
|
*/ |
87
|
|
|
public function setEmail($email) |
88
|
|
|
{ |
89
|
|
|
$this->email = (string)$email; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return mixed |
96
|
|
|
*/ |
97
|
|
|
public function getPhoneNumber() |
98
|
|
|
{ |
99
|
|
|
return $this->phone_number; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param $phone_number |
104
|
|
|
* @return $this |
105
|
|
|
*/ |
106
|
|
|
public function setPhoneNumber($phone_number) |
107
|
|
|
{ |
108
|
|
|
$this->phone_number = (string)$phone_number; |
109
|
|
|
|
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return int |
115
|
|
|
*/ |
116
|
|
|
public function getShippingAmount() |
117
|
|
|
{ |
118
|
|
|
return $this->shipping_amount; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param $shipping_amount |
123
|
|
|
* @return $this |
124
|
|
|
*/ |
125
|
|
|
public function setShippingAmount($shipping_amount) |
126
|
|
|
{ |
127
|
|
|
$this->shipping_amount = (int)($shipping_amount * 100); |
128
|
|
|
|
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return mixed |
134
|
|
|
*/ |
135
|
|
|
public function getAddress() |
136
|
|
|
{ |
137
|
|
|
return $this->address; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param Address $address |
142
|
|
|
* @return $this |
143
|
|
|
*/ |
144
|
|
|
public function setAddress(Address $address) |
145
|
|
|
{ |
146
|
|
|
$this->address = $address; |
147
|
|
|
|
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return Address |
153
|
|
|
*/ |
154
|
|
|
public function address() |
155
|
|
|
{ |
156
|
|
|
$address = new Address(); |
157
|
|
|
|
158
|
|
|
$this->setAddress($address); |
159
|
|
|
|
160
|
|
|
return $address; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param Customer $customer |
165
|
|
|
* @return $this |
166
|
|
|
*/ |
167
|
|
|
public function populateByCustomer(Customer $customer) |
168
|
|
|
{ |
169
|
|
|
$this->setFirstName($customer->getFirstName()); |
170
|
|
|
$this->setName($customer->getName()); |
171
|
|
|
$this->setEmail($customer->getEmail()); |
172
|
|
|
$this->setPhoneNumber($customer->getPhoneNumber()); |
173
|
|
|
$this->setAddress($customer->getBillingAddress()); |
174
|
|
|
|
175
|
|
|
return $this; |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
|