Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/Beyonic.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php
define("BEYONIC_CLIENT_VERSION", "0.0.15");

if (!function_exists('curl_init')) {
throw new Exception('Beyonic requires the CURL PHP extension.');
}
Expand All @@ -22,4 +20,4 @@
require_once(dirname(__FILE__) . '/Beyonic/Transaction.php');
require_once(dirname(__FILE__) . '/Beyonic/Currency.php');
require_once(dirname(__FILE__) . '/Beyonic/Network.php');
require_once(dirname(__FILE__) . '/Beyonic/Beyonic_Exception.php');
require_once(dirname(__FILE__) . '/Beyonic/Beyonic_Exception.php');
42 changes: 26 additions & 16 deletions lib/Beyonic/Beyonic.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,47 @@ class Beyonic {
public static $apiVersion = null;
public static $lastResult = null;

/*
setAPIKey - Sets the API Key for this client / developer.
*/
/**
* setAPIKey - Sets the API Key for this client / developer.
*
* @param string $newApiKey
* @return void
*/
public static function setApiKey( $newApiKey ) {

self::$apiKey = $newApiKey;
}

/*
setAPIVersion - Sets the API Version for this client / developer.
*/
/**
* setAPIVersion - Sets the API Version for this client / developer.
*
* @param string $newApiVersion
* @return void
*/
public static function setApiVersion( $newApiVersion ) {

self::$apiVersion = $newApiVersion;
}

/*
/**
* getClientVersion - Get the client version
*
* @return string
*/
public static function getClientVersion() {
return BEYONIC_CLIENT_VERSION;
}

/*
sendRequest - Sends a REST request to the Beyonic API endpoint.
$endpoint is the endpoint that is the target of the request.
$method is one of GET, POST, PUT or DELETE.
$id is used to identify the target of a GET, PUT or DELETE request.
$parameters is used for POST and PUT, are content is based on the request.
$headerParameters is used for additional supported header parameters. Allows for overriding headers per request.
*/
/**
* sendRequest - Sends a REST request to the Beyonic API endpoint.
*
* @param string $endpoint the endpoint that is the target of the request
* @param string $method s one of GET, POST, PUT or DELETE.
* @param strint|int $id used to identify the target of a GET, PUT or DELETE request
* @param array|null $parameters used for POST and PUT, are content is based on the request
* @param array|null $headerParameters used for additional supported header parameters. Allows for overriding headers per request.
* @return mixed Response Object
*/
public static function sendRequest( $endpoint, $method = 'GET', $id = null, $parameters = null, $headerParameters = null) {

$requestURL = self::$apiURL . '/' . $endpoint;
Expand Down Expand Up @@ -143,4 +153,4 @@ public static function sendRequest( $endpoint, $method = 'GET', $id = null, $par
return( $endpointObject );
}
}
?>
?>
7 changes: 6 additions & 1 deletion lib/Beyonic/Beyonic_Exception.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php

/**
* Beyonic API client version
*/
define("BEYONIC_CLIENT_VERSION", "0.0.61");

/*
The Beyonic_Exception class provides information on errors that may arise
when using the Beyonic interface.
Expand All @@ -26,4 +31,4 @@ public function __toString() {
return __CLASS__ . " Error {$this->code}: {$this->message} when sending {$this->requestMethod} to {$this->requestURL}.\nError Details: {$this->responseBody}\n";
}
}
?>
?>
8 changes: 4 additions & 4 deletions lib/Beyonic/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require_once( dirname(__FILE__) . '/Endpoint_Wrapper.php');

/*
The Beyonic_Collection class provides access to the Collection API.
*/
/**
* The Beyonic_Collection class provides access to the Collection API.
*/
class Beyonic_Collection extends Beyonic_Endpoint_Wrapper {

protected static $endpoint = 'collections';

}
?>
?>
8 changes: 4 additions & 4 deletions lib/Beyonic/Collection_Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require_once( dirname(__FILE__) . '/Endpoint_Wrapper.php');

/*
The Beyonic_Collection_Request class provides access to the Collection Request API.
*/
/**
* The Beyonic_Collection_Request class provides access to the Collection Request API.
*/
class Beyonic_Collection_Request extends Beyonic_Endpoint_Wrapper {

protected static $endpoint = 'collectionrequests';

}
?>
?>
8 changes: 4 additions & 4 deletions lib/Beyonic/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require_once( dirname(__FILE__) . '/Endpoint_Wrapper.php');

/*
The Beyonic_Contact class provides access to the Contact API.
*/
/**
* The Beyonic_Contact class provides access to the Contact API.
*/
class Beyonic_Contact extends Beyonic_Endpoint_Wrapper {

protected static $endpoint = 'contacts';

}
?>
?>
8 changes: 4 additions & 4 deletions lib/Beyonic/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require_once( dirname(__FILE__) . '/Endpoint_Wrapper.php');

/*
The Beyonic_Currency class provides access to the Currencies API.
*/
/**
* The Beyonic_Currency class provides access to the Currencies API.
*/
class Beyonic_Currency extends Beyonic_Endpoint_Wrapper {

protected static $endpoint = 'currencies';

}
?>
?>
57 changes: 46 additions & 11 deletions lib/Beyonic/Endpoint_Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

require_once( dirname(__FILE__) . '/Beyonic.php' );

/*
The Beyonic_Endpoint_Wrapper class provides common routines needed by
all interface classses.
*/
/**
* The Beyonic_Endpoint_Wrapper class provides common routines needed by
* all interface classses.
*/
class Beyonic_Endpoint_Wrapper {

protected static $endpoint = null;
Expand All @@ -17,7 +17,12 @@ function __construct( $jsonObject ) {
$this->$prop = $value;
}

/* Send any changes made as a PATCH Request. Allows for overriding headers per request using $headerParameters */
/**
* Send any changes made as a PATCH Request. Allows for overriding headers per request using $headerParameters
*
* @param array $headerParameters
* @return static
*/
public function send( $headerParameters = null ) {

$values = array();
Expand All @@ -29,14 +34,25 @@ public function send( $headerParameters = null ) {

}

/* Get the associated object with $id */
/**
* Get the associated object with $id
*
* @param string|int $id
* @param array|null $parameters
* @return static
*/
public static function get( $id, $parameters = null ) {

return( new static( Beyonic::sendRequest( static::$endpoint, 'GET', $id, $parameters ) ) );
}

/* Get all of the associated object */
/* Use $parameters (when available) to search for a subset */
/**
* Get all of the associated object
*
* Use $parameters (when available) to search for a subset
* @param array|null $parameters
* @return array
*/
public static function getAll( $parameters = null ) {

$resp = Beyonic::sendRequest( static::$endpoint, 'GET', null, $parameters );
Expand All @@ -52,22 +68,41 @@ public static function getAll( $parameters = null ) {
return( $all );
}

/* Create the new object based on the $parameters and overrides headers for this requestr with $headerParameters */
/**
* Create the new object based on the $parameters and overrides headers for this requestr with $headerParameters.
*
* @param array|null $parameters
* @param array|null $headerParameters
* @return static
*/
public static function create( $parameters, $headerParameters = null ) {

return( new static( Beyonic::sendRequest( static::$endpoint, 'POST', null, $parameters, $headerParameters ) ) );
}

/* Update the object associated with $id using $parameters and overrides headers for this request with $headerParameters */
/**
* Update the object associated with $id using $parameters and overrides headers for this request with $headerParameters
*
* @param string|int $id
* @param array $parameters
* @param array|null $headerParameters
* @return static
*/
public static function update( $id, $parameters, $headerParameters = null ) {

return( new static( Beyonic::sendRequest( static::$endpoint, 'PATCH', $id, $parameters, $headerParameters ) ) );
}

/**
* Delete the object associated with $id
*
* @param string|int $id
*/
/* Delete the object associated with $id */
public static function delete( $id ) {

new static( Beyonic::sendRequest( static::$endpoint, 'DELETE', $id ) );
}

}
?>
?>
8 changes: 4 additions & 4 deletions lib/Beyonic/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require_once( dirname(__FILE__) . '/Endpoint_Wrapper.php');

/*
The Beyonic_Network class provides access to the Networks API.
*/
/**
* The Beyonic_Network class provides access to the Networks API.
*/
class Beyonic_Network extends Beyonic_Endpoint_Wrapper {

protected static $endpoint = 'networks';

}
?>
?>
8 changes: 4 additions & 4 deletions lib/Beyonic/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require_once( dirname(__FILE__) . '/Endpoint_Wrapper.php');

/*
The Beyonic_Payment class provides access to the Payment API.
*/
/**
* The Beyonic_Payment class provides access to the Payment API.
*/
class Beyonic_Payment extends Beyonic_Endpoint_Wrapper {

protected static $endpoint = 'payments';

}
?>
?>
8 changes: 4 additions & 4 deletions lib/Beyonic/Response.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/*
The BeyonicPayment class provides access to the Payment API.
*/
/**
* The BeyonicPayment class provides access to the Payment API.
*/
class Beyonic_Response {

private $endpoint;
Expand All @@ -27,4 +27,4 @@ public function send() {

}
}
?>
?>
8 changes: 4 additions & 4 deletions lib/Beyonic/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

require_once( dirname(__FILE__) . '/Endpoint_Wrapper.php');

/*
The Beyonic_Transaction class provides access to the Transactions API.
*/
/**
* The Beyonic_Transaction class provides access to the Transactions API.
*/
class Beyonic_Transaction extends Beyonic_Endpoint_Wrapper {

protected static $endpoint = 'transactions';

}
?>
?>
10 changes: 5 additions & 5 deletions lib/Beyonic/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

require_once( dirname(__FILE__) . '/Endpoint_Wrapper.php' );

/*
The Beyonic_Webhook class provides access to list, create, add & deletej
Webhook callbacks.
*/
/**
* The Beyonic_Webhook class provides access to list, create, add & deletej
* Webhook callbacks.
*/
class Beyonic_Webhook extends Beyonic_Endpoint_Wrapper {

protected static $endpoint = 'webhooks';

}
?>
?>