Add methods & data structures for all the "push" endpoints

Closes #53
This commit is contained in:
Paul Woolcock
2018-09-10 08:08:46 -04:00
parent 28192e1188
commit 690b029d99
7 changed files with 770 additions and 17 deletions
+3
View File
@@ -15,6 +15,8 @@ pub mod list;
pub mod mention;
/// Data structures for ser/de of notification-related resources
pub mod notification;
/// Data structures for ser/de of push-subscription-related resources
pub mod push;
/// Data structures for ser/de of relationship-related resources
pub mod relationship;
/// Data structures for ser/de of report-related resources
@@ -41,6 +43,7 @@ pub mod prelude {
list::List,
mention::Mention,
notification::Notification,
push::Subscription,
relationship::Relationship,
report::Report,
search_result::{SearchResult, SearchResultV2},
+67
View File
@@ -0,0 +1,67 @@
/// Represents the `alerts` key of the `Subscription` object
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Default)]
pub struct Alerts {
/// flag for follow alerts
pub follow: Option<bool>,
/// flag for favourite alerts
pub favourite: Option<bool>,
/// flag for reblog alerts
pub reblog: Option<bool>,
/// flag for mention alerts
pub mention: Option<bool>,
}
/// Represents a new Push subscription
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct Subscription {
/// The `id` of the subscription
pub id: String,
/// The endpoint of the subscription
pub endpoint: String,
/// The server key of the subscription
pub server_key: String,
/// The status of the alerts for this subscription
pub alerts: Option<Alerts>,
}
pub(crate) mod add_subscription {
use super::Alerts;
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
pub(crate) struct Form {
pub(crate) subscription: Subscription,
pub(crate) data: Option<Data>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
pub(crate) struct Subscription {
pub(crate) endpoint: String,
pub(crate) keys: Keys,
}
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
pub(crate) struct Keys {
pub(crate) p256dh: String,
pub(crate) auth: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
pub(crate) struct Data {
pub(crate) alerts: Option<Alerts>,
}
}
pub(crate) mod update_data {
use super::Alerts;
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
pub(crate) struct Data {
pub(crate) alerts: Option<Alerts>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
pub(crate) struct Form {
pub(crate) id: String,
pub(crate) data: Data,
}
}