Skip to content

Commit

Permalink
Merge pull request #44 from bookboon/hotfix/fix-last
Browse files Browse the repository at this point in the history
Make methods public and fix OauthClient
  • Loading branch information
lkm authored Nov 19, 2019
2 parents 3afe51f + edf92b6 commit 98b3486
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/Client/OauthClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ protected function executeQuery(

$options['headers']['User-Agent'] = $this->getUserAgentString();

if (count($variables) > 0 && $type == ClientInterface::HTTP_POST) {
if (count($variables) > 0
&& in_array($type, [ClientInterface::HTTP_POST, ClientInterface::HTTP_DELETE, ClientInterface::HTTP_PUT], true)) {
$postType = $contentType === ClientInterface::CONTENT_TYPE_JSON ? 'json' : 'form_params';
$options[$postType] = $variables;
}
Expand Down
34 changes: 23 additions & 11 deletions src/Entity/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,21 @@ protected function isValid(array $array): bool
* @return boolean
* @throws \Bookboon\Api\Exception\UsageException
*/
protected static function add(Bookboon $bookboon, string $email, bool $hasConsented, ?string $alias) : bool
public static function add(Bookboon $bookboon, string $email, bool $hasConsented, ?string $alias) : bool
{
$options = [
'email' => $email,
'hasConsented' => false
];

if ($alias !== null) {
$options['alias'] = $alias;
}

try {
$bookboon->rawRequest(
'/subscriptions',
[
'email' => $email,
'alias' => $alias,
'hasConsented' => false
],
$options,
ClientInterface::HTTP_POST,
false
);
Expand All @@ -55,15 +60,21 @@ protected static function add(Bookboon $bookboon, string $email, bool $hasConsen
* @return boolean
* @throws \Bookboon\Api\Exception\UsageException
*/
protected static function remove(Bookboon $bookboon, string $email, ?string $alias) : bool
public static function remove(Bookboon $bookboon, string $email, ?string $alias) : bool
{
$options = [
'email' => $email,
'hasConsented' => false
];

if ($alias !== null) {
$options['alias'] = $alias;
}

try {
$bookboon->rawRequest(
'/subscriptions',
[
'email' => $email,
'alias' => $alias
],
$options,
ClientInterface::HTTP_DELETE,
false
);
Expand All @@ -75,3 +86,4 @@ protected static function remove(Bookboon $bookboon, string $email, ?string $ali
}

}

0 comments on commit 98b3486

Please sign in to comment.