Passed
Pull Request — master (#23)
by
unknown
10:02 queued 05:04
created

AfterPayConfig::getSalutation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
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 Orm\Zed\Sales\Persistence\Map\SpySalesOrderTableMap;
0 ignored issues
show
Bug introduced by
The type Orm\Zed\Sales\Persistenc...p\SpySalesOrderTableMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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