mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-06 15:48:36 +00:00
Bring the package up to date with the Anikeen ID API
Fixed (called endpoints that don't exist):
- charge(): POST v1/billing/charge (Stripe options aren't passed through anymore)
- Invoice::getInvoiceTemporaryUrl(): GET instead of a non-existent PUT
- OrderItems::create(): POST v1/orders/{order}/items
- createUser() / isEmailExisting(): admin endpoints with the app token
- sshKeysByUserId(): app endpoint; no longer returns the first user's keys for every user
- createOrderPreview(): country_iso goes into billing_address as the API expects
- public endpoints (products, order preview) work without a token
- SshKeys::find() results can be deleted
Added:
- Billable: sshKeys() (create, update, delete), billingOverview(), PaymentMethod::delete()
- AnikeenId: products(), boxes(), shipping labels (list, show, pdf, issue, ship, price list),
createOrderForUser(), createTransactionForUser(), findOrCreateSocialiteUser()
Requirements: PHP 8.2+, Laravel 11-13 (Laravel 10 and PHP 8.1 are end of life).
Docs generator handles union types; README regenerated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8de737641e
commit
9613d31a8d
22 files changed
+720
-108
No files matched your search
@@ -42,7 +42,36 @@ trait ManagesUsers
|
||||
*/
|
||||
public function createUser(array $attributes): Result
|
||||
{
|
||||
return $this->post('v1/users', $attributes);
|
||||
// the API takes a single display name
|
||||
if (!isset($attributes['name']) && (isset($attributes['first_name']) || isset($attributes['last_name']))) {
|
||||
$attributes['name'] = trim(($attributes['first_name'] ?? '') . ' ' . ($attributes['last_name'] ?? '')) ?: null;
|
||||
}
|
||||
|
||||
if (isset($attributes['password']) && !isset($attributes['password_confirmation'])) {
|
||||
$attributes['password_confirmation'] = $attributes['password'];
|
||||
}
|
||||
|
||||
unset($attributes['first_name'], $attributes['last_name']);
|
||||
|
||||
// finds the user by email or creates it (trusted apps, app token)
|
||||
return $this->asApp()->post('v1/admin/users', $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the user of a social login or create it (trusted apps, app token).
|
||||
*
|
||||
* @param string $provider The socialite driver, e.g. "twitch".
|
||||
* @param string $providerId The user's ID at the provider.
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function findOrCreateSocialiteUser(string $provider, string $providerId, ?string $email = null, ?string $name = null): Result
|
||||
{
|
||||
return $this->asApp()->post('v1/admin/users/socialite', array_filter([
|
||||
'provider' => $provider,
|
||||
'provider_id' => $providerId,
|
||||
'email' => $email,
|
||||
'name' => $name,
|
||||
], fn ($value) => $value !== null));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +96,8 @@ trait ManagesUsers
|
||||
*/
|
||||
public function isEmailExisting(string $email): Result
|
||||
{
|
||||
return $this->post('v1/users/check', [
|
||||
// `data.exists` tells whether an account uses the email (trusted apps, app token)
|
||||
return $this->asApp()->post('v1/admin/users/check', [
|
||||
'email' => $email,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user