Skip to content
Open
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
1 change: 1 addition & 0 deletions ark-marketplace-api/src/api_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 17 additions & 2 deletions ark-marketplace-api/src/handlers/default_handler.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -61,6 +61,20 @@ pub async fn last_sales(db_pools: web::Data<Arc<[PgPool; 2]>>) -> impl Responder
}
}

#[utoipa::path(
tag = "Collections",
responses(
(status = 200, description = "Get event filters", body = LastSalesResponse),
(status = 400, description = "Data not found", body = String),
)
)]
Comment on lines +64 to +70
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attention mauvais copier/coller ici pour la desc et le tag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'autre part les diffΓ©rentes valeurs de retour n'apparaissent pas sur le swagger

#[get("/event-filters")]
pub async fn event_filters() -> impl Responder {
HttpResponse::Ok().json(json!({
"data": get_event_types(),
}))
}

#[utoipa::path(
tag = "Collections",
responses(
Expand Down Expand Up @@ -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);
}
20 changes: 20 additions & 0 deletions ark-marketplace-api/src/models/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,23 @@ pub struct TokenPortfolioActivityData {
pub metadata: Option<JsonValue>,
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
}