pub const REPORTED_PARSE_SERVER_VERSION: &str = "9.10.1-alpha.6";
#[derive(Debug, Clone, Default)]
pub struct FeatureSupport {
pub global_config: bool,
pub hooks: bool,
pub cloud_code_jobs: bool,
pub logs: bool,
pub schemas: bool,
pub push_audiences: bool,
}
#[derive(Debug, Clone)]
pub struct ServerConfig {
pub app_id: String,
pub master_key: String,
pub maintenance_key: Option<String>,
pub javascript_key: Option<String>,
pub rest_api_key: Option<String>,
pub client_key: Option<String>,
pub dot_net_key: Option<String>,
pub mount_path: String,
pub enable_sanitized_error_response: bool,
pub has_push_support: bool,
pub has_push_scheduled_support: bool,
pub security_check_enabled: bool,
pub features: FeatureSupport,
}
impl ServerConfig {
pub fn new(app_id: impl Into<String>, master_key: impl Into<String>) -> Self {
Self {
app_id: app_id.into(),
master_key: master_key.into(),
maintenance_key: None,
javascript_key: None,
rest_api_key: None,
client_key: None,
dot_net_key: None,
mount_path: "/parse".to_string(),
enable_sanitized_error_response: true,
has_push_support: false,
has_push_scheduled_support: false,
security_check_enabled: false,
features: FeatureSupport::default(),
}
}
pub fn javascript_key(mut self, k: impl Into<String>) -> Self {
self.javascript_key = Some(k.into());
self
}
pub fn rest_api_key(mut self, k: impl Into<String>) -> Self {
self.rest_api_key = Some(k.into());
self
}
pub fn mount_path(mut self, p: impl Into<String>) -> Self {
self.mount_path = p.into();
self
}
pub fn requires_client_key(&self) -> bool {
self.javascript_key.is_some()
|| self.rest_api_key.is_some()
|| self.client_key.is_some()
|| self.dot_net_key.is_some()
}
}