803 lines
29 KiB
Rust
803 lines
29 KiB
Rust
use super::*;
|
|
|
|
impl SpacetimeClient {
|
|
pub async fn get_runtime_settings(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<RuntimeSettingsRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_setting_get_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().get_runtime_setting_or_default_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_setting_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn list_platform_browse_history(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_browse_history_list_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().list_platform_browse_history_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_browse_history_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_profile_dashboard(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_dashboard_get_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().get_profile_dashboard_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_dashboard_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn list_profile_wallet_ledger(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<Vec<RuntimeProfileWalletLedgerEntryRecord>, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_wallet_ledger_list_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().list_profile_wallet_ledger_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_wallet_ledger_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn grant_new_user_registration_wallet_reward(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_dashboard_get_input(user_id)
|
|
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.grant_new_user_registration_wallet_reward_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_runtime_profile_wallet_adjustment_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn consume_profile_wallet_points(
|
|
&self,
|
|
user_id: String,
|
|
amount: u64,
|
|
ledger_id: String,
|
|
created_at_micros: i64,
|
|
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_wallet_adjustment_input(
|
|
user_id,
|
|
amount,
|
|
ledger_id,
|
|
created_at_micros,
|
|
)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.consume_profile_wallet_points_and_return_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_wallet_adjustment_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn refund_profile_wallet_points(
|
|
&self,
|
|
user_id: String,
|
|
amount: u64,
|
|
ledger_id: String,
|
|
created_at_micros: i64,
|
|
) -> Result<RuntimeProfileDashboardRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_wallet_adjustment_input(
|
|
user_id,
|
|
amount,
|
|
ledger_id,
|
|
created_at_micros,
|
|
)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.refund_profile_wallet_points_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_wallet_adjustment_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_profile_recharge_center(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<RuntimeProfileRechargeCenterRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_recharge_center_get_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().get_profile_recharge_center_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_recharge_center_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn create_profile_recharge_order(
|
|
&self,
|
|
user_id: String,
|
|
product_id: String,
|
|
payment_channel: String,
|
|
created_at_micros: i64,
|
|
) -> Result<
|
|
(
|
|
RuntimeProfileRechargeCenterRecord,
|
|
RuntimeProfileRechargeOrderRecord,
|
|
),
|
|
SpacetimeClientError,
|
|
> {
|
|
let procedure_input = build_runtime_profile_recharge_order_create_input(
|
|
user_id,
|
|
product_id,
|
|
payment_channel,
|
|
created_at_micros,
|
|
)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.create_profile_recharge_order_and_return_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_recharge_order_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_profile_referral_invite_center(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<RuntimeReferralInviteCenterRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_referral_invite_center_get_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_profile_referral_invite_center_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_referral_invite_center_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn redeem_profile_referral_invite_code(
|
|
&self,
|
|
user_id: String,
|
|
invite_code: String,
|
|
updated_at_micros: i64,
|
|
) -> Result<RuntimeReferralRedeemRecord, SpacetimeClientError> {
|
|
let procedure_input =
|
|
build_runtime_referral_redeem_input(user_id, invite_code, updated_at_micros)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.redeem_profile_referral_invite_code_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_referral_redeem_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn redeem_profile_reward_code(
|
|
&self,
|
|
user_id: String,
|
|
code: String,
|
|
redeemed_at_micros: i64,
|
|
) -> Result<RuntimeProfileRewardCodeRedeemRecord, SpacetimeClientError> {
|
|
let procedure_input =
|
|
build_runtime_profile_reward_code_redeem_input(user_id, code, redeemed_at_micros)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().redeem_profile_reward_code_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_reward_code_redeem_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_profile_task_center(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<RuntimeProfileTaskCenterRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_task_center_get_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().get_profile_task_center_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_task_center_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn claim_profile_task_reward(
|
|
&self,
|
|
user_id: String,
|
|
task_id: String,
|
|
) -> Result<RuntimeProfileTaskClaimRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_task_claim_input(user_id, task_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.claim_profile_task_reward_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_task_claim_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn admin_list_profile_task_configs(
|
|
&self,
|
|
admin_user_id: String,
|
|
) -> Result<Vec<RuntimeProfileTaskConfigRecord>, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_task_config_admin_list_input(admin_user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.admin_list_profile_task_configs_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_task_config_admin_list_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn admin_upsert_profile_task_config(
|
|
&self,
|
|
admin_user_id: String,
|
|
task_id: String,
|
|
title: String,
|
|
description: String,
|
|
event_key: String,
|
|
cycle: DomainRuntimeProfileTaskCycle,
|
|
scope_kind: DomainRuntimeTrackingScopeKind,
|
|
threshold: u32,
|
|
reward_points: u64,
|
|
enabled: bool,
|
|
sort_order: i32,
|
|
updated_at_micros: i64,
|
|
) -> Result<RuntimeProfileTaskConfigRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_task_config_admin_upsert_input(
|
|
admin_user_id,
|
|
task_id,
|
|
title,
|
|
description,
|
|
event_key,
|
|
cycle,
|
|
scope_kind,
|
|
threshold,
|
|
reward_points,
|
|
enabled,
|
|
sort_order,
|
|
updated_at_micros,
|
|
)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.admin_upsert_profile_task_config_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_task_config_admin_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn admin_disable_profile_task_config(
|
|
&self,
|
|
admin_user_id: String,
|
|
task_id: String,
|
|
updated_at_micros: i64,
|
|
) -> Result<RuntimeProfileTaskConfigRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_task_config_admin_disable_input(
|
|
admin_user_id,
|
|
task_id,
|
|
updated_at_micros,
|
|
)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.admin_disable_profile_task_config_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_task_config_admin_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn admin_upsert_profile_redeem_code(
|
|
&self,
|
|
admin_user_id: String,
|
|
code: String,
|
|
mode: DomainRuntimeProfileRedeemCodeMode,
|
|
reward_points: u64,
|
|
max_uses: u32,
|
|
enabled: bool,
|
|
allowed_user_ids: Vec<String>,
|
|
allowed_public_user_codes: Vec<String>,
|
|
updated_at_micros: i64,
|
|
) -> Result<RuntimeProfileRedeemCodeRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_redeem_code_admin_upsert_input(
|
|
admin_user_id,
|
|
code,
|
|
mode,
|
|
reward_points,
|
|
max_uses,
|
|
enabled,
|
|
allowed_user_ids,
|
|
allowed_public_user_codes,
|
|
updated_at_micros,
|
|
)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.admin_upsert_profile_redeem_code_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_redeem_code_admin_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn admin_list_profile_redeem_codes(
|
|
&self,
|
|
admin_user_id: String,
|
|
) -> Result<Vec<RuntimeProfileRedeemCodeRecord>, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_redeem_code_admin_list_input(admin_user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.admin_list_profile_redeem_codes_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_redeem_code_admin_list_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn admin_disable_profile_redeem_code(
|
|
&self,
|
|
admin_user_id: String,
|
|
code: String,
|
|
updated_at_micros: i64,
|
|
) -> Result<RuntimeProfileRedeemCodeRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_redeem_code_admin_disable_input(
|
|
admin_user_id,
|
|
code,
|
|
updated_at_micros,
|
|
)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.admin_disable_profile_redeem_code_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_redeem_code_admin_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn admin_upsert_profile_invite_code(
|
|
&self,
|
|
admin_user_id: String,
|
|
invite_code: String,
|
|
metadata_json: String,
|
|
updated_at_micros: i64,
|
|
) -> Result<RuntimeProfileInviteCodeRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_invite_code_admin_upsert_input(
|
|
admin_user_id,
|
|
invite_code,
|
|
metadata_json,
|
|
updated_at_micros,
|
|
)
|
|
.map_err(|error| SpacetimeClientError::Runtime(error.to_string()))?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.admin_upsert_profile_invite_code_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_runtime_profile_invite_code_admin_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn admin_list_profile_invite_codes(
|
|
&self,
|
|
admin_user_id: String,
|
|
) -> Result<Vec<RuntimeProfileInviteCodeRecord>, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_invite_code_admin_list_input(admin_user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.admin_list_profile_invite_codes_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_invite_code_admin_list_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_profile_play_stats(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<RuntimeProfilePlayStatsRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_play_stats_get_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().get_profile_play_stats_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_play_stats_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_runtime_snapshot(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<Option<RuntimeSnapshotRecord>, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_snapshot_get_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_runtime_snapshot_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_snapshot_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn put_runtime_snapshot(
|
|
&self,
|
|
user_id: String,
|
|
saved_at_micros: i64,
|
|
bottom_tab: String,
|
|
game_state: serde_json::Value,
|
|
current_story: Option<serde_json::Value>,
|
|
updated_at_micros: i64,
|
|
) -> Result<RuntimeSnapshotRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_snapshot_upsert_input(
|
|
user_id,
|
|
saved_at_micros,
|
|
bottom_tab,
|
|
game_state,
|
|
current_story,
|
|
updated_at_micros,
|
|
)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.upsert_runtime_snapshot_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_snapshot_required_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn delete_runtime_snapshot(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<bool, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_snapshot_delete_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.delete_runtime_snapshot_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_snapshot_delete_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn list_profile_save_archives(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<Vec<RuntimeProfileSaveArchiveRecord>, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_profile_save_archive_list_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection.procedures().list_profile_save_archives_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_save_archive_list_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn resume_profile_save_archive(
|
|
&self,
|
|
user_id: String,
|
|
world_key: String,
|
|
) -> Result<(RuntimeProfileSaveArchiveRecord, RuntimeSnapshotRecord), SpacetimeClientError>
|
|
{
|
|
let procedure_input = build_runtime_profile_save_archive_resume_input(user_id, world_key)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.resume_profile_save_archive_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_profile_save_archive_resume_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn put_runtime_settings(
|
|
&self,
|
|
user_id: String,
|
|
music_volume: f32,
|
|
platform_theme: DomainRuntimePlatformTheme,
|
|
updated_at_micros: i64,
|
|
) -> Result<RuntimeSettingsRecord, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_setting_upsert_input(
|
|
user_id,
|
|
music_volume,
|
|
platform_theme,
|
|
updated_at_micros,
|
|
)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.upsert_runtime_setting_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_setting_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn upsert_platform_browse_history_entries(
|
|
&self,
|
|
user_id: String,
|
|
entries: Vec<module_runtime::RuntimeBrowseHistoryWriteInput>,
|
|
updated_at_micros: i64,
|
|
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
|
|
let procedure_input =
|
|
build_runtime_browse_history_sync_input(user_id, entries, updated_at_micros)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.upsert_platform_browse_history_and_return_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_browse_history_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn clear_platform_browse_history(
|
|
&self,
|
|
user_id: String,
|
|
) -> Result<Vec<RuntimeBrowseHistoryRecord>, SpacetimeClientError> {
|
|
let procedure_input = build_runtime_browse_history_clear_input(user_id)
|
|
.map_err(SpacetimeClientError::validation_failed)?
|
|
.into();
|
|
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.clear_platform_browse_history_and_return_then(
|
|
procedure_input,
|
|
move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_runtime_browse_history_procedure_result);
|
|
send_once(&sender, mapped);
|
|
},
|
|
);
|
|
})
|
|
.await
|
|
}
|
|
}
|