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