From 60d3675277fa7809006e93581acba4c4e18c7269 Mon Sep 17 00:00:00 2001 From: p_917148 Date: Mon, 29 Jul 2019 14:51:40 -0300 Subject: [PATCH 1/2] Added Plans support --- src/Contracts/ZoopPlans.php | 49 +++++++++++++++++++++++++++ src/Facades/ZoopPlans.php | 15 +++++++++ src/Lib/ZoopPlans.php | 67 +++++++++++++++++++++++++++++++++++++ src/ZoopServiceProvider.php | 8 ++++- 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/Contracts/ZoopPlans.php create mode 100644 src/Facades/ZoopPlans.php create mode 100644 src/Lib/ZoopPlans.php diff --git a/src/Contracts/ZoopPlans.php b/src/Contracts/ZoopPlans.php new file mode 100644 index 0000000..de4ab46 --- /dev/null +++ b/src/Contracts/ZoopPlans.php @@ -0,0 +1,49 @@ +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); + } +} \ No newline at end of file diff --git a/src/ZoopServiceProvider.php b/src/ZoopServiceProvider.php index f054067..83d07d2 100644 --- a/src/ZoopServiceProvider.php +++ b/src/ZoopServiceProvider.php @@ -13,6 +13,7 @@ use Zoop\Lib\ZoopSplitTransactions; use Zoop\Lib\ZoopTokens; use Zoop\Lib\ZoopTransfers; +use Zoop\Lib\ZoopPlans; class ZoopServiceProvider extends ServiceProvider { @@ -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)); + }); } /** @@ -78,7 +83,8 @@ public function provides(){ ZoopChargesCNP::class, ZoopSellers::class, ZoopTokens::class, - ZoopTransfers::class + ZoopTransfers::class, + ZoopPlans::class ]; } From 04435e5836156244945b445108e6315cbf18ed4a Mon Sep 17 00:00:00 2001 From: p_917148 Date: Mon, 29 Jul 2019 16:17:08 -0300 Subject: [PATCH 2/2] Added Subscriptions support --- src/Contracts/ZoopSubscriptions.php | 63 +++++++++++++++++++++ src/Facades/ZoopSubscriptions.php | 15 +++++ src/Lib/ZoopSubscriptions.php | 87 +++++++++++++++++++++++++++++ src/ZoopServiceProvider.php | 16 ++++-- 4 files changed, 176 insertions(+), 5 deletions(-) create mode 100644 src/Contracts/ZoopSubscriptions.php create mode 100644 src/Facades/ZoopSubscriptions.php create mode 100644 src/Lib/ZoopSubscriptions.php diff --git a/src/Contracts/ZoopSubscriptions.php b/src/Contracts/ZoopSubscriptions.php new file mode 100644 index 0000000..e3cfbbc --- /dev/null +++ b/src/Contracts/ZoopSubscriptions.php @@ -0,0 +1,63 @@ +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); + } +} \ No newline at end of file diff --git a/src/ZoopServiceProvider.php b/src/ZoopServiceProvider.php index 83d07d2..9754a81 100644 --- a/src/ZoopServiceProvider.php +++ b/src/ZoopServiceProvider.php @@ -14,6 +14,7 @@ use Zoop\Lib\ZoopTokens; use Zoop\Lib\ZoopTransfers; use Zoop\Lib\ZoopPlans; +use Zoop\Lib\ZoopSubscriptions; class ZoopServiceProvider extends ServiceProvider { @@ -52,23 +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)); + return new ZoopPlans(APIResource::getSingleton($service)); + }); + + $this->app->singleton('ZoopSubscriptions', function () use ($service) { + return new ZoopSubscriptions(APIResource::getSingleton($service)); }); } @@ -85,6 +90,7 @@ public function provides(){ ZoopTokens::class, ZoopTransfers::class, ZoopPlans::class + ZoopSubscriptions::class ]; }