/** * Register default client */ public function setupClient() { $this->app['apiClient'] = $this->app->share(function ($app) { $config = $app['config']->get('jwt-api-client::config.configuration'); // Instantiate client $auth = $this->determineAuthentication($app); $client = new ApiClient($config['url'], $config['name'], $config['version'], $auth); // Apply authentication and set config $client->setConfig($app['config']->get('jwt-api-client::config')); return $client; }); }
/** * Register default client * * @return ApiClient */ public function setupClient() { // Provide list of required fields $clientConfig = $this->config['configuration']; // Validate fields or throw an exception Helper::validateFields($clientConfig, ['url', 'name', 'version'], 'configuration'); // If array with invalid fields is empty, proceed login if (empty($invalidFields)) { $auth = $this->determineAuthentication(); // Setup client connection for generation token $client = new ApiClient($clientConfig['url'], $clientConfig['name'], $clientConfig['version'], $auth); $client->setConfig($this->config); return $client; } }