mirror of
https://github.com/anikeen-com/id.git
synced 2026-07-30 21:02:10 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c3f9344a0 | ||
|
|
a7ec7aa908 |
@@ -3,6 +3,7 @@
|
||||
namespace Anikeen\Id;
|
||||
|
||||
use Anikeen\Id\Concerns\ManagesPricing;
|
||||
use Anikeen\Id\Concerns\ManagesSocialiteUsers;
|
||||
use Anikeen\Id\Concerns\ManagesSshKeys;
|
||||
use Anikeen\Id\Concerns\ManagesUsers;
|
||||
use Anikeen\Id\Exceptions\RequestRequiresAuthenticationException;
|
||||
@@ -20,6 +21,7 @@ class AnikeenId
|
||||
{
|
||||
use OauthTrait;
|
||||
use ManagesPricing;
|
||||
use ManagesSocialiteUsers;
|
||||
use ManagesSshKeys;
|
||||
use ManagesUsers;
|
||||
|
||||
|
||||
@@ -60,6 +60,19 @@ trait ManagesPaymentMethods
|
||||
return $this->paymentMethods()->hasDefaultPaymentMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default payment method for the current user.
|
||||
*
|
||||
* @throws Throwable
|
||||
* @see \Anikeen\Id\Resources\PaymentMethods::setDefault()
|
||||
*/
|
||||
public function setDefaultPaymentMethod(string $id): PaymentMethod
|
||||
{
|
||||
unset($this->paymentMethodsCache);
|
||||
|
||||
return $this->paymentMethods()->setDefault($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get billing portal URL for the current user.
|
||||
*
|
||||
|
||||
23
src/Id/Concerns/ManagesSocialiteUsers.php
Normal file
23
src/Id/Concerns/ManagesSocialiteUsers.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Concerns;
|
||||
|
||||
use Anikeen\Id\ApiOperations\Get;
|
||||
use Anikeen\Id\Resources\SocialiteUsers;
|
||||
use Throwable;
|
||||
|
||||
trait ManagesSocialiteUsers
|
||||
{
|
||||
use Get;
|
||||
|
||||
/**
|
||||
* Get all socialite connections for the authenticated user.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function socialiteUsers(): SocialiteUsers
|
||||
{
|
||||
return SocialiteUsers::builder(fn() => $this->get('v1/user/socialite-users'))
|
||||
->setParent($this);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,20 @@ class PaymentMethods extends BaseCollection
|
||||
return $this->defaultPaymentMethodCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default payment method for the current user.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function setDefault(string $id): PaymentMethod
|
||||
{
|
||||
unset($this->defaultPaymentMethodCache);
|
||||
|
||||
return (new PaymentMethod(fn() => $this->billable->anikeenId()
|
||||
->request('PUT', sprintf('v1/payment-methods/%s/default', $id))))
|
||||
->setBillable($this->billable);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
||||
18
src/Id/Resources/SocialiteUser.php
Normal file
18
src/Id/Resources/SocialiteUser.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Resources;
|
||||
|
||||
/**
|
||||
* @property string $id
|
||||
* @property string $user_id
|
||||
* @property string $driver
|
||||
* @property string $uid
|
||||
* @property string|null $display_name
|
||||
* @property string|null $avatar
|
||||
* @property string|null $expires_at
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class SocialiteUser extends BaseResource
|
||||
{
|
||||
}
|
||||
15
src/Id/Resources/SocialiteUsers.php
Normal file
15
src/Id/Resources/SocialiteUsers.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Resources;
|
||||
|
||||
use Anikeen\Id\Concerns\HasParent;
|
||||
|
||||
class SocialiteUsers extends BaseCollection
|
||||
{
|
||||
use HasParent;
|
||||
|
||||
public function find(string $id): ?SocialiteUser
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user