Passed
Pull Request — master (#23)
by
unknown
11:26 queued 06:10
created

AfterPayConfig::getSalutationMapping()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\AfterPay;
9
10
use Spryker\Zed\Kernel\AbstractBundleConfig;
11
use SprykerEco\Shared\AfterPay\AfterPayConfig as SharedAfterPayConfig;
12
use SprykerEco\Shared\AfterPay\AfterPayConstants;
13
14
class AfterPayConfig extends AbstractBundleConfig
15
{
16
    /**
17
     * @api
18
     *
19
     * @param string $orderNumber
20
     *
21
     * @return string
22
     */
23
    public function getCaptureApiEndpointUrl(string $orderNumber): string
24
    {
25
        return $this->getApiEndpointUrl(
26
            sprintf(SharedAfterPayConfig::API_ENDPOINT_CAPTURE_PATH, $orderNumber)
27
        );
28
    }
29
30
    /**
31
     * @api
32
     *
33
     * @param string $orderNumber
34
     *
35
     * @return string
36
     */
37
    public function getRefundApiEndpointUrl(string $orderNumber): string
38
    {
39
        return $this->getApiEndpointUrl(
40
            sprintf(SharedAfterPayConfig::API_ENDPOINT_REFUND_PATH, $orderNumber)
41
        );
42
    }
43
44
    /**
45
     * @api
46
     *
47
     * @param string $orderNumber
48
     *
49
     * @return string
50
     */
51
    public function getCancelApiEndpointUrl(string $orderNumber): string
52
    {
53
        return $this->getApiEndpointUrl(
54
            sprintf(SharedAfterPayConfig::API_ENDPOINT_CANCEL_PATH, $orderNumber)
55
        );
56
    }
57
58
    /**
59
     * @api
60
     *
61
     * @return string
62
     */
63
    public function getAuthorizeApiEndpointUrl(): string
64
    {
65
        return $this->getApiEndpointUrl(
66
            SharedAfterPayConfig::API_ENDPOINT_AUTHORIZE_PATH
67
        );
68
    }
69
70
    /**
71
     * @api
72
     *
73
     * @return string
74
     */
75
    public function getValidateAddressApiEndpointUrl(): string
76
    {
77
        return $this->getApiEndpointUrl(
78
            SharedAfterPayConfig::API_ENDPOINT_VALIDATE_ADDRESS_PATH
79
        );
80
    }
81
82
    /**
83
     * @api
84
     *
85
     * @return string
86
     */
87
    public function getLookupCustomerApiEndpointUrl(): string
88
    {
89
        return $this->getApiEndpointUrl(
90
            SharedAfterPayConfig::API_ENDPOINT_LOOKUP_CUSTOMER_PATH
91
        );
92
    }
93
94
    /**
95
     * @api
96
     *
97
     * @return string
98
     */
99
    public function getLookupInstallmentPlansApiEndpointUrl(): string
100
    {
101
        return $this->getApiEndpointUrl(
102
            SharedAfterPayConfig::API_ENDPOINT_LOOKUP_INSTALLMENT_PLANS_PATH
103
        );
104
    }
105
106
    /**
107
     * @api
108
     *
109
     * @return string
110
     */
111
    public function getValidateBankAccountApiEndpointUrl(): string
112
    {
113
        return $this->getApiEndpointUrl(
114
            SharedAfterPayConfig::API_ENDPOINT_VALIDATE_BANK_ACCOUNT_PATH
115
        );
116
    }
117
118
    /**
119
     * @api
120
     *
121
     * @return string
122
     */
123
    public function getStatusApiEndpointUrl(): string
124
    {
125
        return $this->getApiEndpointUrl(
126
            SharedAfterPayConfig::API_ENDPOINT_API_STATUS_PATH
127
        );
128
    }
129
130
    /**
131
     * @api
132
     *
133
     * @return string
134
     */
135
    public function getVersionApiEndpointUrl(): string
136
    {
137
        return $this->getApiEndpointUrl(
138
            SharedAfterPayConfig::API_ENDPOINT_API_VERSION_PATH
139
        );
140
    }
141
142
    /**
143
     * @api
144
     *
145
     * @return string
146
     */
147
    public function getAvailablePaymentMethodsApiEndpointUrl(): string
148
    {
149
        return $this->getApiEndpointUrl(
150
            SharedAfterPayConfig::API_ENDPOINT_AVAILABLE_PAYMENT_METHODS_PATH
151
        );
152
    }
153
154
    /**
155
     * @api
156
     *
157
     * @return string
158
     */
159
    public function getApiCredentialsAuthKey(): string
160
    {
161
        return $this->get(AfterPayConstants::API_CREDENTIALS_AUTH_KEY);
162
    }
163
164
    /**
165
     * @api
166
     *
167
     * @return string
168
     */
169
    public function getAfterPayAuthorizeWorkflow(): string
170
    {
171
        return $this->get(AfterPayConstants::AFTERPAY_AUTHORIZE_WORKFLOW);
172
    }
173
174
    /**
175
     * @api
176
     *
177
     * @param string $paymentMethod
178
     *
179
     * @return string
180
     */
181
    public function getPaymentChannelId(string $paymentMethod): string
182
    {
183
        if ($paymentMethod === SharedAfterPayConfig::PAYMENT_METHOD_INVOICE) {
184
            return $this->get(AfterPayConstants::PAYMENT_INVOICE_CHANNEL_ID);
185
        }
186
187
        return $this->get(AfterPayConstants::PAYMENT_INVOICE_CHANNEL_ID);
188
    }
189
190
    /**
191
     * @api
192
     *
193
     * @return string
194
     */
195
    public function getPaymentAuthorizationFailedUrl(): string
196
    {
197
        return $this->get(AfterPayConstants::AFTERPAY_YVES_AUTHORIZE_PAYMENT_FAILED_URL);
198
    }
199
200
    /**
201
     * @api
202
     *
203
     * @param string $salutation
204
     *
205
     * @return string
206
     */
207
    public function getSalutationMapping(string $salutation): string
208
    {
209
        $salutationMap = $this->get(AfterPayConstants::SALUTATION_MAP);
210
        return $salutationMap[$salutation] ?? $this->get(AfterPayConstants::SALUTATION_DEFAULT);
211
    }
212
213
    /**
214
     * @param string $endpointPath
215
     *
216
     * @return string
217
     */
218
    protected function getApiEndpointUrl(string $endpointPath): string
219
    {
220
        return $this->get(AfterPayConstants::API_ENDPOINT_BASE_URL) . $endpointPath;
221
    }
222
}
223