1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
use api_request_utils_rs::Client;

/// Represents an application with its associated options.
pub struct App<'a> {
    /// The name of the application.
    pub name: &'a str,
    /// The options for the application.
    pub options: Options<'a>,
    
    pub client : Client
}

/// Represents the configurable options for an application.
pub struct Options<'a> {
    /// The application ID.
    pub application_id: &'a str,
    /// The API key for accessing the application.
    pub api_key: &'a str,
    /// The URL of the database (optional).
    pub database_url: Option<&'a str>,
    /// The Google Analytics tracking ID (optional).
    pub ga_tracking_id: Option<&'a str>,
    /// The storage bucket (optional).
    pub storage_bucket: Option<&'a str>,
    /// The project ID (optional).
    pub project_id: Option<&'a str>,
    /// The Google Cloud Messaging (GCM) sender ID (optional).
    pub gcm_sender_id: Option<&'a str>,
    /// The authentication domain (optional).
    pub auth_domain: Option<&'a str>,
}

impl<'a> App<'a> {
    /// Creates a new instance of the `App` struct.
    ///
    /// # Arguments
    ///
    /// * `name` - The name of the application.
    /// * `options` - The options for the application.
    ///
    /// # Returns
    ///
    /// A new `App` instance.
    pub fn new(name: &'a str, options: Options<'a>) -> Self {
        let client = Client::new();
        App {
            name,
            options,
            client
        }
    }
}

impl<'a> Options<'a> {
    /// Creates a new instance of the `Options` struct.
    ///
    /// # Arguments
    ///
    /// * `application_id` - The application ID.
    /// * `api_key` - The API key for accessing the application.
    ///
    /// # Returns
    ///
    /// A new `Options` instance.
    pub const fn new(application_id: &'a str, api_key: &'a str) -> Self {
        Options {
            application_id,
            api_key,
            database_url: None,
            ga_tracking_id: None,
            storage_bucket: None,
            project_id: None,
            gcm_sender_id: None,
            auth_domain: None,
        }
    }

    /// Sets the database URL for the options.
    ///
    /// # Arguments
    ///
    /// * `database_url` - The URL of the database.
    ///
    /// # Returns
    ///
    /// The modified `Options` instance.
    pub const fn with_database_url(mut self, database_url: &'a str) -> Self {
        self.database_url = Some(database_url);
        self
    }

    /// Sets the Google Analytics tracking ID for the options.
    ///
    /// # Arguments
    ///
    /// * `ga_tracking_id` - The Google Analytics tracking ID.
    ///
    /// # Returns
    ///
    /// The modified `Options` instance.
    pub const fn with_ga_tracking_id(mut self, ga_tracking_id: &'a str) -> Self {
        self.ga_tracking_id = Some(ga_tracking_id);
        self
    }

    /// Sets the storage bucket for the options.
    ///
    /// # Arguments
    ///
    /// * `storage_bucket` - The storage bucket.
    ///
    /// # Returns
    ///
    /// The modified `Options` instance.
    pub const fn with_storage_bucket(mut self, storage_bucket: &'a str) -> Self {
        self.storage_bucket = Some(storage_bucket);
        self
    }

    /// Sets the project ID for the options.
    ///
    /// # Arguments
    ///
    /// * `project_id` - The project ID.
    ///
    /// # Returns
    ///
    /// The modified `Options` instance.
    pub const fn with_project_id(mut self, project_id: &'a str) -> Self {
        self.project_id = Some(project_id);
        self
    }

    /// Sets the Google Cloud Messaging (GCM) sender ID for the options.
    ///
    /// # Arguments
    ///
    /// * `gcm_sender_id` - The GCM sender ID.
    ///
    /// # Returns
    ///
    /// The modified `Options` instance.
    pub const fn with_gcm_sender_id(mut self, gcm_sender_id: &'a str) -> Self {
        self.gcm_sender_id = Some(gcm_sender_id);
        self
    }

    /// Sets the authentication domain for the options.
    ///
    /// # Arguments
    ///
    /// * `auth_domain` - The authentication domain.
    ///
    /// # Returns
    ///
    /// The modified `Options` instance.
    pub const fn with_auth_domain(mut self, auth_domain: &'a str) -> Self {
        self.auth_domain = Some(auth_domain);
        self
    }
}