2 Commits

Author SHA1 Message Date
René Preuß
8232de4003 Update OauthTrait.php 2025-07-30 23:08:13 +02:00
René Preuß
ac3e28f67f Update composer.json 2025-07-30 21:52:09 +02:00
9 changed files with 29 additions and 41 deletions

View File

@@ -15,8 +15,8 @@
"require": {
"php": "^8.1",
"ext-json": "*",
"illuminate/support": "^11.0|^12.0",
"illuminate/console": "^11.0|^12.0",
"illuminate/support": "^10.0|^11.0|^12.0",
"illuminate/console": "^10.0|^11.0|^12.0",
"guzzlehttp/guzzle": "^6.3|^7.0",
"socialiteproviders/manager": "^3.4|^4.0.1",
"firebase/php-jwt": "^6.0"
@@ -49,4 +49,4 @@
}
}
}
}
}

View File

@@ -1,14 +0,0 @@
-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAi4Ta8r01zKaGSnGi1EiD
uMFWRXBlK4y/ZIfWBpElmS2ygv4mGeP3hT4Flm696Z2UMy56KC+c7CC/PQCiutLk
5NUphyX/t+0QS5Dqpw6FB33fLTNNY7GqSmGIUE4os8XYZRSyDQRgtOgq3R3vJkoV
7zoavTJmSCQlG5Qf0T//iMmzQ+b+6VZm1CJSz5nGx94u1DuXNyP5Epkk0wuHrtwy
kADR2lmydNodJzqpSD+8yQqnAhOZNtNF4qwQ3g13fRvHycBp3G2nlCfOn2g5PmYD
KYBKqvTq4PQH4E+K3pbbMz6zf/T6Dw7zTfksqHR4hqMgN6byRRxmwuBczIumcu9b
y7xbgoIGIVZXgJliALPFi+zTPTN7c8MedFs/xCBHCmzWYTCZfHgr8RPRewD19tCG
NSny5R0vlArpuZCTTgedPESDeGU4eNEddg4yXFzKlpE2nNuvzZ1Ohruc5ETOSU19
RTCBUBkjeL6ESZRd/yKGjbVx4dEYxZdIz4yBl+hZ2ZOIyG7L3zPrccAWrPpG56xr
E5IDBXxLFhaJ5LlyEAGQehB0ShEuCdkr88Xz7ba9PHpGqY83l4//ULrqPIZPAa4Z
E3AWHT1ZtXNPeA4SzZ9Y9Oij4M3chyHxqM0lL3kYP+dstZehTujStfElDIx2Ni10
73tILu4edYS0FxsL19m8gbsCAwEAAQ==
-----END PUBLIC KEY-----

View File

@@ -110,7 +110,7 @@ class AnikeenId
if ($redirectUri = config('services.anikeen.redirect')) {
$this->setRedirectUri($redirectUri);
}
if (self::getMode() === 'staging') {
if (config('services.anikeen.mode') === 'staging') {
self::setBaseUrl(self::$stagingBaseUrl);
}
if ($baseUrl = config('services.anikeen.base_url')) {
@@ -141,11 +141,6 @@ class AnikeenId
return self::$accessTokenField;
}
public static function getMode(): string
{
return config('services.anikeen.mode') ?: 'production';
}
public static function useRefreshTokenField(string $refreshTokenField): void
{
self::$refreshTokenField = $refreshTokenField;

View File

@@ -2,7 +2,6 @@
namespace Anikeen\Id\Helpers;
use Anikeen\Id\AnikeenId;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use Illuminate\Auth\AuthenticationException;
@@ -31,8 +30,6 @@ class JwtParser
private function getOauthPublicKey(): bool|string
{
return AnikeenId::getMode() === 'staging'
? file_get_contents(dirname(__DIR__, 3) . '/oauth-public.staging.key')
: file_get_contents(dirname(__DIR__, 3) . '/oauth-public.key');
return file_get_contents(dirname(__DIR__, 3) . '/oauth-public.key');
}
}

View File

@@ -23,13 +23,11 @@ trait OauthTrait
],
]);
$result = new Result($response, null);
$result = new Result($response, null, $this);
} catch (RequestException $exception) {
$result = new Result($exception->getResponse(), $exception);
$result = new Result($exception->getResponse(), $exception, $this);
}
$result->anikeenId = $this;
return $result;
}
}
}

View File

@@ -24,8 +24,7 @@ use Throwable;
* @property Response $response
* @property null|Throwable $exception
*/
#[\AllowDynamicProperties]
abstract class BaseCollection implements JsonSerializable
abstract class BaseCollection implements JsonSerializable
{
private Closure $callable;
public ?Result $result = null;
@@ -88,4 +87,4 @@ abstract class BaseCollection implements JsonSerializable
{
return isset($this->result->{$name});
}
}
}

View File

@@ -6,8 +6,7 @@ use Anikeen\Id\Exceptions\ResourceException;
use Anikeen\Id\Result;
use JsonSerializable;
#[\AllowDynamicProperties]
abstract class BaseResource implements JsonSerializable
abstract class BaseResource implements JsonSerializable
{
public Result $result;
@@ -54,4 +53,4 @@ abstract class BaseResource implements JsonSerializable
{
return false;
}
}
}

View File

@@ -10,12 +10,25 @@ class Transactions extends BaseCollection
{
use HasBillable;
/**
* Create a new transaction for the current user.
*
* @param array $attributes The attributes for the transaction.
* @throws Throwable
* @todo Add type hinting for the attributes array.
*/
public function create(array $attributes = []): Transaction
{
return (new Transaction($this->billable->request('POST', 'v1/transactions', $attributes)))
->setBillable($this->billable);
}
/**
* {@inheritDoc}
*/
public function find(string $id): ?Transaction
{
return (new Transaction(fn() => $this->billable->request('GET', sprintf('v1/transactions/%s', $id))))
->setBillable($this->billable);
->setBillable($this->billable);
}
}

View File

@@ -2,7 +2,6 @@
namespace Anikeen\Id\Socialite;
use Anikeen\Id\AnikeenId;
use Anikeen\Id\Enums\Scope;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Http\Request;
@@ -33,7 +32,9 @@ class Provider extends AbstractProvider implements ProviderInterface
*/
protected function getBaseUrl(): string
{
return AnikeenId::getMode() === 'staging'
$mode = config('services.anikeen.mode') ?? 'production';
return $mode === 'staging'
? 'https://staging.id.anikeen.com'
: 'https://id.anikeen.com';
}