1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
/* |
5
|
|
|
* The MIT License |
6
|
|
|
* |
7
|
|
|
* Copyright 2016 BCL Technologies. |
8
|
|
|
* |
9
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
10
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
11
|
|
|
* in the Software without restriction, including without limitation the rights |
12
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
14
|
|
|
* furnished to do so, subject to the following conditions: |
15
|
|
|
* |
16
|
|
|
* The above copyright notice and this permission notice shall be included in |
17
|
|
|
* all copies or substantial portions of the Software. |
18
|
|
|
* |
19
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25
|
|
|
* THE SOFTWARE. |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
namespace Bcl\EasyPdfCloud; |
29
|
|
|
|
30
|
|
|
class UrlInfo |
31
|
|
|
{ |
32
|
|
|
const AUTHORIZATION_SERVER_ENDPOINT = 'https://www.easypdfcloud.com/oauth2'; |
33
|
|
|
const RESOURCE_SERVER_ENDPOINT = 'https://api.easypdfcloud.com/v1'; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
private $oauth2BaseUrl; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
private $apiBaseUrl; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* UrlInfo constructor. |
47
|
|
|
* |
48
|
|
|
* @param null|string $oauth2BaseUrl |
49
|
|
|
* @param null|string $apiBaseUrl |
50
|
|
|
*/ |
51
|
|
|
public function __construct(string $oauth2BaseUrl = '', string $apiBaseUrl = '') |
52
|
|
|
{ |
53
|
|
|
$this->oauth2BaseUrl = $oauth2BaseUrl; |
54
|
|
|
$this->apiBaseUrl = $apiBaseUrl; |
55
|
|
|
|
56
|
|
|
if (StringUtils::isEmpty($this->oauth2BaseUrl)) { |
57
|
|
|
$this->oauth2BaseUrl = static::AUTHORIZATION_SERVER_ENDPOINT; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if (StringUtils::isEmpty($this->apiBaseUrl)) { |
61
|
|
|
$this->apiBaseUrl = static::RESOURCE_SERVER_ENDPOINT; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
|
|
public function getOAuth2BaseUrl(): string |
69
|
|
|
{ |
70
|
|
|
return $this->oauth2BaseUrl; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function getApiBaseUrl(): string |
77
|
|
|
{ |
78
|
|
|
return $this->apiBaseUrl; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|