vendor/sendinblue/api-v3-sdk/lib/Configuration.php line 116

Open in your IDE?
  1. <?php
  2. /**
  3.  * Configuration
  4.  * PHP version 5
  5.  *
  6.  * @category Class
  7.  * @package  SendinBlue\Client
  8.  * @author   Swagger Codegen team
  9.  * @link     https://github.com/swagger-api/swagger-codegen
  10.  */
  11. /**
  12.  * SendinBlue API
  13.  *
  14.  * SendinBlue provide a RESTFul API that can be used with any languages. With this API, you will be able to :   - Manage your campaigns and get the statistics   - Manage your contacts   - Send transactional Emails and SMS   - and much more...  You can download our wrappers at https://github.com/orgs/sendinblue  **Possible responses**   | Code | Message |   | :-------------: | ------------- |   | 200  | OK. Successful Request  |   | 201  | OK. Successful Creation |   | 202  | OK. Request accepted |   | 204  | OK. Successful Update/Deletion  |   | 400  | Error. Bad Request  |   | 401  | Error. Authentication Needed  |   | 402  | Error. Not enough credit, plan upgrade needed  |   | 403  | Error. Permission denied  |   | 404  | Error. Object does not exist |   | 405  | Error. Method not allowed  |   | 406  | Error. Not Acceptable  |
  15.  *
  16.  * OpenAPI spec version: 3.0.0
  17.  * Contact: contact@sendinblue.com
  18.  * Generated by: https://github.com/swagger-api/swagger-codegen.git
  19.  * Swagger Codegen version: 2.4.12
  20.  */
  21. /**
  22.  * NOTE: This class is auto generated by the swagger code generator program.
  23.  * https://github.com/swagger-api/swagger-codegen
  24.  * Do not edit the class manually.
  25.  */
  26. namespace SendinBlue\Client;
  27. /**
  28.  * Configuration Class Doc Comment
  29.  * PHP version 5
  30.  *
  31.  * @category Class
  32.  * @package  SendinBlue\Client
  33.  * @author   Swagger Codegen team
  34.  * @link     https://github.com/swagger-api/swagger-codegen
  35.  */
  36. $GLOBALS['version'] = '7.4.3';
  37. class Configuration
  38. {
  39.     private static $defaultConfiguration;
  40.     /**
  41.      * Associate array to store API key(s)
  42.      *
  43.      * @var string[]
  44.      */
  45.     protected $apiKeys = [];
  46.     /**
  47.      * Associate array to store API prefix (e.g. Bearer)
  48.      *
  49.      * @var string[]
  50.      */
  51.     protected $apiKeyPrefixes = [];
  52.     /**
  53.      * Access token for OAuth
  54.      *
  55.      * @var string
  56.      */
  57.     protected $accessToken '';
  58.     /**
  59.      * Username for HTTP basic authentication
  60.      *
  61.      * @var string
  62.      */
  63.     protected $username '';
  64.     /**
  65.      * Password for HTTP basic authentication
  66.      *
  67.      * @var string
  68.      */
  69.     protected $password '';
  70.     /**
  71.      * The host
  72.      *
  73.      * @var string
  74.      */
  75.     protected $host 'https://api.sendinblue.com/v3';
  76.     /**
  77.      * Debug switch (default set to false)
  78.      *
  79.      * @var bool
  80.      */
  81.     protected $debug false;
  82.     /**
  83.      * Debug file location (log to STDOUT by default)
  84.      *
  85.      * @var string
  86.      */
  87.     protected $debugFile 'php://output';
  88.     /**
  89.      * Debug file location (log to STDOUT by default)
  90.      *
  91.      * @var string
  92.      */
  93.     protected $tempFolderPath;
  94.     /**
  95.      * Constructor
  96.      */
  97.     public function __construct()
  98.     {
  99.         $this->tempFolderPath sys_get_temp_dir();
  100.         $this->userAgent 'sendinblue_clientAPI/v' $GLOBALS['version'] . '/php'
  101.     }
  102.     /**
  103.      * Sets API key
  104.      *
  105.      * @param string $apiKeyIdentifier API key identifier (authentication scheme)
  106.      * @param string $key              API key or token
  107.      *
  108.      * @return $this
  109.      */
  110.     public function setApiKey($apiKeyIdentifier$key)
  111.     {
  112.         $this->apiKeys[$apiKeyIdentifier] = $key;
  113.         return $this;
  114.     }
  115.     /**
  116.      * Gets API key
  117.      *
  118.      * @param string $apiKeyIdentifier API key identifier (authentication scheme)
  119.      *
  120.      * @return string API key or token
  121.      */
  122.     public function getApiKey($apiKeyIdentifier)
  123.     {
  124.         return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null;
  125.     }
  126.     /**
  127.      * Sets the prefix for API key (e.g. Bearer)
  128.      *
  129.      * @param string $apiKeyIdentifier API key identifier (authentication scheme)
  130.      * @param string $prefix           API key prefix, e.g. Bearer
  131.      *
  132.      * @return $this
  133.      */
  134.     public function setApiKeyPrefix($apiKeyIdentifier$prefix)
  135.     {
  136.         $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix;
  137.         return $this;
  138.     }
  139.     /**
  140.      * Gets API key prefix
  141.      *
  142.      * @param string $apiKeyIdentifier API key identifier (authentication scheme)
  143.      *
  144.      * @return string
  145.      */
  146.     public function getApiKeyPrefix($apiKeyIdentifier)
  147.     {
  148.         return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null;
  149.     }
  150.     /**
  151.      * Sets the access token for OAuth
  152.      *
  153.      * @param string $accessToken Token for OAuth
  154.      *
  155.      * @return $this
  156.      */
  157.     public function setAccessToken($accessToken)
  158.     {
  159.         $this->accessToken $accessToken;
  160.         return $this;
  161.     }
  162.     /**
  163.      * Gets the access token for OAuth
  164.      *
  165.      * @return string Access token for OAuth
  166.      */
  167.     public function getAccessToken()
  168.     {
  169.         return $this->accessToken;
  170.     }
  171.     /**
  172.      * Sets the username for HTTP basic authentication
  173.      *
  174.      * @param string $username Username for HTTP basic authentication
  175.      *
  176.      * @return $this
  177.      */
  178.     public function setUsername($username)
  179.     {
  180.         $this->username $username;
  181.         return $this;
  182.     }
  183.     /**
  184.      * Gets the username for HTTP basic authentication
  185.      *
  186.      * @return string Username for HTTP basic authentication
  187.      */
  188.     public function getUsername()
  189.     {
  190.         return $this->username;
  191.     }
  192.     /**
  193.      * Sets the password for HTTP basic authentication
  194.      *
  195.      * @param string $password Password for HTTP basic authentication
  196.      *
  197.      * @return $this
  198.      */
  199.     public function setPassword($password)
  200.     {
  201.         $this->password $password;
  202.         return $this;
  203.     }
  204.     /**
  205.      * Gets the password for HTTP basic authentication
  206.      *
  207.      * @return string Password for HTTP basic authentication
  208.      */
  209.     public function getPassword()
  210.     {
  211.         return $this->password;
  212.     }
  213.     /**
  214.      * Sets the host
  215.      *
  216.      * @param string $host Host
  217.      *
  218.      * @return $this
  219.      */
  220.     public function setHost($host)
  221.     {
  222.         $this->host $host;
  223.         return $this;
  224.     }
  225.     /**
  226.      * Gets the host
  227.      *
  228.      * @return string Host
  229.      */
  230.     public function getHost()
  231.     {
  232.         return $this->host;
  233.     }
  234.     /**
  235.      * Sets the user agent of the api client
  236.      *
  237.      * @param string $userAgent the user agent of the api client
  238.      *
  239.      * @throws \InvalidArgumentException
  240.      * @return $this
  241.      */
  242.     public function setUserAgent($userAgent)
  243.     {
  244.         if (!is_string($userAgent)) {
  245.             throw new \InvalidArgumentException('User-agent must be a string.');
  246.         }
  247.         if(strpos($userAgent'sendinblue_') !== false) {
  248.             $this->userAgent $userAgent;
  249.         }
  250.         return $this;
  251.     }
  252.     /**
  253.      * Gets the user agent of the api client
  254.      *
  255.      * @return string user agent
  256.      */
  257.     public function getUserAgent()
  258.     {
  259.         return $this->userAgent;
  260.     }
  261.     /**
  262.      * Sets debug flag
  263.      *
  264.      * @param bool $debug Debug flag
  265.      *
  266.      * @return $this
  267.      */
  268.     public function setDebug($debug)
  269.     {
  270.         $this->debug $debug;
  271.         return $this;
  272.     }
  273.     /**
  274.      * Gets the debug flag
  275.      *
  276.      * @return bool
  277.      */
  278.     public function getDebug()
  279.     {
  280.         return $this->debug;
  281.     }
  282.     /**
  283.      * Sets the debug file
  284.      *
  285.      * @param string $debugFile Debug file
  286.      *
  287.      * @return $this
  288.      */
  289.     public function setDebugFile($debugFile)
  290.     {
  291.         $this->debugFile $debugFile;
  292.         return $this;
  293.     }
  294.     /**
  295.      * Gets the debug file
  296.      *
  297.      * @return string
  298.      */
  299.     public function getDebugFile()
  300.     {
  301.         return $this->debugFile;
  302.     }
  303.     /**
  304.      * Sets the temp folder path
  305.      *
  306.      * @param string $tempFolderPath Temp folder path
  307.      *
  308.      * @return $this
  309.      */
  310.     public function setTempFolderPath($tempFolderPath)
  311.     {
  312.         $this->tempFolderPath $tempFolderPath;
  313.         return $this;
  314.     }
  315.     /**
  316.      * Gets the temp folder path
  317.      *
  318.      * @return string Temp folder path
  319.      */
  320.     public function getTempFolderPath()
  321.     {
  322.         return $this->tempFolderPath;
  323.     }
  324.     /**
  325.      * Gets the default configuration instance
  326.      *
  327.      * @return Configuration
  328.      */
  329.     public static function getDefaultConfiguration()
  330.     {
  331.         if (self::$defaultConfiguration === null) {
  332.             self::$defaultConfiguration = new Configuration();
  333.         }
  334.         return self::$defaultConfiguration;
  335.     }
  336.     /**
  337.      * Sets the detault configuration instance
  338.      *
  339.      * @param Configuration $config An instance of the Configuration Object
  340.      *
  341.      * @return void
  342.      */
  343.     public static function setDefaultConfiguration(Configuration $config)
  344.     {
  345.         self::$defaultConfiguration $config;
  346.     }
  347.     /**
  348.      * Gets the essential information for debugging
  349.      *
  350.      * @return string The report for debugging
  351.      */
  352.     public static function toDebugReport()
  353.     {
  354.         $report  'PHP SDK (SendinBlue\Client) Debug Report:' PHP_EOL;
  355.         $report .= '    OS: ' php_uname() . PHP_EOL;
  356.         $report .= '    PHP Version: ' PHP_VERSION PHP_EOL;
  357.         $report .= '    OpenAPI Spec Version: 3.0.0' PHP_EOL;
  358.         $report .= '    Temp Folder Path: ' self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
  359.         return $report;
  360.     }
  361.     /**
  362.      * Get API key (with prefix if set)
  363.      *
  364.      * @param  string $apiKeyIdentifier name of apikey
  365.      *
  366.      * @return string API key with the prefix
  367.      */
  368.     public function getApiKeyWithPrefix($apiKeyIdentifier)
  369.     {
  370.         $prefix $this->getApiKeyPrefix($apiKeyIdentifier);
  371.         $apiKey $this->getApiKey($apiKeyIdentifier);
  372.         if ($apiKey === null) {
  373.             return null;
  374.         }
  375.         if ($prefix === null) {
  376.             $keyWithPrefix $apiKey;
  377.         } else {
  378.             $keyWithPrefix $prefix ' ' $apiKey;
  379.         }
  380.         return $keyWithPrefix;
  381.     }
  382. }