Crates.io | vizio-openrtb |
lib.rs | vizio-openrtb |
version | 0.2.3 |
source | src |
created_at | 2023-03-02 21:09:00.261452 |
updated_at | 2023-03-21 17:32:20.439725 |
description | OpenRTB v2.5 and OpenRTB Dynamic Native Ads v1.2 types for rust forked for Vizio |
homepage | https://github.com/vizio-ad-tech/openrtb-rust |
repository | https://github.com/vizio-ad-tech/openrtb-rust |
max_upload_size | |
id | 799196 |
size | 187,764 |
OpenRTB v2.5 and OpenRTB Dynamic Native Ads v1.2 types for rust. Handles (de)serialization to/from JSON.
extern crate openrtb;
extern crate reqwest;
use std::error::Error;
use openrtb::current::{BidRequest, BidResponse};
use reqwest::StatusCode;
fn main() -> Result<(), Box<Error>> {
let id = "f9b54eb8-6f3b-11e8-adc0-fa7ae01bbebc".to_string();
let req = BidRequest::new(id);
let client = reqwest::Client::new();
let mut res = client
.post("https://prebid.adnxs.com/pbs/v1/openrtb2/auction")
.json(&req)
.send()?;
match res.status() {
StatusCode::OK => {
let res: BidResponse = res.json()?;
println!("Received bids for req {}.", res.id);
}
StatusCode::NO_CONTENT => {
println!("No bids.");
}
_ => {
println!("Error: {:?}", res);
}
}
Ok(())
}