diff --git a/include/controllers/default/cockpit2/api/test/index.php b/include/controllers/default/cockpit2/api/test/index.php index 9dab4894a..233fdff46 100644 --- a/include/controllers/default/cockpit2/api/test/index.php +++ b/include/controllers/default/cockpit2/api/test/index.php @@ -2,19 +2,66 @@ class Controller_api_test extends Cana_Controller { + public function e( $request ){ + if( $request->body ){ + echo json_encode( $request->body );exit; + } else { + echo '
';var_dump( $request );exit();
+ }
+ }
+
public function init(){
- $pex = new Crunchbutton_Pexcard_Resource;
- echo '';var_dump( $pex->ping() );exit();
+ // $pex = new Crunchbutton_Pexcard_Resource;
+ // $this->e( $pex->ping() );
+
+ // $business = new Crunchbutton_Pexcard_Business;
+ // $this->e( $business->profile() );
+
+ // $business = new Crunchbutton_Pexcard_Business;
+ // $this->e( $business->admin() );
+ // $this->e( $business->admin( 1051 ) );
+
+ $details = new Crunchbutton_Pexcard_Details;
+ $this->e( $details->account() );
+
+
+ $card = new Crunchbutton_Pexcard_Card;
+ $card_create = $card->create( [ 'FirstName' => 'Daniel',
+ 'LastName' => 'Camargo',
+ 'DateOfBirth' => '09/05/2012',
+ 'Phone' => '_PHONE_',
+ 'ShippingPhone' => '_PHONE_',
+ 'ShippingMethod' => 'Expedited',
+ 'Email' => '_EMAIL',
+
+ 'ProfileAddress' => [
+ 'ContactName' => 'David',
+ 'AddressLine1' =>'1120 Princeton Drive #7',
+ 'AddressLine2' => '',
+ 'City' => 'Marina Del Rey',
+ 'State' =>'California',
+ 'PostalCode' => '90292',
+ 'Country' => 'USA'
+ ],
+
+ 'ShippingAddress' => [
+ 'ContactName' => 'David',
+ 'AddressLine1' =>'1120 Princeton Drive #7',
+ 'AddressLine2' => '',
+ 'City' => 'Marina Del Rey',
+ 'State' =>'California',
+ 'PostalCode' => '90292',
+ 'Country' => 'USA'
+ ] ] );
+ $this->e( $card_create );
- // $buss = new Crunchbutton_Pexcard_Business;
- // echo '';var_dump( $buss->profile() );exit();
// $start = '01/01/2015';
// $end = '01/25/2015';
// $tranactios = Crunchbutton_Pexcard_Transaction::transactions( $start, $end );
- // echo '';var_dump( $tranactios );exit();
+ $this->e( $tranactios );
}
diff --git a/include/library/Crunchbutton/Pexcard/Business.php b/include/library/Crunchbutton/Pexcard/Business.php
index b57ee24d3..5e3b8c002 100644
--- a/include/library/Crunchbutton/Pexcard/Business.php
+++ b/include/library/Crunchbutton/Pexcard/Business.php
@@ -11,7 +11,12 @@ class Crunchbutton_Pexcard_Business extends Crunchbutton_Pexcard_Resource {
}
public function profile(){
- return Crunchbutton_Pexcard_Resource::request( 'businessprofile', [], true );
+ return Crunchbutton_Pexcard_Resource::request( 'businessprofile' );
+ }
+
+ public function admin( $BusinessAdminId = null ){
+ $params = ( $BusinessAdminId ? [ 'BusinessAdminId' => $BusinessAdminId ] : [] );
+ return Crunchbutton_Pexcard_Resource::request( 'businessadmin', $params );
}
public function transactions( $start, $end ){
diff --git a/include/library/Crunchbutton/Pexcard/Details.php b/include/library/Crunchbutton/Pexcard/Details.php
new file mode 100644
index 000000000..69cd4b487
--- /dev/null
+++ b/include/library/Crunchbutton/Pexcard/Details.php
@@ -0,0 +1,10 @@
+
diff --git a/include/library/Crunchbutton/Pexcard/Resource.php b/include/library/Crunchbutton/Pexcard/Resource.php
index 199cd2963..f529c35ee 100644
--- a/include/library/Crunchbutton/Pexcard/Resource.php
+++ b/include/library/Crunchbutton/Pexcard/Resource.php
@@ -46,14 +46,18 @@ class Crunchbutton_Pexcard_Resource extends Cana_Table {
case 'v4':
$urls = [
- 'ping' => [ 'point' => '/Details/Ping', 'method' => 'GET' ],
- 'businessprofile' => [ 'point' => '/Business/Profile', 'method' => 'GET', 'auth' => 'token' ],
+ 'ping' => [ 'point' => 'Details/Ping', 'method' => 'GET' ],
+ 'businessprofile' => [ 'point' => 'Business/Profile', 'method' => 'GET', 'auth' => 'token' ],
+ 'businessadmin' => [ 'point' => 'Business/Admin', 'method' => 'GET', 'auth' => 'token' ],
+
+ 'createcard' => [ 'point' => 'Card/Create', 'method' => 'POST', 'auth' => 'token' ],
+
+ 'detailsaccount' => [ 'point' => 'Details/AccountDetails', 'method' => 'GET', 'auth' => 'token' ],
'cardlist' => 'admin/cardlist',
'carddetails' => 'admin/carddetails',
'fund' => 'admin/fund',
- 'createcard' => 'admin/createcard',
'changecardstatus' => 'admin/changecardstatus',
'spendbytransactionreport' => 'admin/SpendByTransactionReport',
'businessfundingreport' => 'admin/BusinessFundingReport',
@@ -78,10 +82,10 @@ class Crunchbutton_Pexcard_Resource extends Cana_Table {
switch ( Crunchbutton_Pexcard_Resource::api_version() ) {
case 'v4':
- return Crunchbutton_Pexcard_Resource::request_v4( $point, $params = [], $auth = true, $json = true );
+ return Crunchbutton_Pexcard_Resource::request_v4( $point, $params, $auth, $json );
break;
default:
- return Crunchbutton_Pexcard_Resource::request_v3( $point, $params = [], $auth = true, $json = true );
+ return Crunchbutton_Pexcard_Resource::request_v3( $point, $params, $auth, $json );
break;
}
}
@@ -107,6 +111,13 @@ class Crunchbutton_Pexcard_Resource extends Cana_Table {
$params = [];
}
+ if( strtolower( $method ) == 'get' ){
+ foreach ( $params as $key => $value ) {
+ $url .= '/' . $value;
+ }
+ $params = [];
+ }
+
if( $url ){
if( strtolower( $method ) == 'post' ){
@@ -141,8 +152,6 @@ class Crunchbutton_Pexcard_Resource extends Cana_Table {
$request->sendsForm();
}
- // echo '';var_dump( $request );exit();
-
return $request->send();
}
return false;