1
|
|
|
<?php |
2
|
|
|
// phpcs:disable Generic.Files.LineLength |
3
|
|
|
namespace Commercetools\Core\Builder\Request; |
4
|
|
|
|
5
|
|
|
use Commercetools\Core\Request\Payments\PaymentByIdGetRequest; |
6
|
|
|
use Commercetools\Core\Request\Payments\PaymentByKeyGetRequest; |
7
|
|
|
use Commercetools\Core\Request\Payments\PaymentCreateRequest; |
8
|
|
|
use Commercetools\Core\Model\Payment\PaymentDraft; |
9
|
|
|
use Commercetools\Core\Request\Payments\PaymentDeleteByKeyRequest; |
10
|
|
|
use Commercetools\Core\Model\Payment\Payment; |
11
|
|
|
use Commercetools\Core\Request\Payments\PaymentDeleteRequest; |
12
|
|
|
use Commercetools\Core\Request\Payments\PaymentQueryRequest; |
13
|
|
|
use Commercetools\Core\Request\Payments\PaymentUpdateByKeyRequest; |
14
|
|
|
use Commercetools\Core\Request\Payments\PaymentUpdateRequest; |
15
|
|
|
|
16
|
|
|
class PaymentRequestBuilder |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @link https://docs.commercetools.com/http-api-projects-payments.html#get-payment-by-id |
21
|
|
|
* @param string $id |
22
|
|
|
* @return PaymentByIdGetRequest |
23
|
|
|
*/ |
24
|
1 |
|
public function getById($id) |
25
|
|
|
{ |
26
|
1 |
|
$request = PaymentByIdGetRequest::ofId($id); |
27
|
1 |
|
return $request; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @link https://docs.commercetools.com/http-api-projects-payments.html#get-payment-by-key |
32
|
|
|
* @param string $key |
33
|
|
|
* @return PaymentByKeyGetRequest |
34
|
|
|
*/ |
35
|
1 |
|
public function getByKey($key) |
36
|
|
|
{ |
37
|
1 |
|
$request = PaymentByKeyGetRequest::ofKey($key); |
38
|
1 |
|
return $request; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @link https://docs.commercetools.com/http-api-projects-payments.html#create-a-payment |
43
|
|
|
* @param PaymentDraft $payment |
44
|
|
|
* @return PaymentCreateRequest |
45
|
|
|
*/ |
46
|
1 |
|
public function create(PaymentDraft $payment) |
47
|
|
|
{ |
48
|
1 |
|
$request = PaymentCreateRequest::ofDraft($payment); |
49
|
1 |
|
return $request; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @link https://docs.commercetools.com/http-api-projects-payments.html#delete-payment-by-key |
54
|
|
|
* @param Payment $payment |
55
|
|
|
* @return PaymentDeleteByKeyRequest |
56
|
|
|
*/ |
57
|
1 |
|
public function deleteByKey(Payment $payment) |
58
|
|
|
{ |
59
|
1 |
|
$request = PaymentDeleteByKeyRequest::ofKeyAndVersion($payment->getKey(), $payment->getVersion()); |
60
|
1 |
|
return $request; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @link https://docs.commercetools.com/http-api-projects-payments.html#delete-payment |
65
|
|
|
* @param Payment $payment |
66
|
|
|
* @return PaymentDeleteRequest |
67
|
|
|
*/ |
68
|
1 |
|
public function delete(Payment $payment) |
69
|
|
|
{ |
70
|
1 |
|
$request = PaymentDeleteRequest::ofIdAndVersion($payment->getId(), $payment->getVersion()); |
71
|
1 |
|
return $request; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @link https://docs.commercetools.com/http-api-projects-payments.html#query-payments |
76
|
|
|
* |
77
|
|
|
* @return PaymentQueryRequest |
78
|
|
|
*/ |
79
|
1 |
|
public function query() |
80
|
|
|
{ |
81
|
1 |
|
$request = PaymentQueryRequest::of(); |
82
|
1 |
|
return $request; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @link https://docs.commercetools.com/http-api-projects-payments.html#update-payment-by-key |
87
|
|
|
* @param Payment $payment |
88
|
|
|
* @return PaymentUpdateByKeyRequest |
89
|
|
|
*/ |
90
|
1 |
|
public function updateByKey(Payment $payment) |
91
|
|
|
{ |
92
|
1 |
|
$request = PaymentUpdateByKeyRequest::ofKeyAndVersion($payment->getKey(), $payment->getVersion()); |
93
|
1 |
|
return $request; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @link https://docs.commercetools.com/http-api-projects-payments.html#update-payment |
98
|
|
|
* @param Payment $payment |
99
|
|
|
* @return PaymentUpdateRequest |
100
|
|
|
*/ |
101
|
1 |
|
public function update(Payment $payment) |
102
|
|
|
{ |
103
|
1 |
|
$request = PaymentUpdateRequest::ofIdAndVersion($payment->getId(), $payment->getVersion()); |
104
|
1 |
|
return $request; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return PaymentRequestBuilder |
109
|
|
|
*/ |
110
|
|
|
public function of() |
111
|
|
|
{ |
112
|
|
|
return new self(); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|