Skip to content

Commit

Permalink
Basic constructor and makeRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Edofre committed Jan 11, 2017
1 parent d118775 commit e429424
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/NsApi.php
Expand Up @@ -8,17 +8,45 @@
* Class NsApi
* @package Edofre\NsApi
*/
class NsApi extends Client
class NsApi
{
/** API URL */
const API_URL = 'http://webservices.ns.nl/';
/** Endpoints */
const ENDPOINT_STATIONS = '/ns-api-stations-v2';
/** @var Client */
private $client;
/** @var */
/** @var */
private $username;
/** @var */
/** @var */
private $password;

/**
* NsApi constructor.
* @param array $config
*/
public function __construct(array $config = [])
{
$this->client = new Client(array_merge([
'base_uri' => self::API_URL,
], $config));

// Make sure we have a username and password
$this->username = config('ns-api.username');
$this->password = config('ns-api.password');
}

/**
* @param $request
* @return \Psr\Http\Message\ResponseInterface
*/
private function makeRequest($request)
{
return $this->client->get($request, [
'auth' => [
$this->username,
$this->password,
],
]);
}
}

0 comments on commit e429424

Please sign in to comment.