Environment.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. class ChargeBee_Environment {
  3. private $apiKey;
  4. private $site;
  5. private $apiEndPoint;
  6. private static $default_env;
  7. public static $scheme = "https";
  8. public static $chargebeeDomain;
  9. public static $connectTimeout= 50;
  10. public static $timeout=100;
  11. const API_VERSION = "v2";
  12. function __construct($site, $apiKey) {
  13. $this->site = $site;
  14. $this->apiKey = $apiKey;
  15. if (ChargeBee_Environment::$chargebeeDomain == null) {
  16. $this->apiEndPoint = "https://$site.chargebee.com/api/" . ChargeBee_Environment::API_VERSION;
  17. } else {
  18. $this->apiEndPoint = ChargeBee_Environment::$scheme . "://$site." . ChargeBee_Environment::$chargebeeDomain . "/api/" . ChargeBee_Environment::API_VERSION;
  19. }
  20. }
  21. public static function configure($site, $apiKey) {
  22. ChargeBee_Environment::$default_env = new ChargeBee_Environment($site, $apiKey);
  23. }
  24. public function getApiKey() {
  25. return $this->apiKey;
  26. }
  27. public function getSite() {
  28. return $this->site;
  29. }
  30. public function getApiEndpoint() {
  31. return $this->apiEndPoint;
  32. }
  33. public static function defaultEnv() {
  34. return ChargeBee_Environment::$default_env;
  35. }
  36. public function apiUrl($url) {
  37. return $this->apiEndPoint . $url;
  38. }
  39. }
  40. ?>