Skip to content

Commit

Permalink
Added Plans support
Browse files Browse the repository at this point in the history
  • Loading branch information
p_917148 committed Jul 29, 2019
1 parent 4984476 commit 60d3675
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 1 deletion.
49 changes: 49 additions & 0 deletions src/Contracts/ZoopPlans.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Zoop\Contracts;

use Zoop\Lib\APIResource;

interface ZoopPlans{

/**
* API Resource.
*
* @param $APIResource $APIResource
*/
public function __construct(APIResource $APIResource);

/**
* Create a new Plan
*
* @param $post array
*/
public function create($post);

/**
* Update a created plan
*
* @param $planID string
* @param $post array
*/
public function update($planID, $post);

/**
* Delete a Plan by id
*
* @param $planID string
*/
public function delete($planID);

/**
* Retrieve the details of a Plan by id
*
* @param $planID string
*/
public function get($planID);

/**
* Returns a JSON object with a list of plans.
*/
public function getAll();
}
15 changes: 15 additions & 0 deletions src/Facades/ZoopPlans.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Zoop\Facades;

use Illuminate\Support\Facades\Facade;

class ZoopPlans extends Facade{

/**
* @return string
*/
protected static function getFacadeAccessor(){
return 'ZoopPlans';
}
}
67 changes: 67 additions & 0 deletions src/Lib/ZoopPlans.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Zoop\Lib;


class ZoopPlans implements \Zoop\Contracts\ZoopPlans {

/**
* API Resource
*
* @var object
*/
protected $APIResource;

/**
* ZoopPlans constructor.
* @param APIResource $APIResource
*/
public function __construct(APIResource $APIResource){
$this->APIResource = $APIResource;
}

/**
* @param array $post
* @return mixed
*/
public function create($post = []){
$api = 'plans';
return $this->APIResource->createAPI($api, $post);
}

/**
* @param string $planID
* @param array $post
* @return mixed
*/
public function update($planID, $post){
$api = 'plans/' . $planID;
return $this->APIResource->updateAPI($api, $post);
}

/**
* @param string $planID
* @return mixed
*/
public function delete($planID){
$api = 'plans/' . $planID;
return $this->APIResource->deleteAPI($api);
}

/**
* @param string $planID
* @return mixed
*/
public function get($planID){
$api = 'plans/' . $planID;
return $this->APIResource->searchAPI($api);
}

/**
* @return mixed
*/
public function getAll(){
$api = 'plans';
return $this->APIResource->searchAPI($api);
}
}
8 changes: 7 additions & 1 deletion src/ZoopServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Zoop\Lib\ZoopSplitTransactions;
use Zoop\Lib\ZoopTokens;
use Zoop\Lib\ZoopTransfers;
use Zoop\Lib\ZoopPlans;

class ZoopServiceProvider extends ServiceProvider {

Expand Down Expand Up @@ -65,6 +66,10 @@ public function register(){
$this->app->singleton('ZoopTransfers', function () use ($service) {
return new ZoopTransfers(APIResource::getSingleton($service));
});

$this->app->singleton('ZoopPlans', function () use ($service) {
return new ZoopPlans(APIResource::getSingleton($service));
});
}

/**
Expand All @@ -78,7 +83,8 @@ public function provides(){
ZoopChargesCNP::class,
ZoopSellers::class,
ZoopTokens::class,
ZoopTransfers::class
ZoopTransfers::class,
ZoopPlans::class
];
}

Expand Down

0 comments on commit 60d3675

Please sign in to comment.