diff --git a/README.md b/README.md index 663f506..35dd78d 100644 --- a/README.md +++ b/README.md @@ -18,15 +18,6 @@ PHP wrapper for the FreshBooks API. Simplifies FreshBooks API XML structure into The XML tag parameters you see on the freshbooks API page are the ones you pass to $fb->post() (as an array) -Statically : -```php -$domain = 'your-subdomain'; // https://your-subdomain.freshbooks.com/ -$token = '1234567890'; // your api token found in your account -Freshbooks\FreshBooksApi::init($domain, $token); -``` - -Or using _construct and object instance: - ```php $domain = 'your-subdomain'; // https://your-subdomain.freshbooks.com/ $token = '1234567890'; // your api token found in your account @@ -37,9 +28,6 @@ Example: list clients with an email of some@email.com ```php // Method names are the same as found on the freshbooks API -// Statically -$fb = new Freshbooks\FreshBooksApi('client.list'); -// Or $fb->setMethod('client.list'); // For complete list of arguments see FreshBooks docs at http://developers.freshbooks.com diff --git a/src/Freshbooks/FreshBooksApi.php b/src/Freshbooks/FreshBooksApi.php index 32f886d..0a6b80e 100644 --- a/src/Freshbooks/FreshBooksApi.php +++ b/src/Freshbooks/FreshBooksApi.php @@ -18,18 +18,16 @@ class FreshBooksApi { /* * The domain you need when making a request */ - protected static $_domain = ''; protected $domain = ''; /* * The API token you need when making a request */ - protected static $_token = ''; protected $token = ''; /* * The API url we're hitting. {{ DOMAIN }} will get replaced with $domain - * when you set FreshBooksApi::init($domain, $token) + * when you set `new FreshBooksApi($domain, $token)` */ protected $_api_url = 'https://{{ DOMAIN }}.freshbooks.com/api/2.1/xml-in'; @@ -59,19 +57,6 @@ class FreshBooksApi { */ protected $_response = array(); - /* - * Initialize the and store the domain/token for making requests - * - * @param string $domain The subdomain like 'yoursite'.freshbooks.com - * @param string $token The token found in your account settings area - * @return null - */ - public static function init($domain, $token) - { - self::$_domain = $domain; - self::$_token = $token; - } - /** * Initialize the and store the domain/token for making requests as init * does instead of doing what setMethod does @@ -169,7 +154,7 @@ public function request() if(!$this->domain || !$this->token) { throw new FreshBooksApiException( - 'You need to call new FreshBooksApi($domain, $token) or FreshBooksApi::init($domain, $token) with your domain and token.' + 'You need to call new FreshBooksApi($domain, $token) with your domain and token.' ); } diff --git a/src/sample.php b/src/sample.php index fa6ec43..f5d0ecd 100644 --- a/src/sample.php +++ b/src/sample.php @@ -5,12 +5,12 @@ // Setup the login credentials $domain = ''; $token = ''; -FreshBooksApi::init($domain, $token); /********************************************** * Fetch all clients by a specific id **********************************************/ -$fb = new FreshBooksApi('client.list'); +$fb = new FreshBooksApi($domain, $token); +$fb->setMethod('client.list'); $fb->post(array( 'email' => 'some@email.com' )); @@ -29,7 +29,8 @@ /********************************************** * List invoices from a specific client **********************************************/ -$fb = new FreshBooksApi('invoice.list'); +$fb = new FreshBooksApi($domain, $token); +$fb->setMethod('invoice.list'); $fb->post(array( 'client_id' => 41 )); @@ -47,7 +48,8 @@ /********************************************** * Create a recurring profile with multiple line items **********************************************/ -$fb = new FreshBooksApi('recurring.create'); +$fb = new FreshBooksApi($domain, $token); +$fb->setMethod('recurring.create'); $fb->post(array( 'recurring' => array( 'client_id' => 41, @@ -82,4 +84,4 @@ echo $fb->getError(); print_r($fb->getResponse()); -} \ No newline at end of file +}