Permalink
Browse files

Updated README.md. Removed a whole lot of code from ubersmith.php now…

… that we're working with the 2.0 API instead of the old once. Nice and simple.
  • Loading branch information...
1 parent ac23868 commit 9b6393142728670e8ffc8e2f6b60bf5e6e5899e9 jph committed May 15, 2012
Showing with 7 additions and 18 deletions.
  1. +4 −2 README.md
  2. +3 −16 ubersmith.php
View
@@ -1,7 +1,9 @@
Ubersmith API layer
-MIT License (see LICENSE)
-Basically what I intend to do here is make a nice layer for Ubersmith's 2.0 API, as the example shipped with the software is lacking in readability.
+Copyright (c) 2012 James Hynes
+For full license details see LICENSE
+
+What I've intended to do here is make a nice layer for Ubersmith's 2.0 API, as the example shipped with the software is lacking in readability.
```php
<?
View
@@ -4,9 +4,6 @@ class Ubersmith
{
private $endpoint, $auth_string, $arguments_to_send, $result, $request_url, $response;
- var $ubersmith_functions = [ 'client.service_list' => 'client.service_list' ];
- var $ubersmith_arguments = [ 'client.service_list' => [ 'client_id' ] ];
-
function __construct($api_ip, $api_user, $api_pass)
{
$this->endpoint = 'http://' . $api_ip . '/api/2.0/?';
@@ -32,7 +29,7 @@ public function execute()
private function generate_url()
{
$this->request_url = $this->endpoint . 'method=' . $this->provided_method . "&";
- foreach($this->arguments_to_send as $key => $val)
+ foreach($this->provided_arguments as $key => $val)
{
$this->request_url .= $key . "=" . $val . "&";
}
@@ -41,17 +38,9 @@ private function generate_url()
public function __call($method, $args)
{
$this->provided_method = preg_replace('/_/', '.', $method, 1);
- if(!$method)
- throw new Exception("Method does not exist");
-
$this->provided_arguments = (array) json_decode($args[0]);
- foreach($this->provided_arguments as $provided_argument => $provided_value)
- {
- if(array_search($provided_argument, $this->ubersmith_arguments[$this->provided_method]) !== FALSE)
- $this->arguments_to_send[$provided_argument] = $provided_value;
- }
- if(count($this->arguments_to_send) == 0)
- throw new Exception("No valid arguments provided.");
+
+ if(count($this->provided_arguments) == 0) throw new Exception("No valid arguments provided.");
$this->generate_url();
@@ -64,5 +53,3 @@ public function result()
}
}
-
-// end

0 comments on commit 9b63931

Please sign in to comment.