forem_openapi_client/models/
display_ad.rs

1/*
2 * Forem API V1
3 *
4 * Access Forem articles, users and other resources via API.         For a real-world example of Forem in action, check out [DEV](https://www.dev.to).         All endpoints can be accessed with the 'api-key' header and a accept header, but         some of them are accessible publicly without authentication.          Dates and date times, unless otherwise specified, must be in         the [RFC 3339](https://tools.ietf.org/html/rfc3339) format.
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// DisplayAd : A Display Ad, aka Billboard, aka Widget
12
13#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct DisplayAd {
15    /// The ID of the Display Ad
16    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
17    pub id: Option<i32>,
18    /// For internal use, helps distinguish ads from one another
19    #[serde(rename = "name")]
20    pub name: String,
21    /// The text (in markdown) of the ad (required)
22    #[serde(rename = "body_markdown")]
23    pub body_markdown: String,
24    /// Ad must be both published and approved to be in rotation
25    #[serde(rename = "approved", skip_serializing_if = "Option::is_none")]
26    pub approved: Option<bool>,
27    /// Ad must be both published and approved to be in rotation
28    #[serde(rename = "published", skip_serializing_if = "Option::is_none")]
29    pub published: Option<bool>,
30    /// Identifies the organization to which the ad belongs
31    #[serde(
32        rename = "organization_id",
33        default,
34        with = "::serde_with::rust::double_option",
35        skip_serializing_if = "Option::is_none"
36    )]
37    pub organization_id: Option<Option<i32>>,
38    /// Identifies the user who created the ad.
39    #[serde(
40        rename = "creator_id",
41        default,
42        with = "::serde_with::rust::double_option",
43        skip_serializing_if = "Option::is_none"
44    )]
45    pub creator_id: Option<Option<i32>>,
46    /// Identifies which area of site layout the ad can appear in
47    #[serde(rename = "placement_area")]
48    pub placement_area: PlacementArea,
49    /// Tags on which this ad can be displayed (blank is all/any tags)
50    #[serde(rename = "tag_list", skip_serializing_if = "Option::is_none")]
51    pub tag_list: Option<String>,
52    /// Articles this ad should *not* appear on (blank means no articles are disallowed, and this ad can appear next to any/all articles). Comma-separated list of integer Article IDs
53    #[serde(
54        rename = "article_exclude_ids",
55        default,
56        with = "::serde_with::rust::double_option",
57        skip_serializing_if = "Option::is_none"
58    )]
59    pub article_exclude_ids: Option<Option<String>>,
60    /// Potentially limits visitors to whom the ad is visible
61    #[serde(rename = "display_to", skip_serializing_if = "Option::is_none")]
62    pub display_to: Option<DisplayTo>,
63    /// Types of the billboards: in_house (created by admins), community (created by an entity, appears on entity's content), external ( created by an entity, or a non-entity, can appear everywhere)
64    #[serde(rename = "type_of", skip_serializing_if = "Option::is_none")]
65    pub type_of: Option<TypeOf>,
66}
67
68impl DisplayAd {
69    /// A Display Ad, aka Billboard, aka Widget
70    pub fn new(name: String, body_markdown: String, placement_area: PlacementArea) -> DisplayAd {
71        DisplayAd {
72            id: None,
73            name,
74            body_markdown,
75            approved: None,
76            published: None,
77            organization_id: None,
78            creator_id: None,
79            placement_area,
80            tag_list: None,
81            article_exclude_ids: None,
82            display_to: None,
83            type_of: None,
84        }
85    }
86}
87
88/// Identifies which area of site layout the ad can appear in
89#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
90pub enum PlacementArea {
91    #[serde(rename = "sidebar_left")]
92    SidebarLeft,
93    #[serde(rename = "sidebar_left_2")]
94    SidebarLeft2,
95    #[serde(rename = "sidebar_right")]
96    SidebarRight,
97    #[serde(rename = "post_sidebar")]
98    PostSidebar,
99    #[serde(rename = "post_comments")]
100    PostComments,
101}
102
103impl Default for PlacementArea {
104    fn default() -> PlacementArea {
105        Self::SidebarLeft
106    }
107}
108/// Potentially limits visitors to whom the ad is visible
109#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
110pub enum DisplayTo {
111    #[serde(rename = "all")]
112    All,
113    #[serde(rename = "logged_in")]
114    LoggedIn,
115    #[serde(rename = "logged_out")]
116    LoggedOut,
117}
118
119impl Default for DisplayTo {
120    fn default() -> DisplayTo {
121        Self::All
122    }
123}
124/// Types of the billboards: in_house (created by admins), community (created by an entity, appears on entity's content), external ( created by an entity, or a non-entity, can appear everywhere)
125#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
126pub enum TypeOf {
127    #[serde(rename = "in_house")]
128    InHouse,
129    #[serde(rename = "community")]
130    Community,
131    #[serde(rename = "external")]
132    External,
133}
134
135impl Default for TypeOf {
136    fn default() -> TypeOf {
137        Self::InHouse
138    }
139}