1private $config;
2 private static $instance;
3
4 private static function getInstance() {
5 if(is_null(self::$instance)){
6 self::$instance = new DSConfig();
7 }
8
9 return self::$instance;
10 }
11
12 public function __construct() {
13 date_default_timezone_set('UTC');
14
15 $clientId = getenv("DS_CLIENT_ID");
16 if (!is_null($clientId) and !empty($clientId)) {
17 $this->config["DS_CLIENT_ID"] = $clientId;
18 $this->config["DS_AUTH_SERVER"] = getenv("DS_AUTH_SERVER");
19 $this->config["DS_IMPERSONATED_USER_GUID"] = getenv("DS_IMPERSONATED_USER_GUID");
20 $this->config["DS_TARGET_ACCOUNT_ID"] = getenv("DS_TARGET_ACCOUNT_ID");
21 $this->config["SIGNER_EMAIL"] = getenv("SIGNER_EMAIL");
22 $this->config["SIGNER_NAME"] = getenv("SIGNER_NAME");
23 $this->config["CC_EMAIL"] = getenv("CC_EMAIL");
24 $this->config["CC_NAME"] = getenv("CC_NAME");
25 $this->config["DS_PRIVATE_KEY"] = getenv("DS_PRIVATE_KEY");
26 } else {
27 $this->config = parse_ini_file('ds_config.ini', true);
28 }
29 }
30
31 private function _auth_server() {
32 return $this->config["DS_AUTH_SERVER"];
33 }
34 public static function auth_server() {
35 return self::getInstance()->_auth_server();
36 }
37 private function _client_id() {
38 return $this->config["DS_CLIENT_ID"];
39 }
40 public static function client_id() {
41 return self::getInstance()->_client_id();
42 }
43 private function _impersonated_user_guid() {
44 return $this->config["DS_IMPERSONATED_USER_GUID"];
45 }
46 public static function impersonated_user_guid() {
47 return self::getInstance()->_impersonated_user_guid();
48 }
49 private function _target_account_id() {
50 return $this->config["DS_TARGET_ACCOUNT_ID"];
51 }
52 public static function target_account_id(){
53 return self::getInstance()->_target_account_id();
54 }
55 private function _signer_email() {
56 return $this->config["SIGNER_EMAIL"];
57 }
58 public static function signer_email(){
59 return self::getInstance()->_signer_email();
60 }
61 private function _signer_name(){
62 return $this->config["SIGNER_NAME"];
63 }
64 public static function signer_name(){
65 return self::getInstance()->_signer_name();
66 }
67 private function _cc_email() {
68 return $this->config["CC_EMAIL"];
69 }
70 public static function cc_email(){
71 return self::getInstance()->_cc_email();
72 }
73 private function _cc_name(){
74 return $this->config["CC_NAME"];
75 }
76 public static function cc_name(){
77 return self::getInstance()->_cc_name();
78 }
79 private function _private_key() {
80 return $this->config["DS_PRIVATE_KEY"];
81 }
82 public static function private_key(){
83 return self::getInstance()->_private_key();
84 }
85 public static function aud() {
86 $auth_server = self::getInstance()->_auth_server();
87
88 if (strpos($auth_server, 'https://') !== false) {
89 $aud = substr($auth_server, 8);
90 } else { # assuming http://blah
91 $aud = substr($auth_server, 7);
92 }
93 return $aud;
94 }
95 public static function api() {
96 return "restapi/v2";
97 }
98 public static function jwt_scope() {
99 return "signature";
100 }
101