1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WSW\SiftScience\Transformers\Events; |
4
|
|
|
|
5
|
|
|
use WSW\SiftScience\Events\Transaction; |
6
|
|
|
use WSW\SiftScience\Support\Traits\Transformers\ObjectValues; |
7
|
|
|
use WSW\SiftScience\Support\Traits\Transformers\Relationships; |
8
|
|
|
use WSW\SiftScience\Transformers\AbstractTransformer; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class TransactionTransformer |
12
|
|
|
* |
13
|
|
|
* @package WSW\SiftScience\Transformers\Events |
14
|
|
|
* @author Ronaldo Matos Rodrigues <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class TransactionTransformer extends AbstractTransformer |
17
|
|
|
{ |
18
|
|
|
use Relationships; |
19
|
|
|
use ObjectValues; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param Transaction $transaction |
23
|
|
|
* |
24
|
|
|
* @return array |
25
|
|
|
*/ |
26
|
2 |
|
public function transform(Transaction $transaction) |
27
|
|
|
{ |
28
|
2 |
|
return array_filter([ |
29
|
2 |
|
'$type' => $transaction->getType(), |
30
|
2 |
|
'$api_key' => $transaction->getApiKey(), |
31
|
2 |
|
'$user_id' => $transaction->getUserId(), |
32
|
2 |
|
'$user_email' => $this->email($transaction->getUserEmail()), |
33
|
2 |
|
'$transaction_type' => $transaction->getTransactionType(), |
34
|
2 |
|
'$transaction_status' => $transaction->getTransactionStatus(), |
35
|
2 |
|
'$amount' => $this->amount($transaction->getAmount()), |
36
|
2 |
|
'$currency_code' => $this->currency($transaction->getAmount()), |
37
|
2 |
|
'$order_id' => $transaction->getOrderId(), |
38
|
2 |
|
'$transaction_id' => $transaction->getId(), |
39
|
2 |
|
'$billing_address' => $this->address($transaction->getBillingAddress()), |
40
|
2 |
|
'$shipping_address' => $this->address($transaction->getShippingAddress()), |
41
|
2 |
|
'$session_id' => $transaction->getSessionId(), |
42
|
2 |
|
'$seller_user_id' => $transaction->getSellerUserId(), |
43
|
2 |
|
'$transfer_recipient_user_id' => $transaction->getTransferRecipientUserId() |
44
|
|
|
]); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|