Passed
Push — master ( b846fe...52bca8 )
by
unknown
07:07
created

AfterPayConfig::getSalutation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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