use async_trait::async_trait;
use pib_client::PibClient;
use pib_service_api_types::{
Associated, ItemResponse, PagedResponse, Pagination, Search,
body::by_id_or_alias::{location, paper, paper_location::PaperLocation},
};
use pib_service_core_types::PaperLocationId;
use crate::{PageableItem, item::GetableItem};
#[async_trait(?Send)]
impl GetableItem<paper::by_id::location::ParentId, PaperLocationId, PaperLocation>
for PaperLocation
{
async fn get<C: PibClient>(
client: &C,
paper::by_id::location::ParentId { body_id, paper_id }: paper::by_id::location::ParentId,
paper_location_id: PaperLocationId,
associated: Associated,
) -> Result<
ItemResponse<paper::by_id::location::ParentId, PaperLocationId, PaperLocation>,
C::ClientError,
> {
Ok(client
.body_by_id_or_alias_paper_by_id_location_by_id_get(
body_id,
paper_id,
paper_location_id,
associated,
)
.await?)
}
}
#[async_trait(?Send)]
impl PageableItem<paper::by_id::location::ParentId, PaperLocationId, PaperLocation>
for PaperLocation
{
async fn get_page<C: PibClient>(
client: &C,
paper::by_id::location::ParentId { body_id, paper_id }: paper::by_id::location::ParentId,
pagination: Pagination,
search: Search,
associated: Associated,
) -> Result<
PagedResponse<paper::by_id::location::ParentId, PaperLocationId, PaperLocation>,
C::ClientError,
> {
Ok(client
.body_by_id_or_alias_paper_by_id_location_get(
body_id, paper_id, pagination, search, associated,
)
.await?)
}
}
#[async_trait(?Send)]
impl GetableItem<location::by_id::paper::ParentId, PaperLocationId, PaperLocation>
for PaperLocation
{
async fn get<C: PibClient>(
client: &C,
location::by_id::paper::ParentId {
body_id,
location_id,
}: location::by_id::paper::ParentId,
paper_location_id: PaperLocationId,
associated: Associated,
) -> Result<
ItemResponse<location::by_id::paper::ParentId, PaperLocationId, PaperLocation>,
C::ClientError,
> {
Ok(client
.body_by_id_or_alias_location_by_id_paper_by_id_get(
body_id,
location_id,
paper_location_id,
associated,
)
.await?)
}
}
#[async_trait(?Send)]
impl PageableItem<location::by_id::paper::ParentId, PaperLocationId, PaperLocation>
for PaperLocation
{
async fn get_page<C: PibClient>(
client: &C,
location::by_id::paper::ParentId {
body_id,
location_id,
}: location::by_id::paper::ParentId,
pagination: Pagination,
search: Search,
associated: Associated,
) -> Result<
PagedResponse<location::by_id::paper::ParentId, PaperLocationId, PaperLocation>,
C::ClientError,
> {
Ok(client
.body_by_id_or_alias_location_by_id_paper_get(
body_id,
location_id,
pagination,
search,
associated,
)
.await?)
}
}