Skip to content

Commit

Permalink
Merge pull request #6 from taciobrito/master
Browse files Browse the repository at this point in the history
Update Plans and Subscriptions
  • Loading branch information
adhenrique authored Jul 29, 2019
2 parents 4984476 + 04435e5 commit ef11ebf
Show file tree
Hide file tree
Showing 7 changed files with 313 additions and 5 deletions.
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();
}
63 changes: 63 additions & 0 deletions src/Contracts/ZoopSubscriptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Zoop\Contracts;

use Zoop\Lib\APIResource;

interface ZoopSubscriptions{

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

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

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

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

/**
* Suspend a Subscription by id
*
* @param $subscriptionID string
*/
public function suspend($subscriptionID);

/**
* Reactivate a Subscription by id
*
* @param $subscriptionID string
*/
public function reactivate($subscriptionID);

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

/**
* Returns a JSON object with a list of Subscriptions.
*/
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';
}
}
15 changes: 15 additions & 0 deletions src/Facades/ZoopSubscriptions.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 ZoopSubscriptions extends Facade{

/**
* @return string
*/
protected static function getFacadeAccessor(){
return 'ZoopSubscriptions';
}
}
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);
}
}
87 changes: 87 additions & 0 deletions src/Lib/ZoopSubscriptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

namespace Zoop\Lib;


class ZoopSubscriptions implements \Zoop\Contracts\ZoopSubscriptions {

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

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

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

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

/**
* @param string $subscriptionID
* @param array $post
* @return mixed
*/
public function suspend($subscriptionID){
$api = 'subscriptions/' . $subscriptionID . '/suspend';
return $this->APIResource->createAPI($api);
}

/**
* @param string $subscriptionID
* @param array $post
* @return mixed
*/
public function reactivate($subscriptionID){
$api = 'subscriptions/' . $subscriptionID . '/reactivate';
return $this->APIResource->createAPI($api);
}

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

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

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

class ZoopServiceProvider extends ServiceProvider {

Expand Down Expand Up @@ -51,19 +53,27 @@ public function register(){
});

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

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

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

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

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

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

Expand All @@ -78,7 +88,9 @@ public function provides(){
ZoopChargesCNP::class,
ZoopSellers::class,
ZoopTokens::class,
ZoopTransfers::class
ZoopTransfers::class,
ZoopPlans::class
ZoopSubscriptions::class
];
}

Expand Down

0 comments on commit ef11ebf

Please sign in to comment.