Skip to content

Commit fc3c1ac

Browse files
committed
primitives - campaign_list_response example
Add to sentry routes docs Add to CampaignListReponse
1 parent eec0500 commit fc3c1ac

File tree

4 files changed

+238
-2
lines changed

4 files changed

+238
-2
lines changed

primitives/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ required-features = ["test-util"]
2424
name = "campaign_list_query"
2525
required-features = ["test-util"]
2626

27+
[[example]]
28+
name = "campaign_list_response"
29+
required-features = ["test-util"]
30+
2731
[dependencies]
2832
# (De)Serialization
2933
serde = { version = "^1.0", features = ['derive'] }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
use primitives::sentry::campaign_list::CampaignListResponse;
2+
use serde_json::{json, from_value};
3+
4+
fn main() {
5+
let json = json!({
6+
"campaigns": [
7+
{
8+
"id": "0x936da01f9abd4d9d80c702af85c822a8",
9+
"channel": {
10+
"leader": "0x80690751969B234697e9059e04ed72195c3507fa",
11+
"follower": "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
12+
"guardian": "0xe061E1EB461EaBE512759aa18A201B20Fe90631D",
13+
"token": "0x2BCaf6968aEC8A3b5126FBfAb5Fd419da6E8AD8E",
14+
"nonce": "0"
15+
},
16+
"creator": "0xDd589B43793934EF6Ad266067A0d1D4896b0dff0",
17+
"budget": "15000000000",
18+
"validators": [
19+
{
20+
"id": "0x80690751969B234697e9059e04ed72195c3507fa",
21+
"fee": "500000000",
22+
"url": "http://localhost:8005/"
23+
},
24+
{
25+
"id": "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
26+
"fee": "400000000",
27+
"url": "http://localhost:8006/"
28+
}
29+
],
30+
"title": "Dummy Campaign",
31+
"pricingBounds": {
32+
"CLICK": {
33+
"min": "6000000",
34+
"max": "10000000"
35+
},
36+
"IMPRESSION": {
37+
"min": "4000000",
38+
"max": "5000000"
39+
}
40+
},
41+
"eventSubmission": {
42+
"allow": []
43+
},
44+
"adUnits": [
45+
{
46+
"ipfs": "Qmasg8FrbuSQpjFu3kRnZF9beg8rEBFrqgi1uXDRwCbX5f",
47+
"type": "legacy_250x250",
48+
"mediaUrl": "ipfs://QmcUVX7fvoLMM93uN2bD3wGTH8MXSxeL8hojYfL2Lhp7mR",
49+
"mediaMime": "image/jpeg",
50+
"targetUrl": "https://www.adex.network/?stremio-test-banner-1",
51+
"owner": "0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9",
52+
"created": 1564390800000_u64,
53+
"title": "Dummy AdUnit 1",
54+
"description": "Dummy AdUnit description 1",
55+
"archived": false
56+
},
57+
{
58+
"ipfs": "QmVhRDGXoM3Fg3HZD5xwMuxtb9ZErwC8wHt8CjsfxaiUbZ",
59+
"type": "legacy_250x250",
60+
"mediaUrl": "ipfs://QmQB7uz7Gxfy7wqAnrnBcZFaVJLos8J9gn8mRcHQU6dAi1",
61+
"mediaMime": "image/jpeg",
62+
"targetUrl": "https://www.adex.network/?adex-campaign=true&pub=stremio",
63+
"owner": "0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9",
64+
"created": 1564390800000_u64,
65+
"title": "Dummy AdUnit 2",
66+
"description": "Dummy AdUnit description 2",
67+
"archived": false
68+
}
69+
],
70+
"targetingRules": [],
71+
"created": 1612162800000_u64,
72+
"active_to": 4073414400000_u64
73+
},
74+
{
75+
"id": "0x127b98248f4e4b73af409d10f62daeaa",
76+
"channel": {
77+
"leader": "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
78+
"follower": "0x80690751969B234697e9059e04ed72195c3507fa",
79+
"guardian": "0x79D358a3194d737880B3eFD94ADccD246af9F535",
80+
"token": "0x2BCaf6968aEC8A3b5126FBfAb5Fd419da6E8AD8E",
81+
"nonce": "0"
82+
},
83+
"creator": "0xDd589B43793934EF6Ad266067A0d1D4896b0dff0",
84+
"budget": "2000000000",
85+
"validators": [
86+
{
87+
"id": "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
88+
"fee": "10000000",
89+
"url": "http://localhost:8006/"
90+
},
91+
{
92+
"id": "0x80690751969B234697e9059e04ed72195c3507fa",
93+
"fee": "5000000",
94+
"url": "http://localhost:8005/"
95+
}
96+
],
97+
"title": "Dummy Campaign 2 in Chain #1337",
98+
"pricingBounds": {
99+
"CLICK": {
100+
"min": "300000000",
101+
"max": "500000000"
102+
},
103+
"IMPRESSION": {
104+
"min": "100000000",
105+
"max": "200000000"
106+
}
107+
},
108+
"eventSubmission": {
109+
"allow": []
110+
},
111+
"adUnits": [
112+
{
113+
"ipfs": "Qmasg8FrbuSQpjFu3kRnZF9beg8rEBFrqgi1uXDRwCbX5f",
114+
"type": "legacy_250x250",
115+
"mediaUrl": "ipfs://QmcUVX7fvoLMM93uN2bD3wGTH8MXSxeL8hojYfL2Lhp7mR",
116+
"mediaMime": "image/jpeg",
117+
"targetUrl": "https://www.adex.network/?stremio-test-banner-1",
118+
"owner": "0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9",
119+
"created": 1564390800000_u64,
120+
"title": "Dummy AdUnit 1",
121+
"description": "Dummy AdUnit description 1",
122+
"archived": false
123+
},
124+
{
125+
"ipfs": "QmVhRDGXoM3Fg3HZD5xwMuxtb9ZErwC8wHt8CjsfxaiUbZ",
126+
"type": "legacy_250x250",
127+
"mediaUrl": "ipfs://QmQB7uz7Gxfy7wqAnrnBcZFaVJLos8J9gn8mRcHQU6dAi1",
128+
"mediaMime": "image/jpeg",
129+
"targetUrl": "https://www.adex.network/?adex-campaign=true&pub=stremio",
130+
"owner": "0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9",
131+
"created": 1564390800000_u64,
132+
"title": "Dummy AdUnit 2",
133+
"description": "Dummy AdUnit description 2",
134+
"archived": false
135+
}
136+
],
137+
"targetingRules": [],
138+
"created": 1612162800000_u64,
139+
"active_to": 4073414400000_u64
140+
},
141+
{
142+
"id": "0xa78f3492481b41a688488a7aa1ff17df",
143+
"channel": {
144+
"leader": "0x80690751969B234697e9059e04ed72195c3507fa",
145+
"follower": "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
146+
"guardian": "0x79D358a3194d737880B3eFD94ADccD246af9F535",
147+
"token": "0x12a28f2bfBFfDf5842657235cC058242f40fDEa6",
148+
"nonce": "1"
149+
},
150+
"creator": "0x541b401362Ea1D489D322579552B099e801F3632",
151+
"budget": "2000000000",
152+
"validators": [
153+
{
154+
"id": "0x80690751969B234697e9059e04ed72195c3507fa",
155+
"fee": "200000000",
156+
"url": "http://localhost:8005/"
157+
},
158+
{
159+
"id": "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
160+
"fee": "175000000",
161+
"url": "http://localhost:8006/"
162+
}
163+
],
164+
"title": "Dummy Campaign 3 in Chain #1",
165+
"pricingBounds": {
166+
"CLICK": {
167+
"min": "3500000",
168+
"max": "6500000"
169+
},
170+
"IMPRESSION": {
171+
"min": "1500000",
172+
"max": "2500000"
173+
}
174+
},
175+
"eventSubmission": {
176+
"allow": []
177+
},
178+
"adUnits": [
179+
{
180+
"ipfs": "QmYwcpMjmqJfo9ot1jGe9rfXsszFV1WbEA59QS7dEVHfJi",
181+
"type": "legacy_250x250",
182+
"mediaUrl": "ipfs://QmQB7uz7Gxfy7wqAnrnBcZFaVJLos8J9gn8mRcHQU6dAi1",
183+
"mediaMime": "image/jpeg",
184+
"targetUrl": "https://www.adex.network/?adex-campaign=true",
185+
"owner": "0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9",
186+
"created": 1564390800000_u64,
187+
"title": "Dummy AdUnit 3",
188+
"description": "Dummy AdUnit description 3",
189+
"archived": false
190+
},
191+
{
192+
"ipfs": "QmTAF3FsFDS7Ru8WChoD9ofiHTH8gAQfR4mYSnwxqTDpJH",
193+
"type": "legacy_250x250",
194+
"mediaUrl": "ipfs://QmQAcfBJpDDuH99A4p3pFtUmQwamS8UYStP5HxHC7bgYXY",
195+
"mediaMime": "image/jpeg",
196+
"targetUrl": "https://adex.network",
197+
"owner": "0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9",
198+
"created": 1564390800000_u64,
199+
"title": "Dummy AdUnit 4",
200+
"description": "Dummy AdUnit description 4",
201+
"archived": false
202+
}
203+
],
204+
"targetingRules": [],
205+
"created": 1612162800000_u64,
206+
"active_to": 4073414400000_u64
207+
}
208+
],
209+
"totalPages": 1,
210+
"page": 0
211+
});
212+
213+
assert!(from_value::<CampaignListResponse>(json).is_ok());
214+
}

