Completed
Push — master ( 84a128...7da2fe )
by Ronaldo
07:05
created

Transaction::setShippingAddress()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace WSW\SiftScience\Events;
4
5
use InvalidArgumentException;
6
use WSW\Email\Email;
7
use WSW\Money\Money;
8
use WSW\SiftScience\Entities\Address;
9
use WSW\SiftScience\Entities\PaymentMethod;
10
use WSW\SiftScience\Support\AllowedValues\TransactionStatus;
11
use WSW\SiftScience\Support\AllowedValues\TransactionType;
12
13
/**
14
 * Class Transaction
15
 *
16
 * @package WSW\SiftScience\Events
17
 * @author Ronaldo Matos Rodrigues <[email protected]>
18
 */
19
class Transaction extends BaseEvent
20
{
21
    /**
22
     * @var string
23
     */
24
    private $id;
25
26
    /**
27
     * @var Email
28
     */
29
    private $userEmail;
30
31
    /**
32
     * @var string
33
     */
34
    private $transactionType;
35
36
    /**
37
     * @var string
38
     */
39
    private $transactionStatus;
40
41
    /**
42
     * @var Money
43
     */
44
    private $amount;
45
46
    /**
47
     * @var string
48
     */
49
    private $orderId;
50
51
    /**
52
     * @var Address
53
     */
54
    private $billingAddress;
55
56
    /**
57
     * @var Address
58
     */
59
    private $shippingAddress;
60
61
    /**
62
     * @var PaymentMethod
63
     */
64
    private $paymentMethod;
65
66
    /**
67
     * @var string
68
     */
69
    private $sessionId;
70
71
    /**
72
     * @var string
73
     */
74
    private $sellerUserId;
75
76
    /**
77
     * @var string
78
     */
79
    private $transferRecipientUserId;
80
81
    /**
82
     * Transaction constructor.
83
     */
84
    public function __construct()
85
    {
86
        $this->type = '$transaction';
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getId()
93
    {
94
        return $this->id;
95
    }
96
97
    /**
98
     * @param string $id
99
     *
100
     * @return $this
101
     */
102
    public function setId($id)
103
    {
104
        $this->id = $id;
105
106
        return $this;
107
    }
108
109
    /**
110
     * @return Email
111
     */
112
    public function getUserEmail()
113
    {
114
        return $this->userEmail;
115
    }
116
117
    /**
118
     * @param Email $userEmail
119
     *
120
     * @return $this
121
     */
122
    public function setUserEmail(Email $userEmail)
123
    {
124
        $this->userEmail = $userEmail;
125
126
        return $this;
127
    }
128
129
    /**
130
     * @return string
131
     */
132
    public function getTransactionType()
133
    {
134
        return $this->transactionType;
135
    }
136
137
    /**
138
     * @param string $transactionType
139
     *
140
     * @return $this
141
     */
142
    public function setTransactionType($transactionType)
143
    {
144
        if (!TransactionType::isValid($transactionType)) {
145
            throw new InvalidArgumentException('You should inform a valid transaction type.');
146
        }
147
148
        $this->transactionType = $transactionType;
149
150
        return $this;
151
    }
152
153
    /**
154
     * @return string
155
     */
156
    public function getTransactionStatus()
157
    {
158
        return $this->transactionStatus;
159
    }
160
161
    /**
162
     * @param string $transactionStatus
163
     *
164
     * @return $this
165
     */
166
    public function setTransactionStatus($transactionStatus)
167
    {
168
        if (!TransactionStatus::isValid($transactionStatus)) {
169
            throw new InvalidArgumentException('You should inform a valid transaction status.');
170
        }
171
172
        $this->transactionStatus = $transactionStatus;
173
174
        return $this;
175
    }
176
177
    /**
178
     * @return Money
179
     */
180
    public function getAmount()
181
    {
182
        return $this->amount;
183
    }
184
185
    /**
186
     * @param Money $amount
187
     *
188
     * @return $this
189
     */
190
    public function setAmount(Money $amount)
191
    {
192
        $this->amount = $amount;
193
194
        return $this;
195
    }
196
197
    /**
198
     * @return string
199
     */
200
    public function getOrderId()
201
    {
202
        return $this->orderId;
203
    }
204
205
    /**
206
     * @param string $orderId
207
     *
208
     * @return $this
209
     */
210
    public function setOrderId($orderId)
211
    {
212
        $this->orderId = $orderId;
213
214
        return $this;
215
    }
216
217
    /**
218
     * @return Address
219
     */
220
    public function getBillingAddress()
221
    {
222
        return $this->billingAddress;
223
    }
224
225
    /**
226
     * @param Address $billingAddress
227
     *
228
     * @return $this
229
     */
230
    public function setBillingAddress(Address $billingAddress)
231
    {
232
        $this->billingAddress = $billingAddress;
233
234
        return $this;
235
    }
236
237
    /**
238
     * @return Address
239
     */
240
    public function getShippingAddress()
241
    {
242
        return $this->shippingAddress;
243
    }
244
245
    /**
246
     * @param Address $shippingAddress
247
     *
248
     * @return $this
249
     */
250
    public function setShippingAddress(Address $shippingAddress)
251
    {
252
        $this->shippingAddress = $shippingAddress;
253
254
        return $this;
255
    }
256
257
    /**
258
     * @return PaymentMethod
259
     */
260
    public function getPaymentMethod()
261
    {
262
        return $this->paymentMethod;
263
    }
264
265
    /**
266
     * @param PaymentMethod $paymentMethod
267
     *
268
     * @return $this
269
     */
270
    public function setPaymentMethod(PaymentMethod $paymentMethod)
271
    {
272
        $this->paymentMethod = $paymentMethod;
273
274
        return $this;
275
    }
276
277
    /**
278
     * @return string
279
     */
280
    public function getSessionId()
281
    {
282
        return $this->sessionId;
283
    }
284
285
    /**
286
     * @param string $sessionId
287
     *
288
     * @return $this
289
     */
290
    public function setSessionId($sessionId)
291
    {
292
        $this->sessionId = $sessionId;
293
294
        return $this;
295
    }
296
297
    /**
298
     * @return string
299
     */
300
    public function getSellerUserId()
301
    {
302
        return $this->sellerUserId;
303
    }
304
305
    /**
306
     * @param string $sellerUserId
307
     *
308
     * @return $this
309
     */
310
    public function setSellerUserId($sellerUserId)
311
    {
312
        $this->sellerUserId = $sellerUserId;
313
314
        return $this;
315
    }
316
317
    /**
318
     * @return string
319
     */
320
    public function getTransferRecipientUserId()
321
    {
322
        return $this->transferRecipientUserId;
323
    }
324
325
    /**
326
     * @param string $transferRecipientUserId
327
     *
328
     * @return $this
329
     */
330
    public function setTransferRecipientUserId($transferRecipientUserId)
331
    {
332
        $this->transferRecipientUserId = $transferRecipientUserId;
333
334
        return $this;
335
    }
336
}
337