This commit is contained in:
Pererinha 2015-01-30 11:56:24 -02:00
parent 4e185337ed
commit de6c1b7b51
4 changed files with 84 additions and 13 deletions

View File

@ -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 '<pre>';var_dump( $request );exit();
}
}
public function init(){
$pex = new Crunchbutton_Pexcard_Resource;
echo '<pre>';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 '<pre>';var_dump( $buss->profile() );exit();
// $start = '01/01/2015';
// $end = '01/25/2015';
// $tranactios = Crunchbutton_Pexcard_Transaction::transactions( $start, $end );
// echo '<pre>';var_dump( $tranactios );exit();
$this->e( $tranactios );
}

View File

@ -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 ){

View File

@ -0,0 +1,10 @@
<?php
class Crunchbutton_Pexcard_Details extends Crunchbutton_Pexcard_Resource {
public function account(){
return Crunchbutton_Pexcard_Resource::request( 'detailsaccount' );
}
}
?>

View File

@ -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 '<pre>';var_dump( $request );exit();
return $request->send();
}
return false;