Completed
Push — develop ( b6cb2c...9ca58c )
by Jens
15:17 queued 07:08
created

PaymentRequestBuilder::updateByKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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