This repository has been archived by the owner on Apr 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Subscriptions | ||
|
||
## Get the subscription info | ||
|
||
Show the subscribers / subscription info for any "recordings" object: Messages, Comments, Documents, | ||
Uploads, etc... | ||
|
||
```php | ||
$subscription = $recording->subscriptions()->show(); | ||
``` | ||
|
||
## Subscribe the current user | ||
|
||
```php | ||
$subscription = $recording->subscriptions()->subscribe(); | ||
``` | ||
|
||
## Unsubscribe the current user | ||
|
||
```php | ||
$response = $recording->subscriptions()->unsubscribe(); | ||
``` | ||
|
||
## Update the subscription info | ||
|
||
Pass the array of people id to subscribe or unsubscribe. | ||
|
||
```php | ||
$subscription = $recording->subscriptions()->update([ | ||
"subscriptions": [4,5,6], | ||
"unsubscriptions": [1,2,3], | ||
]); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Belvedere\Basecamp\Models; | ||
|
||
use Basecamp; | ||
|
||
class Subscription extends AbstractModel | ||
{ | ||
/** | ||
* Subscribe the current user. | ||
* | ||
* @return \Belvedere\Basecamp\Models\Subscription | ||
*/ | ||
public function subscribe() | ||
{ | ||
return Basecamp::subscriptions($this->url)->subscribe(); | ||
} | ||
|
||
/** | ||
* Unsubscribe the current user. | ||
* | ||
* @return string | ||
*/ | ||
public function unsubscribe() | ||
{ | ||
return Basecamp::subscriptions($this->url)->unsubscribe(); | ||
} | ||
|
||
/** | ||
* Update the subscription. | ||
* | ||
* @param array $data | ||
* @return \Illuminate\Http\Collection | ||
*/ | ||
public function update(array $data) | ||
{ | ||
return Basecamp::subscriptions($this->url)->update($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Belvedere\Basecamp\Sections; | ||
|
||
use Belvedere\Basecamp\Models\Subscription; | ||
use GuzzleHttp\Client; | ||
|
||
class Subscriptions extends AbstractSection | ||
{ | ||
/** | ||
* Store the api url for this section. | ||
* | ||
* @var string | ||
*/ | ||
protected $url; | ||
|
||
/** | ||
* Check for url in of bucket. | ||
* | ||
* @param \GuzzleHttp\Client $client | ||
* @param array $parameters | ||
* @return void | ||
*/ | ||
public function __construct(Client $client, array $parameters = []) | ||
{ | ||
parent::__construct($client, $parameters); | ||
|
||
if (filter_var($this->bucket, FILTER_VALIDATE_URL)) { | ||
$this->url = $this->bucket; | ||
} else { | ||
$this->url = sprintf('buckets/%d/recordings/%d/subscription.json', $this->bucket, $this->parent); | ||
} | ||
} | ||
|
||
/** | ||
* Show subscription info for a recording. | ||
* | ||
* @return \Belvedere\Basecamp\Models\Subscription | ||
*/ | ||
public function show() | ||
{ | ||
$subscription = $this->client->get($this->url); | ||
|
||
return new Subscription($this->response($subscription)); | ||
} | ||
|
||
/** | ||
* Subscribe the current user. | ||
* | ||
* @return \Belvedere\Basecamp\Models\Subscription | ||
*/ | ||
public function subscribe() | ||
{ | ||
$subscription = $this->client->post($this->url); | ||
|
||
return new Subscription($this->response($subscription)); | ||
} | ||
|
||
/** | ||
* Unsubscribe the current user. | ||
* | ||
* @return string | ||
*/ | ||
public function unsubscribe() | ||
{ | ||
return $this->client->delete($this->url); | ||
} | ||
|
||
/** | ||
* Update the subscription. | ||
* | ||
* @param array $data | ||
* @return \Belvedere\Basecamp\Models\Subscription | ||
*/ | ||
public function update(array $data) | ||
{ | ||
$subscription = $this->client->put( | ||
$this->url, | ||
[ | ||
'json' => $data, | ||
] | ||
); | ||
|
||
return new Subscription($this->response($subscription)); | ||
} | ||
} |