Compare commits
2 Commits
9863029eb9
...
34d0266c1f
| Author | SHA1 | Date | |
|---|---|---|---|
| 34d0266c1f | |||
| ac0f574d2b |
@@ -1,13 +1,11 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use strum::EnumString;
|
use strum::EnumString;
|
||||||
|
|
||||||
use crate::{
|
use crate::service::{service_domain::ServiceDomain, service_id::ServiceId, IntoServiceCall};
|
||||||
notify::service::mobile_app::SpecialMessage,
|
|
||||||
object_id::ObjectId,
|
|
||||||
service::{service_domain::ServiceDomain, service_id::ServiceId, IntoServiceCall},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::{NotifyMobileAppServiceData, NotifyMobileAppServiceDataData};
|
use super::super::{
|
||||||
|
MobileAppDeviceId, NotifyMobileAppServiceData, NotifyMobileAppServiceDataData, SpecialMessage,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, EnumString, strum::Display)]
|
#[derive(Debug, Clone, EnumString, strum::Display)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
#[strum(serialize_all = "snake_case")]
|
||||||
@@ -33,7 +31,7 @@ pub enum Filter {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, typed_builder::TypedBuilder)]
|
#[derive(Debug, Clone, typed_builder::TypedBuilder)]
|
||||||
pub struct DoNotDisturb {
|
pub struct DoNotDisturb {
|
||||||
pub object_id: ObjectId,
|
pub device_id: MobileAppDeviceId,
|
||||||
pub filter: Filter,
|
pub filter: Filter,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,11 +39,11 @@ impl IntoServiceCall for DoNotDisturb {
|
|||||||
type ServiceData = NotifyMobileAppServiceData;
|
type ServiceData = NotifyMobileAppServiceData;
|
||||||
|
|
||||||
fn into_service_call(self) -> (ServiceDomain, ServiceId, Self::ServiceData) {
|
fn into_service_call(self) -> (ServiceDomain, ServiceId, Self::ServiceData) {
|
||||||
let DoNotDisturb { object_id, filter } = self;
|
let DoNotDisturb { device_id, filter } = self;
|
||||||
|
|
||||||
let service_domain = ServiceDomain::from_str("notify").expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
let service_domain = ServiceDomain::from_str("notify").expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
||||||
|
|
||||||
let service_id = ServiceId::from_str(&format!("mobile_app_{object_id}")).expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
let service_id = ServiceId::from_str(&format!("mobile_app_{device_id}")).expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
||||||
|
|
||||||
let service_data = NotifyMobileAppServiceData::builder()
|
let service_data = NotifyMobileAppServiceData::builder()
|
||||||
.message(SpecialMessage::CommandDnd.to_string())
|
.message(SpecialMessage::CommandDnd.to_string())
|
||||||
|
|||||||
@@ -1,27 +1,23 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::service::{service_domain::ServiceDomain, service_id::ServiceId, IntoServiceCall};
|
||||||
notify::service::mobile_app::SpecialMessage,
|
|
||||||
object_id::ObjectId,
|
|
||||||
service::{service_domain::ServiceDomain, service_id::ServiceId, IntoServiceCall},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::NotifyMobileAppServiceData;
|
use super::super::{MobileAppDeviceId, NotifyMobileAppServiceData, SpecialMessage};
|
||||||
|
|
||||||
#[derive(Debug, Clone, typed_builder::TypedBuilder)]
|
#[derive(Debug, Clone, typed_builder::TypedBuilder)]
|
||||||
pub struct RequestLocationUpdate {
|
pub struct RequestLocationUpdate {
|
||||||
pub object_id: ObjectId,
|
pub device_id: MobileAppDeviceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoServiceCall for RequestLocationUpdate {
|
impl IntoServiceCall for RequestLocationUpdate {
|
||||||
type ServiceData = NotifyMobileAppServiceData;
|
type ServiceData = NotifyMobileAppServiceData;
|
||||||
|
|
||||||
fn into_service_call(self) -> (ServiceDomain, ServiceId, Self::ServiceData) {
|
fn into_service_call(self) -> (ServiceDomain, ServiceId, Self::ServiceData) {
|
||||||
let RequestLocationUpdate { object_id } = self;
|
let RequestLocationUpdate { device_id } = self;
|
||||||
|
|
||||||
let service_domain = ServiceDomain::from_str("notify").expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
let service_domain = ServiceDomain::from_str("notify").expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
||||||
|
|
||||||
let service_id = ServiceId::from_str(&format!("mobile_app_{object_id}")).expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
let service_id = ServiceId::from_str(&format!("mobile_app_{device_id}")).expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
||||||
|
|
||||||
let service_data = NotifyMobileAppServiceData::builder()
|
let service_data = NotifyMobileAppServiceData::builder()
|
||||||
.message(SpecialMessage::RequestLocationUpdate.to_string())
|
.message(SpecialMessage::RequestLocationUpdate.to_string())
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
use python_utils::{FromPyFromStr, ToStrToPy};
|
||||||
|
|
||||||
|
use crate::slug::Slug;
|
||||||
|
|
||||||
|
pub use crate::slug::SlugParsingError as ParseMobileAppDeviceIdError;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, derive_more::FromStr, derive_more::Display, FromPyFromStr, ToStrToPy)]
|
||||||
|
pub struct MobileAppDeviceId(pub Slug);
|
||||||
@@ -10,10 +10,12 @@ use strum::EnumString;
|
|||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
pub mod command;
|
pub mod command;
|
||||||
|
pub mod device_id;
|
||||||
pub mod standard;
|
pub mod standard;
|
||||||
pub mod text_to_speech;
|
pub mod text_to_speech;
|
||||||
|
|
||||||
pub use command::*;
|
pub use command::*;
|
||||||
|
pub use device_id::MobileAppDeviceId;
|
||||||
pub use standard::StandardNotification;
|
pub use standard::StandardNotification;
|
||||||
pub use text_to_speech::TextToSpeech;
|
pub use text_to_speech::TextToSpeech;
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,16 @@ use std::str::FromStr;
|
|||||||
|
|
||||||
use mitsein::vec1::Vec1;
|
use mitsein::vec1::Vec1;
|
||||||
|
|
||||||
use crate::{
|
use crate::service::{service_domain::ServiceDomain, service_id::ServiceId, IntoServiceCall};
|
||||||
object_id::ObjectId,
|
|
||||||
service::{service_domain::ServiceDomain, service_id::ServiceId, IntoServiceCall},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Action, NonSpecialMessage, NotifyMobileAppServiceData, NotifyMobileAppServiceDataData,
|
Action, MobileAppDeviceId, NonSpecialMessage, NotifyMobileAppServiceData,
|
||||||
Visibility,
|
NotifyMobileAppServiceDataData, Visibility,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, typed_builder::TypedBuilder)]
|
#[derive(Debug, Clone, typed_builder::TypedBuilder)]
|
||||||
pub struct StandardNotification {
|
pub struct StandardNotification {
|
||||||
pub object_id: ObjectId,
|
pub device_id: MobileAppDeviceId,
|
||||||
|
|
||||||
#[builder(default, setter(strip_option))]
|
#[builder(default, setter(strip_option))]
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
@@ -32,7 +29,7 @@ impl IntoServiceCall for StandardNotification {
|
|||||||
|
|
||||||
fn into_service_call(self) -> (ServiceDomain, ServiceId, Self::ServiceData) {
|
fn into_service_call(self) -> (ServiceDomain, ServiceId, Self::ServiceData) {
|
||||||
let StandardNotification {
|
let StandardNotification {
|
||||||
object_id,
|
device_id,
|
||||||
title,
|
title,
|
||||||
message,
|
message,
|
||||||
actions,
|
actions,
|
||||||
@@ -41,7 +38,7 @@ impl IntoServiceCall for StandardNotification {
|
|||||||
|
|
||||||
let service_domain = ServiceDomain::from_str("notify").expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
let service_domain = ServiceDomain::from_str("notify").expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
||||||
|
|
||||||
let service_id = ServiceId::from_str(&format!("mobile_app_{object_id}")).expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
let service_id = ServiceId::from_str(&format!("mobile_app_{device_id}")).expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
||||||
|
|
||||||
let service_data = NotifyMobileAppServiceData::builder()
|
let service_data = NotifyMobileAppServiceData::builder()
|
||||||
.title_option(title)
|
.title_option(title)
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::service::{service_domain::ServiceDomain, service_id::ServiceId, IntoServiceCall};
|
||||||
notify::service::mobile_app::SpecialMessage,
|
|
||||||
object_id::ObjectId,
|
|
||||||
service::{service_domain::ServiceDomain, service_id::ServiceId, IntoServiceCall},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{MediaStream, NotifyMobileAppServiceData, NotifyMobileAppServiceDataData};
|
use super::{
|
||||||
|
MediaStream, MobileAppDeviceId, NotifyMobileAppServiceData, NotifyMobileAppServiceDataData,
|
||||||
|
SpecialMessage,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, typed_builder::TypedBuilder)]
|
#[derive(Debug, Clone, typed_builder::TypedBuilder)]
|
||||||
pub struct TextToSpeech {
|
pub struct TextToSpeech {
|
||||||
pub object_id: ObjectId,
|
pub device_id: MobileAppDeviceId,
|
||||||
|
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub media_stream: Option<MediaStream>,
|
pub media_stream: Option<MediaStream>,
|
||||||
@@ -21,14 +20,14 @@ impl IntoServiceCall for TextToSpeech {
|
|||||||
|
|
||||||
fn into_service_call(self) -> (ServiceDomain, ServiceId, Self::ServiceData) {
|
fn into_service_call(self) -> (ServiceDomain, ServiceId, Self::ServiceData) {
|
||||||
let TextToSpeech {
|
let TextToSpeech {
|
||||||
object_id,
|
device_id,
|
||||||
message,
|
message,
|
||||||
media_stream,
|
media_stream,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
let service_domain = ServiceDomain::from_str("notify").expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
let service_domain = ServiceDomain::from_str("notify").expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
||||||
|
|
||||||
let service_id = ServiceId::from_str(&format!("mobile_app_{object_id}")).expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
let service_id = ServiceId::from_str(&format!("mobile_app_{device_id}")).expect("statically written and known to be a valid slug; hoping to get compiler checks instead in the future");
|
||||||
|
|
||||||
let service_data = NotifyMobileAppServiceData::builder()
|
let service_data = NotifyMobileAppServiceData::builder()
|
||||||
.message(SpecialMessage::Tts.to_string())
|
.message(SpecialMessage::Tts.to_string())
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
use std::convert::Infallible;
|
|
||||||
|
|
||||||
use pyo3::{prelude::*, types::PyString};
|
|
||||||
use python_utils::{FromPyFromStr, ToStrToPy};
|
use python_utils::{FromPyFromStr, ToStrToPy};
|
||||||
|
|
||||||
use super::slug::Slug;
|
use super::slug::Slug;
|
||||||
|
|||||||
Reference in New Issue
Block a user