Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just Idea for dev and production env #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/Client/TripletexClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ class TripletexClient
/**
* API's base URL.
*/
const BASE_URL = 'https://tripletex.no/v2';

/**
* @var string
*/
public static $BASE_URL = 'https://tripletex.no/v2';

/**
* @var \Http\Client\HttpClient|\Http\Client\HttpAsyncClient
Expand Down Expand Up @@ -45,6 +49,7 @@ class TripletexClient
*/
public function __construct(array $options = [])
{
$this->setBaseUrl($options['production'] ?? true);
$this->setHttpClient(isset($options['http_client']) ? $options['http_client'] : null);
$this->setSessionToken(isset($options['session_token']) ? $options['session_token'] : null);
$this->setCompanyId(isset($options['company_id']) ? $options['company_id'] : 0);
Expand All @@ -55,7 +60,16 @@ public function __construct(array $options = [])
*/
public static function getBaseUrl()
{
return self::BASE_URL;
return self::$BASE_URL;
}

/**
* @return string
*/
private function setBaseUrl($production)
{
self::$BASE_URL = $production ? 'https://tripletex.no/v2' : 'https://api.tripletex.io/v2';
return self;
}

/**
Expand Down