-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathWorkOS.php
More file actions
138 lines (118 loc) · 2.79 KB
/
WorkOS.php
File metadata and controls
138 lines (118 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
namespace WorkOS;
/**
* Class WorkOS.
*
* This class allows users to get and set configuration for the package.
*/
class WorkOS
{
/**
* @var null|string WorkOS API key
*/
private static $apiKey = null;
/**
* @var null|string WorkOS Client ID
*/
private static $clientId = null;
/**
* @var string WorkOS base API URL.
*/
private static $apiBaseUrl = "https://api.workos.com/";
/**
* @var string SDK identifier
*/
private static $identifier = Version::SDK_IDENTIFIER;
/**
* @var string SDK version
*/
private static $version = Version::SDK_VERSION;
/**
* @return null|string WorkOS API key
*/
public static function getApiKey()
{
if (isset(self::$apiKey)) {
return self::$apiKey;
}
if (getenv("WORKOS_API_KEY")) {
self::$apiKey = getenv("WORKOS_API_KEY");
return self::$apiKey;
}
$msg = "\$apiKey is required.";
throw new \WorkOS\Exception\ConfigurationException($msg);
}
/**
* @param null|string $apiKey WorkOS API key
*/
public static function setApiKey($apiKey)
{
self::$apiKey = $apiKey;
}
/**
* @throws \WorkOS\Exception\ConfigurationException
*
* @return null|string WorkOS Client ID
*/
public static function getClientId()
{
if (isset(self::$clientId)) {
return self::$clientId;
}
if (getenv("WORKOS_CLIENT_ID")) {
self::$clientId = getenv("WORKOS_CLIENT_ID");
return self::$clientId;
}
$msg = "\$clientId is required.";
throw new \WorkOS\Exception\ConfigurationException($msg);
}
/**
* @param string $clientId WorkOS Client ID
*/
public static function setClientId($clientId)
{
self::$clientId = $clientId;
}
/**
* @return string WorkOS base API URL
*/
public static function getApiBaseURL()
{
return self::$apiBaseUrl;
}
/**
* @param string $apiBaseUrl WorkOS base API URL
*/
public static function setApiBaseUrl($apiBaseUrl)
{
self::$apiBaseUrl = $apiBaseUrl;
}
/**
* @param string $identifier SDK identifier
*/
public static function setIdentifier($identifier)
{
self::$identifier = $identifier;
}
/**
* @return string SDK identifier
*/
public static function getIdentifier()
{
return self::$identifier;
}
/**
* @param string $version SDK version
*/
public static function setVersion($version)
{
self::$version = $version;
}
/**
* @return string SDK version
*/
public static function getVersion()
{
return self::$version;
}
}