Permalink
Browse files

Basic constructor and makeRequest

  • Loading branch information...
1 parent d118775 commit e42942479a1129c5850d6de3b879af8ec2032a2b @Edofre committed Jan 11, 2017
Showing with 31 additions and 3 deletions.
  1. +31 −3 src/NsApi.php
View
@@ -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.