diff --git a/docs/class-ApiAxle.Shared.Config.html b/docs/class-ApiAxle.Shared.Config.html
index e33427d..3721274 100644
--- a/docs/class-ApiAxle.Shared.Config.html
+++ b/docs/class-ApiAxle.Shared.Config.html
@@ -126,7 +126,7 @@
Class Config
Author:
Phillip Shipley <phillip@phillipshipley.com>
- Located at src/ApiAxle/Shared/Config.php
+ Located at src/ApiAxle/Shared/Config.php
@@ -144,7 +144,7 @@ Class Config
#
- __construct( array $config = array() )
+ __construct( array $config = array() )
@@ -184,7 +184,7 @@ Parameters
#
- setConfg( array $config )
+ setConfg( array $config )
@@ -222,7 +222,7 @@ Parameters
#
- getConfig( )
+ getConfig( )
@@ -259,7 +259,7 @@ Returns
#
- loadConfigFile( string $file = false )
+ loadConfigFile( string $file = false )
@@ -307,7 +307,7 @@ Throws
#
- getEndpoint( )
+ getEndpoint( )
@@ -336,7 +336,7 @@ Throws
#
- setEndpoint( mixed $endpoint )
+ setEndpoint( mixed $endpoint )
@@ -365,7 +365,7 @@ Throws
#
- getKey( )
+ getKey( )
@@ -394,7 +394,7 @@ Throws
#
- setKey( mixed $key )
+ setKey( mixed $key )
@@ -423,7 +423,7 @@ Throws
#
- getSecret( )
+ getSecret( )
@@ -452,7 +452,7 @@ Throws
#
- setSecret( mixed $secret )
+ setSecret( mixed $secret )
@@ -481,7 +481,7 @@ Throws
#
- getSignature( )
+ getSignature( )
diff --git a/docs/source-class-ApiAxle.Api.Api.html b/docs/source-class-ApiAxle.Api.Api.html
index 4357b60..f4b88cb 100644
--- a/docs/source-class-ApiAxle.Api.Api.html
+++ b/docs/source-class-ApiAxle.Api.Api.html
@@ -331,7 +331,7 @@ Classes
234: $request = Utilities::callApi($apiPath, 'GET', $params, $this->getConfig());
235: if($request){
236: foreach($request as $name => $data){
-237: $api = new Api();
+237: $api = new Api($this->getConfig());
238: $api->setName($name);
239: $api->setData($data);
240: $apiList->addItem($api);
@@ -370,7 +370,7 @@ Classes
273:
274: public function update($data)
275: {
-276: if(!is_null($this->getName())){
+276: if(!is_null($this->getName()) && $this->isValid()){
277: $apiPath = 'api/'.$this->getName();
278: $request = Utilities::callApi($apiPath,'PUT',$data,$this->getConfig());
279: if($request){
@@ -506,7 +506,7 @@ Classes
409: $request = Utilities::callApi($apiPath, 'GET', $data,$this->getConfig());
410: if($request){
411: foreach($request as $item => $value){
-412: $key = new Key();
+412: $key = new Key($this->getConfig());
413: $key->setKey($item);
414: $key->setData($value);
415: $keyList->addItem($key);
diff --git a/docs/source-class-ApiAxle.Api.Key.html b/docs/source-class-ApiAxle.Api.Key.html
index 6b7e70f..12e6a06 100644
--- a/docs/source-class-ApiAxle.Api.Key.html
+++ b/docs/source-class-ApiAxle.Api.Key.html
@@ -354,7 +354,7 @@ Classes
257:
258: public function update($data)
259: {
-260: if(!is_null($this->getKey())){
+260: if(!is_null($this->getKey()) && $this->isValid()){
261: $apiPath = 'key/'.$this->getKey();
262: $request = Utilities::callApi($apiPath,'PUT',$data,$this->getConfig());
263: if($request){
@@ -418,7 +418,7 @@ Classes
321: $request = Utilities::callApi($apiPath, 'GET', $params, $this->getConfig());
322: if($request){
323: foreach($request as $name => $data){
-324: $key = new Key();
+324: $key = new Key($this->getConfig());
325: $key->setKey($name);
326: $key->setData($data);
327: $keyList->addItem($key);
@@ -447,7 +447,7 @@ Classes
350: $request = Utilities::callApi($apiPath, 'GET', $data, $this->getConfig());
351: if($request){
352: foreach($request as $name => $value){
-353: $api = new Api();
+353: $api = new Api($this->getConfig());
354: $api->setName($name);
355: $api->setData($value);
356: $apiList->addItem($api);
diff --git a/docs/source-class-ApiAxle.Api.Keyring.html b/docs/source-class-ApiAxle.Api.Keyring.html
index bdd7683..8ac93bb 100644
--- a/docs/source-class-ApiAxle.Api.Keyring.html
+++ b/docs/source-class-ApiAxle.Api.Keyring.html
@@ -272,7 +272,7 @@ Classes
175: $request = Utilities::callApi($apiPath, 'GET', $params, $this->getConfig());
176: if($request){
177: foreach($request as $name => $data){
-178: $keyring = new Keyring();
+178: $keyring = new Keyring($this->getConfig());
179: $keyring->setName($name);
180: $keyring->setData($data);
181: $keyringList->addItem($keyring);
@@ -336,7 +336,7 @@ Classes
239: $request = Utilities::callApi($apiPath, 'GET', $data,$this->getConfig());
240: if($request){
241: foreach($request as $item => $value){
-242: $key = new Key();
+242: $key = new Key($this->getConfig());
243: $key->setKey($item);
244: $key->setData($value);
245: $keyList->addItem($key);
diff --git a/docs/source-class-ApiAxle.Shared.Config.html b/docs/source-class-ApiAxle.Shared.Config.html
index 7b64f06..d46d19b 100644
--- a/docs/source-class-ApiAxle.Shared.Config.html
+++ b/docs/source-class-ApiAxle.Shared.Config.html
@@ -154,126 +154,130 @@ Exceptions
52: {
53: if($config && is_array($config) && count($config) > 0){
54: $this->setConfg($config);
- 55: } else {
- 56: $this->loadConfigFile();
- 57: }
- 58:
- 59: if(!is_null($this->endpoint) && !is_null($this->key) && !is_null($this->secret)){
- 60: $this->isInitialized = true;
+ 55: } elseif($config instanceof \ApiAxle\Shared\Config){
+ 56: $this->setEndpoint($config->getEndpoint());
+ 57: $this->setKey($config->getKey());
+ 58: $this->setSecret($config->getSecret());
+ 59: } else {
+ 60: $this->loadConfigFile();
61: }
- 62: }
- 63:
- 64: 65: 66: 67: 68:
- 69: public function setConfg($config)
- 70: {
- 71: $this->setEndpoint(isset($config['endpoint']) ? $config['endpoint'] : false);
- 72: $this->setKey(isset($config['key']) ? $config['key'] : false);
- 73: $this->setSecret(isset($config['secret']) ? $config['secret'] : false);
- 74: }
- 75:
- 76: 77: 78: 79: 80:
- 81: public function getConfig()
- 82: {
- 83: return array(
- 84: 'endpoint' => $this->endpoint,
- 85: 'key' => $this->key,
- 86: 'secret' => $this->secret
- 87: );
- 88: }
- 89:
- 90: 91: 92: 93: 94: 95: 96:
- 97: public function loadConfigFile($file=false)
- 98: {
- 99: $file = $file ?: __DIR__.'/../../../config/config.local.php';
-100: if(file_exists($file)){
-101: $config = include $file;
-102: if(is_array($config) && count($config) > 0){
-103: $this->setConfg($config);
-104: return true;
-105: }
-106: }
-107: throw new \Exception('Unable to load configuration from file '.$file, '100');
-108: }
-109:
-110: public function getEndpoint()
-111: {
-112: return $this->endpoint;
-113: }
-114:
-115: public function setEndpoint($endpoint)
-116: {
-117: $url = filter_var($endpoint, FILTER_VALIDATE_URL);
-118: if($url){
-119: if(preg_match('/^http[s]{0,1}:\/\//', $endpoint)){
-120: $this->endpoint = $endpoint;
-121: } else {
-122: throw new \Exception('Endpoint must start with http:// or https://',101);
-123: }
-124: } else {
-125: throw new \Exception('Invalid URL specified for Endpoint.',102);
-126: }
-127:
-128: return $this;
-129: }
-130:
-131: public function getKey()
-132: {
-133: return $this->key;
-134: }
-135:
-136: public function setKey($key)
-137: {
-138: $this->key = $key;
-139: }
-140:
-141: public function getSecret()
-142: {
-143: return $this->secret;
-144: }
-145:
-146: public function setSecret($secret)
-147: {
-148: $this->secret = $secret;
-149: }
-150:
-151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163:
-164: public function getSignature()
-165: {
-166: if(!is_null($this->secret)){
-167: $api_sig = hash_hmac('sha1', time().$this->getKey(), $this->getSecret());
-168: return $api_sig;
-169: } else {
-170: return false;
-171: }
-172: }
-173:
-174: }
+ 62:
+ 63: if(!is_null($this->endpoint) && !is_null($this->key) && !is_null($this->secret)){
+ 64: $this->isInitialized = true;
+ 65: }
+ 66: }
+ 67:
+ 68: 69: 70: 71: 72:
+ 73: public function setConfg($config)
+ 74: {
+ 75: $this->setEndpoint(isset($config['endpoint']) ? $config['endpoint'] : false);
+ 76: $this->setKey(isset($config['key']) ? $config['key'] : false);
+ 77: $this->setSecret(isset($config['secret']) ? $config['secret'] : false);
+ 78: }
+ 79:
+ 80: 81: 82: 83: 84:
+ 85: public function getConfig()
+ 86: {
+ 87: return array(
+ 88: 'endpoint' => $this->endpoint,
+ 89: 'key' => $this->key,
+ 90: 'secret' => $this->secret
+ 91: );
+ 92: }
+ 93:
+ 94: 95: 96: 97: 98: 99: 100:
+101: public function loadConfigFile($file=false)
+102: {
+103: $file = $file ?: __DIR__.'/../../../config/config.local.php';
+104: if(file_exists($file)){
+105: $config = include $file;
+106: if(is_array($config) && count($config) > 0){
+107: $this->setConfg($config);
+108: return true;
+109: }
+110: }
+111: throw new \Exception('Unable to load configuration from file '.$file, '100');
+112: }
+113:
+114: public function getEndpoint()
+115: {
+116: return $this->endpoint;
+117: }
+118:
+119: public function setEndpoint($endpoint)
+120: {
+121: $url = filter_var($endpoint, FILTER_VALIDATE_URL);
+122: if($url){
+123: if(preg_match('/^http[s]{0,1}:\/\//', $endpoint)){
+124: $this->endpoint = $endpoint;
+125: } else {
+126: throw new \Exception('Endpoint must start with http:// or https://',101);
+127: }
+128: } else {
+129: throw new \Exception('Invalid URL specified for Endpoint.',102);
+130: }
+131:
+132: return $this;
+133: }
+134:
+135: public function getKey()
+136: {
+137: return $this->key;
+138: }
+139:
+140: public function setKey($key)
+141: {
+142: $this->key = $key;
+143: }
+144:
+145: public function getSecret()
+146: {
+147: return $this->secret;
+148: }
+149:
+150: public function setSecret($secret)
+151: {
+152: $this->secret = $secret;
+153: }
+154:
+155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167:
+168: public function getSignature()
+169: {
+170: if(!is_null($this->secret)){
+171: $api_sig = hash_hmac('sha1', time().$this->getKey(), $this->getSecret());
+172: return $api_sig;
+173: } else {
+174: return false;
+175: }
+176: }
+177:
+178: }
| | | | | | | | | | |