primitives/src/sentry.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,13 @@ pub mod campaign_list {
680680

681681
use super::Pagination;
682682

683+
/// `GET /v5/campaign/list` response
684+
///
685+
/// # Examples
686+
///
687+
/// ```
688+
#[doc = include_str!("../examples/campaign_list_response.rs")]
689+
/// ```
683690
#[derive(Debug, Serialize, Deserialize)]
684691
#[serde(rename_all = "camelCase")]
685692
pub struct CampaignListResponse {
@@ -697,19 +704,24 @@ pub mod campaign_list {
697704
/// ```
698705
#[derive(Debug, Serialize, Deserialize, PartialEq)]
699706
pub struct CampaignListQuery {
700-
/// default is `u64::default()` = `0`
707+
/// Default is `u64::default()` = `0`.
701708
#[serde(default)]
702709
pub page: u64,
703-
/// filters the list on `active.to >= active_to_ge`
710+
/// Filters the list on `Campaign.active.to >= active_to_ge`.
711+
///
704712
/// It should be the same timestamp format as the `Campaign.active.to`: **seconds**
713+
///
714+
/// **Note:** This field is deserialized from `activeTo`.
705715
#[serde(with = "ts_seconds", default = "Utc::now", rename = "activeTo")]
706716
pub active_to_ge: DateTime<Utc>,
717+
/// Returns only the [`Campaign`]s containing a specified creator if provided.
707718
pub creator: Option<Address>,
708719
/// Returns only the [`Campaign`]s containing a specified validator if provided.
709720
#[serde(flatten)]
710721
pub validator: Option<ValidatorParam>,
711722
}
712723

724+
/// The `validator` query parameter for [`CampaignListQuery`].
713725
#[derive(Serialize, Deserialize, Debug, PartialEq)]
714726
#[serde(rename_all = "camelCase")]
715727
pub enum ValidatorParam {

sentry/src/routes.rs

+6
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@
204204
//! ```
205205
#![doc = include_str!("../../primitives/examples/campaign_list_query.rs")]
206206
//! ```
207+
//!
208+
//! Response:
209+
//!
210+
//! ```
211+
#![doc = include_str!("../../primitives/examples/campaign_list_response.rs")]
212+
//! ```
207213
//!
208214
//! #### POST `/v5/campaign` (auth required)
209215
//!

0 commit comments

Comments
 (0)