Exemplo n.º 1
0
 /**
  * Configure the API client with the required credentials.
  *
  * Requires a settings array to be passed in with the following keys:
  *
  * - store_url
  * - username
  * - api_key
  *
  * @param array $settings
  */
 public static function configure(array $settings)
 {
     if (!isset($settings['store_url'])) {
         throw new Exception("'store_url' must be provided");
     }
     if (!isset($settings['username'])) {
         throw new Exception("'username' must be provided");
     }
     if (!isset($settings['api_key'])) {
         throw new Exception("'api_key' must be provided");
     }
     self::$username = $settings['username'];
     self::$api_key = $settings['api_key'];
     self::$store_url = rtrim($settings['store_url'], '/');
     self::$api_path = self::$store_url . self::$api_path;
 }
Exemplo n.º 2
0
 /**
  * Configure the API client with the required credentials.
  *
  * Requires a settings array to be passed in with the following keys:
  *
  * - store_url
  * - username
  * - api_key
  *
  * @param array $settings
  */
 public static function configure(array $settings)
 {
     if (!isset($settings['store_url'])) {
         throw new Exception("'store_url' must be provided");
     }
     if (!isset($settings['username'])) {
         throw new Exception("'username' must be provided");
     }
     if (!isset($settings['api_key'])) {
         throw new Exception("'api_key' must be provided");
     }
     // Needed to add this to reset the connection if connecting to a different account
     // this will effectively reset the username and password in curl
     if (isset(self::$api_key) && self::$api_key != $settings['api_key']) {
         self::$connection = FALSE;
     }
     self::$username = $settings['username'];
     self::$api_key = $settings['api_key'];
     self::$store_url = rtrim($settings['store_url'], '/');
     self::$api_path = self::$store_url . '/api/v2';
 }