Skip to content

Commit

Permalink
Cleanup ess xvp (#483)
Browse files Browse the repository at this point in the history
* fix: cleanup privacy & usergrants

* fix: cleanup discovery

* fix: uncomment and update AccountLinkService

* fix: cleanup

* fix: remove all derive macros for AppSetting

* build: fmt
  • Loading branch information
SKumarMetro committed Apr 12, 2024
1 parent 5217a1e commit 675b205
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 27 deletions.
18 changes: 17 additions & 1 deletion core/sdk/src/api/distributor/distributor_privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::str::FromStr;

use serde::{Deserialize, Serialize};

use crate::api::usergrant_entry::UserGrantInfo;
use crate::{
api::{
session::AccountSession,
Expand Down Expand Up @@ -165,7 +166,6 @@ impl ExtnPayloadProvider for PrivacySettingsData {
{
return Some(settings);
}

None
}

Expand Down Expand Up @@ -300,6 +300,22 @@ impl FromStr for DataEventType {
}
}

pub struct AppSetting {
pub app_id: Option<String>,
pub value: Option<bool>,
}

pub type UserGrants = Vec<UserGrantInfo>;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum PrivacyResponse {
None,
Bool(bool),
Settings(PrivacySettings),
Exclusions(ExclusionPolicy),
Grants(UserGrants),
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 2 additions & 0 deletions core/sdk/src/api/distributor/distributor_usergrants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ impl ExtnPayloadProvider for UserGrantsCloudStoreRequest {
}
}

pub type UserGrants = Vec<UserGrantInfo>;

#[cfg(test)]
mod tests {
use super::*;
Expand Down
64 changes: 38 additions & 26 deletions core/sdk/src/api/firebolt/fb_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ use std::collections::{HashMap, HashSet};

use serde::{Deserialize, Serialize};

use crate::utils::error::RippleError;
use crate::{
api::{
device::entertainment_data::{ContentIdentifiers, NavigationIntent},
session::AccountSession,
},
utils::serde_utils::{optional_date_time_str_serde, progress_value_deserialize},
};
use async_trait::async_trait;

pub const DISCOVERY_EVENT_ON_NAVIGATE_TO: &str = "discovery.onNavigateTo";

Expand Down Expand Up @@ -227,6 +229,12 @@ impl From<SignInInfo> for ContentAccessRequest {
}
}

#[derive(Debug, Clone)]
pub enum DiscoveryRequest {
SetContentAccess(ContentAccessListSetParams),
ClearContent(ClearContentSetParams),
}

#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ContentAccessEntitlement {
Expand Down Expand Up @@ -283,13 +291,13 @@ pub struct SignInRequestParams {
pub is_signed_in: bool, /*true for signIn, false for signOut */
}

// #[derive(Debug, Clone)]
// pub enum DiscoveryAccountLinkRequest {
// EntitlementsAccountLink(EntitlementsAccountLinkRequestParams),
// MediaEventAccountLink(MediaEventsAccountLinkRequestParams),
// LaunchPadAccountLink(LaunchPadAccountLinkRequestParams),
// SignIn(SignInRequestParams),
// }
#[derive(Debug, Clone)]
pub enum DiscoveryAccountLinkRequest {
EntitlementsAccountLink(EntitlementsAccountLinkRequestParams),
MediaEventAccountLink(MediaEventsAccountLinkRequestParams),
LaunchPadAccountLink(LaunchPadAccountLinkRequestParams),
SignIn(SignInRequestParams),
}

pub const PROGRESS_UNIT_SECONDS: &str = "Seconds";
pub const PROGRESS_UNIT_PERCENT: &str = "Percent";
Expand Down Expand Up @@ -371,28 +379,32 @@ pub struct MediaEventsAccountLinkRequestParams {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MediaEventsAccountLinkResponse {}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LaunchPadAccountLinkRequestParams {
pub link_launchpad: AccountLaunchpad,
pub content_partner_id: String,
pub dist_session: AccountSession,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LaunchPadAccountLinkResponse {}

// #[async_trait]
// pub trait AccountLinkService {
// async fn entitlements_account_link(
// self: Box<Self>,
// request: DpabRequest,
// params: EntitlementsAccountLinkRequestParams,
// );
// async fn media_events_account_link(
// self: Box<Self>,
// request: DpabRequest,
// params: MediaEventsAccountLinkRequestParams,
// );
// async fn launch_pad_account_link(
// self: Box<Self>,
// request: DpabRequest,
// params: LaunchPadAccountLinkRequestParams,
// );
// async fn sign_in(self: Box<Self>, request: DpabRequest, params: SignInRequestParams);
// }
#[async_trait]
pub trait AccountLinkService {
async fn entitlements_account_link(
self: Box<Self>,
params: EntitlementsAccountLinkRequestParams,
) -> Result<EntitlementsAccountLinkResponse, RippleError>;
async fn media_events_account_link(
self: Box<Self>,
params: MediaEventsAccountLinkRequestParams,
) -> Result<MediaEventsAccountLinkResponse, RippleError>;
async fn launch_pad_account_link(
self: Box<Self>,
params: LaunchPadAccountLinkRequestParams,
) -> Result<LaunchPadAccountLinkResponse, RippleError>;
async fn sign_in(self: Box<Self>, params: SignInRequestParams) -> Result<(), RippleError>;
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 2 additions & 0 deletions core/sdk/src/utils/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub enum RippleError {
NoResponse,
InvalidAccess,
Permission(DenyReason),
ServiceError,
NotAvailable,
}
impl std::fmt::Display for RippleError {
Expand All @@ -54,6 +55,7 @@ impl std::fmt::Display for RippleError {
RippleError::NoResponse => write!(f, "NoResponse"),
RippleError::InvalidAccess => write!(f, "InvalidAccess"),
RippleError::Permission(p) => write!(f, "Permission {}", p),
RippleError::ServiceError => write!(f, "ServiceError"),
RippleError::NotAvailable => write!(f, "NotAvailable"),
}
}
Expand Down

0 comments on commit 675b205

Please sign in to comment.