diff --git a/src/Client.php b/src/Client.php index 6fb7ecc..3008507 100644 --- a/src/Client.php +++ b/src/Client.php @@ -26,6 +26,7 @@ class Client */ public function __construct($accountId, $applicationKey, array $options = []) { + $this->accountId = $accountId; $this->applicationKey = $applicationKey; @@ -34,8 +35,15 @@ public function __construct($accountId, $applicationKey, array $options = []) } else { $this->client = new HttpClient(['exceptions' => false]); } + + if(!empty($options['authorization'])){ + $this->authToken = $options['authorization']['authToken']; + $this->apiUrl = $options['authorization']['apiUrl']; + $this->downloadUrl = $options['authorization']['downloadUrl']; + } else { + $this->authorizeAccount(); + } - $this->authorizeAccount(); } /** @@ -399,6 +407,22 @@ public function deleteFile(array $options) return true; } + + /** + * Retrieve authorization details from connection + * + * @return array + */ + public function getAuthorization() + { + + return [ + 'authToken' => $this->authToken, + 'apiUrl' => $this->apiUrl, + 'downloadUrl' => $this->downloadUrl + ]; + + } /** * Authorize the B2 account in order to get an auth token and API/download URLs.