Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/HelloassoClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
$this->checkout = new CheckoutIntentService($apiCaller, $organizationSlug);
$this->directory = new DirectoryService();
$this->payment = new PaymentService($apiCaller, $organizationSlug);
$this->order = new OrderService($apiCaller);
$this->order = new OrderService($apiCaller, $organizationSlug);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/Models/Statistics/OrderCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Helloasso\Models\Statistics;

use Helloasso\Models\Common\Collection;

/**
* @extends Collection<Order>
*/
class OrderCollection extends Collection
{
/**
* Overriding the property with an @var annotation is needed for the
* serializer component until generics are not supported.
*
* @var Order[]
*/
protected array $data = [];
}
23 changes: 23 additions & 0 deletions src/Service/OrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,37 @@

use Helloasso\Exception\HelloassoApiException;
use Helloasso\Http\ApiCaller;
use Helloasso\Models\Statistics\Order;
use Helloasso\Models\Statistics\OrderCollection;

class OrderService
{
public function __construct(
private readonly ApiCaller $apiCaller,
private readonly string $organizationSlug,
) {
}

/**
* @throws HelloassoApiException
*/
public function retrieve(int $id): Order
{
return $this->apiCaller->get("/v5/orders/$id", Order::class);
}

/**
* @param array<string, mixed> $params
*
* @throws HelloassoApiException
*/
public function all(array $params = []): OrderCollection
{
return $this->apiCaller->get("/v5/organizations/{$this->organizationSlug}/orders", OrderCollection::class, [
'query' => $params,
]);
}

/**
* @throws HelloassoApiException
*/
Expand Down