hyperspace-rs 0.2.0

A Rust library to interact with [Hyperspace](https://avax.hyperspace.xyz/) NFT marketplace on Avalanche
Documentation
use serde::{Deserialize, Serialize};

use crate::types::{MarketplaceSnapshot, PaginationConfig, PaginationInfo};

use super::H160;

#[derive(Debug, Serialize)]
pub(crate) struct GetInventoryRequest {
    condition: GetInventoryCondition,
    pagination_info: Option<PaginationConfig>,
}

#[derive(Debug, Serialize)]
pub(crate) struct GetInventoryCondition {
    pub(crate) owner: H160,
    pub(crate) project_ids: Option<Vec<ProjectId>>,
}

#[derive(Debug, Serialize)]
pub(crate) struct ProjectId {
    pub(crate) project_id: String,
}

impl GetInventoryRequest {
    pub(crate) fn new(
        owner: H160,
        project_id: Option<&str>,
        pagination_config: Option<PaginationConfig>,
    ) -> Self {
        if let Some(project_id) = project_id {
            Self {
                condition: GetInventoryCondition {
                    owner,
                    project_ids: Some(vec![ProjectId {
                        project_id: project_id.to_string(),
                    }]),
                },
                pagination_info: pagination_config,
            }
        } else {
            Self {
                condition: GetInventoryCondition {
                    owner,
                    project_ids: None,
                },
                pagination_info: pagination_config,
            }
        }
    }
}

#[derive(Debug, Deserialize)]
pub(crate) struct GetInventoryResponse {
    pub(crate) marketplace_snapshots: Vec<MarketplaceSnapshot>,
    pub(crate) pagination_info: PaginationInfo,
}