Skip to content

Commit

Permalink
Added Subscriptions support
Browse files Browse the repository at this point in the history
  • Loading branch information
p_917148 committed Jul 29, 2019
1 parent 60d3675 commit 04435e5
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 5 deletions.
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/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';
}
}
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);
}
}
16 changes: 11 additions & 5 deletions src/ZoopServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Zoop\Lib\ZoopTokens;
use Zoop\Lib\ZoopTransfers;
use Zoop\Lib\ZoopPlans;
use Zoop\Lib\ZoopSubscriptions;

class ZoopServiceProvider extends ServiceProvider {

Expand Down Expand Up @@ -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));
});
}

Expand All @@ -85,6 +90,7 @@ public function provides(){
ZoopTokens::class,
ZoopTransfers::class,
ZoopPlans::class
ZoopSubscriptions::class
];
}

Expand Down

0 comments on commit 04435e5

Please sign in to comment.