1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WSW\SiftScience\Transformers\Events; |
4
|
|
|
|
5
|
|
|
use WSW\SiftScience\Events\AbstractOrder; |
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 OrderTransformer |
12
|
|
|
* |
13
|
|
|
* @package WSW\SiftScience\Transformers\Events |
14
|
|
|
* @author Ronaldo Matos Rodrigues <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class OrderTransformer extends AbstractTransformer |
17
|
|
|
{ |
18
|
|
|
use ObjectValues; |
19
|
|
|
use Relationships; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param AbstractOrder $order |
23
|
|
|
* |
24
|
|
|
* @return array |
25
|
|
|
*/ |
26
|
|
|
public function transform(AbstractOrder $order) |
27
|
|
|
{ |
28
|
|
|
return array_filter([ |
29
|
|
|
'$type' => $order->getType(), |
30
|
|
|
'$api_key' => $order->getApiKey(), |
31
|
|
|
'$user_id' => $order->getUserId(), |
32
|
|
|
'$session_id' => $order->getSession(), |
33
|
|
|
'$order_id' => $order->getOrder(), |
34
|
|
|
'$user_email' => $this->email($order->getUserEmail()), |
35
|
|
|
'$amount' => $this->amount($order->getAmount()), |
36
|
|
|
'$currency_code' => $this->currency($order->getAmount()), |
37
|
|
|
'$billing_address' => $this->address($order->getBillingAddress()), |
38
|
|
|
'$payment_methods' => $this->paymentMethods($order->getPaymentMethods()), |
39
|
|
|
'$shipping_address' => $this->address($order->getShippingAddress()), |
40
|
|
|
'$expedited_shipping' => $order->isExpeditedShipping(), |
41
|
|
|
'$shipping_method' => $order->getShippingMethod(), |
42
|
|
|
'$items' => $this->items($order->getItems()), |
43
|
|
|
'$seller_user_id' => $order->getSellerUserId(), |
44
|
|
|
'$promotions' => $this->promotions($order->getPromotions()) |
45
|
|
|
]); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|