1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
use std::time::SystemTime;

/// This struct is the root of the standard userstyles API response.
///
/// The request url is `https://userstyles.org/api/v1/styles/{id}`.
pub struct Style {
    /// id of the style, this is part of the `userstyles.org` url
    pub id: i32,
    /// Name of the style
    pub name: String,
    /// Summary of what the style does
    pub description: String,
    /// User that created the style
    pub user: User,
    /// Last update time
    pub updated: SystemTime,
    /// Installs per this week
    pub weekly_install_count: i32,
    /// Total install count
    pub total_install_count: i32,
    /// Rating of this style from 1 to 3
    pub rating: Option<f32>,
    /// File name of the thumbnail
    pub after_screenshot_name: Option<String>,
    /// id for newer version of this style
    pub obsoleting_style_id: Option<i32>,
    /// Name of the replacing style
    pub obsoleting_style_name: Option<String>,
    /// Indicate that style has been discontinued
    pub obsolete: bool,
    /// Reason why style has been removed by an admin
    pub admin_delete_reason: Option<String>,
    /// Reason why style has been obsoleted
    pub obsoletion_message: Option<String>,
    /// Screenshot fil names for this style
    pub screenshots: Option<Vec<String>>,
    /// License the style is published under
    pub license: Option<String>,
    /// Creation time
    pub created: SystemTime,
    /// Category this style falls in
    pub category: String,
    /// Subcategory or domain name
    pub subcategory: Option<String>,
    // I don't know what this is used for
    pledgie_id: Option<i32>,
    /// Additional informations about this style
    pub additional_info: Option<String>,
    /// The style's css with the default settings
    pub css: String,
    /// Comments on this style
    pub discussions: Vec<Discussion>,
    /// JavaScipt file name for this style
    pub userjs_url: Option<String>,
    /// Available settings
    pub style_settings: Vec<StyleSetting>,
}

/// `userstyles.org` user.
pub struct User {
    /// id of the user
    pub id: i32,
    /// Username
    pub name: String,
    /// Email address
    pub email: Option<String>,
    /// Paypal email
    pub paypal_email: Option<String>,
    /// Homepage
    pub homepage: Option<String>,
    /// Bio about the user
    pub about: Option<String>,
    /// Default license
    pub license: String,
}

/// Single comment about a userstyle
pub struct Discussion {
    /// Comment id
    pub id: i32,
    /// Comment text
    pub name: String,
    /// Rating either 0, 1, 2 or 3.
    /// 0 means no rating was given.
    pub rating: i32,
    /// Creation date of this comment
    pub created: SystemTime,
    /// Username of the comment author
    pub author_name: String,
    /// User id of the comment author
    pub author_id: i32,
}

/// Available option for a userstyle
pub struct StyleSetting {
    /// id of this setting
    pub id: i32,
    /// id of style this setting belongs to
    pub style_id: i32,
    /// key for request body
    pub install_key: String,
    /// Human-readable name of this setting
    pub label: String,
    /// The type of this setting.
    /// This is eiter `color`, `image`, `text` or `dropdown`.
    pub setting_type: String,
    /// The available options and default
    pub style_setting_options: Vec<StyleSettingOption>,
}

/// Available options and default for a setting
pub struct StyleSettingOption {
    /// id of this option
    pub id: i32,
    /// id of the setting this option belongs to
    pub style_setting_id: i32,
    /// Human-readable name of this option
    pub label: String,
    /// Text that will be replace the template
    pub value: String,
    /// Indicate that this is the default option
    pub default: bool,
    /// Order id for arranging options
    pub ordinal: i32,
    /// value for request body
    pub install_key: String,
}