mirror of
https://github.com/anikeen-com/id.git
synced 2026-07-30 12:52:00 +00:00
Compare commits
3 Commits
1.0.0-rc.1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c3f9344a0 | ||
|
|
a7ec7aa908 | ||
| 4555efa80c |
@@ -15,15 +15,15 @@
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"ext-json": "*",
|
||||
"illuminate/support": "^10.0|^11.0|^12.0",
|
||||
"illuminate/console": "^10.0|^11.0|^12.0",
|
||||
"illuminate/support": "^10.0|^11.0|^12.0|^13.0",
|
||||
"illuminate/console": "^10.0|^11.0|^12.0|^13.0",
|
||||
"guzzlehttp/guzzle": "^6.3|^7.0",
|
||||
"socialiteproviders/manager": "^3.4|^4.0.1",
|
||||
"firebase/php-jwt": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.0|^9.0",
|
||||
"laravel/framework": "^10.0|^11.0|^12.0"
|
||||
"laravel/framework": "^10.0|^11.0|^12.0|^13.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -55,14 +55,27 @@ trait ManagesPaymentMethods
|
||||
* @throws Throwable
|
||||
* @see \Anikeen\Id\Resources\PaymentMethods::hasDefaultPaymentMethod()
|
||||
*/
|
||||
public function hasDefaultPaymentMethod(): bool
|
||||
{
|
||||
return $this->paymentMethods()->hasDefaultPaymentMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get billing portal URL for the current user.
|
||||
*
|
||||
public function hasDefaultPaymentMethod(): bool
|
||||
{
|
||||
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.
|
||||
*
|
||||
* @param string|null $returnUrl The URL to redirect to after the user has finished in the billing portal.
|
||||
* @param array $options Additional options for the billing portal.
|
||||
* @throws Throwable
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -34,20 +34,34 @@ class PaymentMethods extends BaseCollection
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function defaultPaymentMethod(): PaymentMethod
|
||||
{
|
||||
if (!isset($this->defaultPaymentMethodCache)) {
|
||||
$this->defaultPaymentMethodCache = (new PaymentMethod(fn() => $this->billable->anikeenId()
|
||||
->request('GET', 'v1/payment-methods/default')))
|
||||
public function defaultPaymentMethod(): PaymentMethod
|
||||
{
|
||||
if (!isset($this->defaultPaymentMethodCache)) {
|
||||
$this->defaultPaymentMethodCache = (new PaymentMethod(fn() => $this->billable->anikeenId()
|
||||
->request('GET', 'v1/payment-methods/default')))
|
||||
->setBillable($this->billable);
|
||||
}
|
||||
|
||||
return $this->defaultPaymentMethodCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
||||
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}
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function find(string $id): ?PaymentMethod
|
||||
@@ -56,4 +70,4 @@ class PaymentMethods extends BaseCollection
|
||||
->request('GET', sprintf('v1/payment-methods/%s', $id))))
|
||||
->setBillable($this->billable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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