diff --git a/ark-marketplace-api/src/api_doc.rs b/ark-marketplace-api/src/api_doc.rs index 0e68a134..afc56273 100644 --- a/ark-marketplace-api/src/api_doc.rs +++ b/ark-marketplace-api/src/api_doc.rs @@ -38,6 +38,7 @@ use utoipa_swagger_ui::{SwaggerUi, Url}; default_handler::last_sales, default_handler::live_auctions, default_handler::trending, + default_handler::event_filters, collection_handler::get_collection, collection_handler::get_collection_activity, collection_handler::get_portfolio_collections, diff --git a/ark-marketplace-api/src/handlers/default_handler.rs b/ark-marketplace-api/src/handlers/default_handler.rs index 73a6b161..567e5328 100644 --- a/ark-marketplace-api/src/handlers/default_handler.rs +++ b/ark-marketplace-api/src/handlers/default_handler.rs @@ -1,11 +1,11 @@ use crate::db::default_query::{get_last_sales, get_live_auctions, get_trending}; +use crate::models::token::get_event_types; use crate::types::default::{HealthCheckResponse, HealthCheckResponseV1}; use actix_web::{get, web}; use actix_web::{HttpResponse, Responder}; use serde_json::json; use sqlx::PgPool; use std::sync::Arc; - #[utoipa::path( tag = "HealthCheck", responses( @@ -61,6 +61,20 @@ pub async fn last_sales(db_pools: web::Data>) -> impl Responder } } +#[utoipa::path( + tag = "Collections", + responses( + (status = 200, description = "Get event filters", body = LastSalesResponse), + (status = 400, description = "Data not found", body = String), + ) +)] +#[get("/event-filters")] +pub async fn event_filters() -> impl Responder { + HttpResponse::Ok().json(json!({ + "data": get_event_types(), + })) +} + #[utoipa::path( tag = "Collections", responses( @@ -112,5 +126,6 @@ pub fn configure(cfg: &mut web::ServiceConfig) { .service(root) .service(last_sales) .service(live_auctions) - .service(trending); + .service(trending) + .service(event_filters); } diff --git a/ark-marketplace-api/src/models/token.rs b/ark-marketplace-api/src/models/token.rs index 6f48e0ac..f4e872cc 100644 --- a/ark-marketplace-api/src/models/token.rs +++ b/ark-marketplace-api/src/models/token.rs @@ -420,3 +420,23 @@ pub struct TokenPortfolioActivityData { pub metadata: Option, pub currency: Currency, } + +const EVENT_TYPES: [&str; 13] = [ + LISTING_STR, + COLLECTION_OFFER_STR, + OFFER_STR, + AUCTION_STR, + CANCELLED_STR, + SALE_STR, + MINT_STR, + TRANSFER_STR, + LISTING_CANCELLED_STR, + AUCTION_CANCELLED_STR, + OFFER_CANCELLED_STR, + LISTING_EXPIRED_STR, + OFFER_EXPIRED_STR, +]; + +pub fn get_event_types() -> &'static [&'static str; 13] { + &EVENT_TYPES +}