update resources

Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
2025-05-02 06:27:53 +02:00
parent 1725ec68de
commit 1d2119a32b
33 changed files with 303 additions and 320 deletions

View File

@@ -5,7 +5,7 @@ namespace Anikeen\Id\Concerns;
use Anikeen\Id\ApiOperations\Request;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Resources\Addresses;
use GuzzleHttp\Exception\GuzzleException;
use Throwable;
trait ManagesAddresses
{
@@ -14,21 +14,23 @@ trait ManagesAddresses
/**
* Get addresses from the current user.
*
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function addresses(): Addresses
{
return (new Addresses($this->request('GET', 'v1/addresses')))
->setBillable($this);
if (!isset($this->addressesCache)) {
$this->addressesCache = Addresses::builder(fn() => $this->request('GET', 'v1/addresses'))
->setBillable($this);
}
return $this->addressesCache;
}
/**
* Check if the current user has a default billing address.
*
* @see \Anikeen\Id\Resources\Addresses::hasDefaultBillingAddress()
* @throws RequestRequiresClientIdException
* @throws GuzzleException
* @throws Throwable
*/
public function hasDefaultBillingAddress(): bool
{