use crate::scope::{
AlliancesScopes, AssetsScopes, CalendarScopes, CharactersScopes, ClonesScopes, ContractsScopes,
CorporationsScopes, FittingsScopes, FleetsScopes, IndustryScopes, KillmailsScopes,
LocationScopes, MailScopes, MarketsScopes, PlanetsScopes, SearchScopes, SkillsScopes, UiScopes,
UniverseScopes, WalletScopes,
};
pub const PUBLIC_DATA: &str = "publicData";
pub struct ScopeBuilder {
scopes: Vec<String>,
}
impl Default for ScopeBuilder {
fn default() -> Self {
Self::new()
}
}
impl ScopeBuilder {
pub fn new() -> Self {
ScopeBuilder { scopes: Vec::new() }
}
pub fn all() -> Vec<String> {
ScopeBuilder::new()
.public_data()
.alliances(AlliancesScopes::all())
.assets(AssetsScopes::all())
.calendar(CalendarScopes::all())
.characters(CharactersScopes::all())
.clones(ClonesScopes::all())
.contracts(ContractsScopes::all())
.corporations(CorporationsScopes::all())
.fittings(FittingsScopes::all())
.fleets(FleetsScopes::all())
.industry(IndustryScopes::all())
.killmails(KillmailsScopes::all())
.location(LocationScopes::all())
.mail(MailScopes::all())
.markets(MarketsScopes::all())
.planets(PlanetsScopes::all())
.search(SearchScopes::all())
.skills(SkillsScopes::all())
.ui(UiScopes::all())
.universe(UniverseScopes::all())
.wallet(WalletScopes::all())
.build()
}
pub fn build(self) -> Vec<String> {
self.scopes
}
pub fn custom(mut self, scope: &str) -> Self {
self.scopes.push(scope.to_string());
self
}
pub fn public_data(mut self) -> Self {
self.scopes.push(PUBLIC_DATA.to_string());
self
}
pub fn alliances(mut self, alliances_scopes: AlliancesScopes) -> Self {
self.scopes.extend(alliances_scopes.scopes);
self
}
pub fn assets(mut self, assets_scopes: AssetsScopes) -> Self {
self.scopes.extend(assets_scopes.scopes);
self
}
pub fn calendar(mut self, calendar_scopes: CalendarScopes) -> Self {
self.scopes.extend(calendar_scopes.scopes);
self
}
pub fn characters(mut self, characters_scopes: CharactersScopes) -> Self {
self.scopes.extend(characters_scopes.scopes);
self
}
pub fn clones(mut self, clones_scopes: ClonesScopes) -> Self {
self.scopes.extend(clones_scopes.scopes);
self
}
pub fn contracts(mut self, contracts_scopes: ContractsScopes) -> Self {
self.scopes.extend(contracts_scopes.scopes);
self
}
pub fn corporations(mut self, corporations_scopes: CorporationsScopes) -> Self {
self.scopes.extend(corporations_scopes.scopes);
self
}
pub fn fittings(mut self, fittings_scopes: FittingsScopes) -> Self {
self.scopes.extend(fittings_scopes.scopes);
self
}
pub fn fleets(mut self, fleets_scopes: FleetsScopes) -> Self {
self.scopes.extend(fleets_scopes.scopes);
self
}
pub fn industry(mut self, industry_scopes: IndustryScopes) -> Self {
self.scopes.extend(industry_scopes.scopes);
self
}
pub fn killmails(mut self, killmails_scopes: KillmailsScopes) -> Self {
self.scopes.extend(killmails_scopes.scopes);
self
}
pub fn location(mut self, location_scopes: LocationScopes) -> Self {
self.scopes.extend(location_scopes.scopes);
self
}
pub fn mail(mut self, mail_scopes: MailScopes) -> Self {
self.scopes.extend(mail_scopes.scopes);
self
}
pub fn markets(mut self, markets_scopes: MarketsScopes) -> Self {
self.scopes.extend(markets_scopes.scopes);
self
}
pub fn planets(mut self, planets_scopes: PlanetsScopes) -> Self {
self.scopes.extend(planets_scopes.scopes);
self
}
pub fn search(mut self, search_scopes: SearchScopes) -> Self {
self.scopes.extend(search_scopes.scopes);
self
}
pub fn skills(mut self, skills_scopes: SkillsScopes) -> Self {
self.scopes.extend(skills_scopes.scopes);
self
}
pub fn ui(mut self, ui_scopes: UiScopes) -> Self {
self.scopes.extend(ui_scopes.scopes);
self
}
pub fn universe(mut self, universe_scopes: UniverseScopes) -> Self {
self.scopes.extend(universe_scopes.scopes);
self
}
pub fn wallet(mut self, wallet_scopes: WalletScopes) -> Self {
self.scopes.extend(wallet_scopes.scopes);
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_scope_builder_default() {
ScopeBuilder::default().build();
}
#[test]
fn test_scope_builder_all() {
ScopeBuilder::all();
}
#[test]
fn test_scope_builder_custom() {
let scopes = ScopeBuilder::new().custom("custom_scope").build();
assert_eq!(scopes[0], "custom_scope");
}
}