1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PaymentGateway\PayPalSdk\Products\Requests; |
4
|
|
|
|
5
|
|
|
use PaymentGateway\PayPalSdk\Products\Concerns\HasProductCategory; |
6
|
|
|
use PaymentGateway\PayPalSdk\Products\Concerns\HasProductDescription; |
7
|
|
|
use PaymentGateway\PayPalSdk\Products\Concerns\HasHomeUrl; |
8
|
|
|
use PaymentGateway\PayPalSdk\Products\Concerns\HasImageUrl; |
9
|
|
|
use PaymentGateway\PayPalSdk\Products\Constants\ProductType; |
10
|
|
|
|
11
|
|
|
class StoreProductRequest |
12
|
|
|
{ |
13
|
|
|
use HasProductDescription; |
14
|
|
|
use HasProductCategory; |
15
|
|
|
use HasImageUrl; |
16
|
|
|
use HasHomeUrl; |
17
|
|
|
|
18
|
|
|
protected string $productId; |
19
|
|
|
protected string $productName; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
* @see ProductType |
24
|
|
|
*/ |
25
|
|
|
protected string $productType; |
26
|
|
|
|
27
|
14 |
|
public function __construct(string $productName, string $productType) |
28
|
|
|
{ |
29
|
14 |
|
$this->productName = $productName; |
30
|
14 |
|
$this->productType = $productType; |
31
|
14 |
|
} |
32
|
|
|
|
33
|
1 |
|
public function getProductId(): string |
34
|
|
|
{ |
35
|
1 |
|
return $this->productId; |
36
|
|
|
} |
37
|
|
|
|
38
|
2 |
|
public function setProductId(string $productId): self |
39
|
|
|
{ |
40
|
2 |
|
$this->productId = $productId; |
41
|
|
|
|
42
|
2 |
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
1 |
|
public function getProductName(): string |
46
|
|
|
{ |
47
|
1 |
|
return $this->productName; |
48
|
|
|
} |
49
|
|
|
|
50
|
1 |
|
public function setProductName(string $productName): self |
51
|
|
|
{ |
52
|
1 |
|
$this->productName = $productName; |
53
|
|
|
|
54
|
1 |
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
public function getProductType(): string |
58
|
|
|
{ |
59
|
1 |
|
return $this->productType; |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
public function setProductType(string $productType): self |
63
|
|
|
{ |
64
|
1 |
|
$this->productType = $productType; |
65
|
|
|
|
66
|
1 |
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
14 |
|
public function toArray(): array |
70
|
|
|
{ |
71
|
14 |
|
$request = []; |
72
|
|
|
|
73
|
14 |
|
if ($this->productId ?? null) { |
74
|
2 |
|
$request['id'] = $this->productId; |
75
|
|
|
} |
76
|
|
|
|
77
|
14 |
|
$request['name'] = $this->productName; |
78
|
14 |
|
$request['type'] = $this->productType; |
79
|
|
|
|
80
|
14 |
|
if ($this->productDescription ?? null) { |
81
|
12 |
|
$request['description'] = $this->productDescription; |
82
|
|
|
} |
83
|
|
|
|
84
|
14 |
|
if ($this->productCategory ?? null) { |
85
|
12 |
|
$request['category'] = $this->productCategory; |
86
|
|
|
} |
87
|
|
|
|
88
|
14 |
|
if ($this->imageUrl ?? null) { |
89
|
12 |
|
$request['image_url'] = $this->imageUrl; |
90
|
|
|
} |
91
|
|
|
|
92
|
14 |
|
if ($this->homeUrl ?? null) { |
93
|
12 |
|
$request['home_url'] = $this->homeUrl; |
94
|
|
|
} |
95
|
|
|
|
96
|
14 |
|
return $request; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|