Skip to content
Draft
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
19 changes: 19 additions & 0 deletions crates/common/src/auction/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ pub struct AdRequest {
pub struct AdUnit {
pub code: String,
pub media_types: Option<MediaTypes>,
pub bids: Option<Vec<BidConfig>>,
}

/// Bidder configuration from the request.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BidConfig {
pub bidder: String,
#[serde(default)]
pub params: serde_json::Value,
}

#[derive(Debug, Deserialize)]
Expand Down Expand Up @@ -91,11 +101,20 @@ pub fn convert_tsjs_to_auction_request(
});
}

// Extract bidder params from the bids array
let mut bidders = std::collections::HashMap::new();
if let Some(bids) = &unit.bids {
for bid in bids {
bidders.insert(bid.bidder.clone(), bid.params.clone());
}
}

slots.push(AdSlot {
id: unit.code.clone(),
formats,
floor_price: None,
targeting: std::collections::HashMap::new(),
bidders,
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/common/src/auction/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ pub struct AdSlot {
pub floor_price: Option<f64>,
/// Slot-specific targeting
pub targeting: HashMap<String, serde_json::Value>,
/// Bidder configurations (bidder name -> params)
pub bidders: HashMap<String, serde_json::Value>,
}

/// Ad format specification.
Expand Down
Loading