nullnet_libdatastore/builders/
login_request_builder.rs1use crate::{LoginBody, LoginData, LoginParams, LoginRequest};
2
3#[derive(Debug, Default)]
4pub struct LoginRequestBuilder {
5 account_id: Option<String>,
6 account_secret: Option<String>,
7 is_root: bool,
8}
9
10impl LoginRequestBuilder {
11 pub fn new() -> Self {
12 Self::default()
13 }
14
15 pub fn account_id(mut self, id: impl Into<String>) -> Self {
16 self.account_id = Some(id.into());
17 self
18 }
19
20 pub fn account_secret(mut self, secret: impl Into<String>) -> Self {
21 self.account_secret = Some(secret.into());
22 self
23 }
24
25 pub fn set_root(mut self, is_root: bool) -> Self {
26 self.is_root = is_root;
27 self
28 }
29
30 pub fn build(self) -> LoginRequest {
31 LoginRequest {
32 body: Some(LoginBody {
33 data: Some(LoginData {
34 account_id: self.account_id.unwrap_or_default(),
35 account_secret: self.account_secret.unwrap_or_default(),
36 }),
37 }),
38 params: Some(LoginParams {
39 is_root: if self.is_root {
41 String::from("true")
42 } else {
43 String::from("false")
44 },
45 t: String::new(),
46 }),
47 }
48 }
49}