Skip to content

Commit

Permalink
allow passing of credentials to clients via constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
padams committed Nov 7, 2021
1 parent 3fb50f7 commit 076dc02
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/OwaClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public function __construct( $config ) {

'instance_url' => '',
'ns' => 'owa_',
'endpoint' => 'api'
'endpoint' => 'api',
'credentials' => []
];

// override default config with config array passed in.
Expand All @@ -36,9 +37,7 @@ public function setSetting( $name, $value ) {

public function getCredentials() {

static $credentials;

if ( empty ( $credentials ) ) {
if ( empty ( $this->config['credentials'] ) ) {

$credentials = [

Expand All @@ -60,8 +59,7 @@ public function getCredentials() {
if ( defined('OWA_API_KEY') ) {

$credentials['api_key'] = OWA_API_KEY;
}

}
}

// check environment variables
Expand All @@ -78,7 +76,6 @@ public function getCredentials() {

$credentials['auth_key'] = OWA_AUTH_KEY;
}

}

//check credentials file in home dir.
Expand All @@ -97,10 +94,11 @@ public function getCredentials() {
}
}
}


$this->config['credentials'] = $credentials;
}

return $credentials;
return $this->config['credentials'];
}

private function getHomeDirectory() {
Expand Down

0 comments on commit 076dc02

Please sign in to comment.