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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
use serde_json::json;
use crate::model::*;
use crate::BumpClient;
/**Create this with the associated client method.

That method takes required values as arguments. Set optional values using builder methods on this struct.*/
pub struct PostDiffsRequest<'a> {
    pub(crate) client: &'a BumpClient,
    pub url: Option<String>,
    pub previous_url: Option<String>,
    pub previous_definition: Option<String>,
    pub previous_references: Option<Vec<Reference>>,
    pub definition: Option<String>,
    pub references: Option<Vec<Reference>>,
    pub expires_at: Option<String>,
}
impl<'a> PostDiffsRequest<'a> {
    pub async fn send(self) -> anyhow::Result<serde_json::Value> {
        let mut r = self.client.client.post("/diffs");
        if let Some(ref unwrapped) = self.url {
            r = r.push_json(json!({ "url" : unwrapped }));
        }
        if let Some(ref unwrapped) = self.previous_url {
            r = r.push_json(json!({ "previous_url" : unwrapped }));
        }
        if let Some(ref unwrapped) = self.previous_definition {
            r = r.push_json(json!({ "previous_definition" : unwrapped }));
        }
        if let Some(ref unwrapped) = self.previous_references {
            r = r.push_json(json!({ "previous_references" : unwrapped }));
        }
        if let Some(ref unwrapped) = self.definition {
            r = r.push_json(json!({ "definition" : unwrapped }));
        }
        if let Some(ref unwrapped) = self.references {
            r = r.push_json(json!({ "references" : unwrapped }));
        }
        if let Some(ref unwrapped) = self.expires_at {
            r = r.push_json(json!({ "expires_at" : unwrapped }));
        }
        r = self.client.authenticate(r);
        let res = r.send().await.unwrap().error_for_status();
        match res {
            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
            Err(res) => {
                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
                Err(anyhow::anyhow!("{:?}", text))
            }
        }
    }
    pub fn url(mut self, url: &str) -> Self {
        self.url = Some(url.to_owned());
        self
    }
    pub fn previous_url(mut self, previous_url: &str) -> Self {
        self.previous_url = Some(previous_url.to_owned());
        self
    }
    pub fn previous_definition(mut self, previous_definition: &str) -> Self {
        self.previous_definition = Some(previous_definition.to_owned());
        self
    }
    pub fn previous_references(mut self, previous_references: Vec<Reference>) -> Self {
        self.previous_references = Some(previous_references);
        self
    }
    pub fn definition(mut self, definition: &str) -> Self {
        self.definition = Some(definition.to_owned());
        self
    }
    pub fn references(mut self, references: Vec<Reference>) -> Self {
        self.references = Some(references);
        self
    }
    pub fn expires_at(mut self, expires_at: &str) -> Self {
        self.expires_at = Some(expires_at.to_owned());
        self
    }
}
/**Create this with the associated client method.

That method takes required values as arguments. Set optional values using builder methods on this struct.*/
pub struct GetDiffsByIdRequest<'a> {
    pub(crate) client: &'a BumpClient,
    pub id: String,
    pub formats: Option<Vec<String>>,
}
impl<'a> GetDiffsByIdRequest<'a> {
    pub async fn send(self) -> anyhow::Result<DiffForApi> {
        let mut r = self.client.client.get(&format!("/diffs/{id}", id = self.id));
        if let Some(ref unwrapped) = self.formats {
            for item in unwrapped {
                r = r.push_query("formats[]", &item.to_string());
            }
        }
        r = self.client.authenticate(r);
        let res = r.send().await.unwrap().error_for_status();
        match res {
            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
            Err(res) => {
                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
                Err(anyhow::anyhow!("{:?}", text))
            }
        }
    }
    pub fn formats(
        mut self,
        formats: impl IntoIterator<Item = impl AsRef<str>>,
    ) -> Self {
        self
            .formats = Some(
            formats.into_iter().map(|s| s.as_ref().to_owned()).collect(),
        );
        self
    }
}
/**Create this with the associated client method.

That method takes required values as arguments. Set optional values using builder methods on this struct.*/
pub struct GetHubsByHubIdOrSlugRequest<'a> {
    pub(crate) client: &'a BumpClient,
    pub hub_id_or_slug: String,
}
impl<'a> GetHubsByHubIdOrSlugRequest<'a> {
    pub async fn send(self) -> anyhow::Result<Hub> {
        let mut r = self
            .client
            .client
            .get(
                &format!("/hubs/{hub_id_or_slug}", hub_id_or_slug = self.hub_id_or_slug),
            );
        r = self.client.authenticate(r);
        let res = r.send().await.unwrap().error_for_status();
        match res {
            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
            Err(res) => {
                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
                Err(anyhow::anyhow!("{:?}", text))
            }
        }
    }
}
/**Create this with the associated client method.

That method takes required values as arguments. Set optional values using builder methods on this struct.*/
pub struct PostVersionsRequest<'a> {
    pub(crate) client: &'a BumpClient,
    pub documentation: String,
    pub hub: String,
    pub documentation_name: String,
    pub auto_create_documentation: bool,
    pub definition: String,
    pub references: Vec<Reference>,
    pub branch_name: String,
    pub previous_version_id: String,
    pub unpublished: bool,
}
impl<'a> PostVersionsRequest<'a> {
    pub async fn send(self) -> anyhow::Result<Version> {
        let mut r = self.client.client.post("/versions");
        r = r.push_json(json!({ "documentation" : self.documentation }));
        r = r.push_json(json!({ "hub" : self.hub }));
        r = r.push_json(json!({ "documentation_name" : self.documentation_name }));
        r = r
            .push_json(
                json!({ "auto_create_documentation" : self.auto_create_documentation }),
            );
        r = r.push_json(json!({ "definition" : self.definition }));
        r = r.push_json(json!({ "references" : self.references }));
        r = r.push_json(json!({ "branch_name" : self.branch_name }));
        r = r.push_json(json!({ "previous_version_id" : self.previous_version_id }));
        r = r.push_json(json!({ "unpublished" : self.unpublished }));
        r = self.client.authenticate(r);
        let res = r.send().await.unwrap().error_for_status();
        match res {
            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
            Err(res) => {
                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
                Err(anyhow::anyhow!("{:?}", text))
            }
        }
    }
}
pub struct PostVersionsRequired<'a> {
    pub documentation: &'a str,
    pub hub: &'a str,
    pub documentation_name: &'a str,
    pub auto_create_documentation: bool,
    pub definition: &'a str,
    pub references: Vec<Reference>,
    pub branch_name: &'a str,
    pub previous_version_id: &'a str,
    pub unpublished: bool,
}
impl<'a> PostVersionsRequired<'a> {}
/**Create this with the associated client method.

That method takes required values as arguments. Set optional values using builder methods on this struct.*/
pub struct PostValidationsRequest<'a> {
    pub(crate) client: &'a BumpClient,
    pub documentation: String,
    pub hub: String,
    pub documentation_name: String,
    pub auto_create_documentation: bool,
    pub url: String,
    pub definition: String,
    pub references: Vec<Reference>,
}
impl<'a> PostValidationsRequest<'a> {
    pub async fn send(self) -> anyhow::Result<Validation> {
        let mut r = self.client.client.post("/validations");
        r = r.push_json(json!({ "documentation" : self.documentation }));
        r = r.push_json(json!({ "hub" : self.hub }));
        r = r.push_json(json!({ "documentation_name" : self.documentation_name }));
        r = r
            .push_json(
                json!({ "auto_create_documentation" : self.auto_create_documentation }),
            );
        r = r.push_json(json!({ "url" : self.url }));
        r = r.push_json(json!({ "definition" : self.definition }));
        r = r.push_json(json!({ "references" : self.references }));
        r = self.client.authenticate(r);
        let res = r.send().await.unwrap().error_for_status();
        match res {
            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
            Err(res) => {
                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
                Err(anyhow::anyhow!("{:?}", text))
            }
        }
    }
}
pub struct PostValidationsRequired<'a> {
    pub documentation: &'a str,
    pub hub: &'a str,
    pub documentation_name: &'a str,
    pub auto_create_documentation: bool,
    pub url: &'a str,
    pub definition: &'a str,
    pub references: Vec<Reference>,
}
impl<'a> PostValidationsRequired<'a> {}
/**Create this with the associated client method.

That method takes required values as arguments. Set optional values using builder methods on this struct.*/
pub struct PostPreviewsRequest<'a> {
    pub(crate) client: &'a BumpClient,
    pub definition: String,
    pub references: Option<Vec<Reference>>,
}
impl<'a> PostPreviewsRequest<'a> {
    pub async fn send(self) -> anyhow::Result<Preview> {
        let mut r = self.client.client.post("/previews");
        r = r.push_json(json!({ "definition" : self.definition }));
        if let Some(ref unwrapped) = self.references {
            r = r.push_json(json!({ "references" : unwrapped }));
        }
        r = self.client.authenticate(r);
        let res = r.send().await.unwrap().error_for_status();
        match res {
            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
            Err(res) => {
                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
                Err(anyhow::anyhow!("{:?}", text))
            }
        }
    }
    pub fn references(mut self, references: Vec<Reference>) -> Self {
        self.references = Some(references);
        self
    }
}
/**Create this with the associated client method.

That method takes required values as arguments. Set optional values using builder methods on this struct.*/
pub struct PutPreviewsByPreviewIdRequest<'a> {
    pub(crate) client: &'a BumpClient,
    pub preview_id: String,
    pub definition: String,
    pub references: Option<Vec<Reference>>,
}
impl<'a> PutPreviewsByPreviewIdRequest<'a> {
    pub async fn send(self) -> anyhow::Result<Preview> {
        let mut r = self
            .client
            .client
            .put(&format!("/previews/{preview_id}", preview_id = self.preview_id));
        r = r.push_json(json!({ "definition" : self.definition }));
        if let Some(ref unwrapped) = self.references {
            r = r.push_json(json!({ "references" : unwrapped }));
        }
        r = self.client.authenticate(r);
        let res = r.send().await.unwrap().error_for_status();
        match res {
            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
            Err(res) => {
                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
                Err(anyhow::anyhow!("{:?}", text))
            }
        }
    }
    pub fn references(mut self, references: Vec<Reference>) -> Self {
        self.references = Some(references);
        self
    }
}
/**Create this with the associated client method.

That method takes required values as arguments. Set optional values using builder methods on this struct.*/
pub struct GetVersionsByVersionIdRequest<'a> {
    pub(crate) client: &'a BumpClient,
    pub version_id: String,
}
impl<'a> GetVersionsByVersionIdRequest<'a> {
    pub async fn send(self) -> anyhow::Result<serde_json::Value> {
        let mut r = self
            .client
            .client
            .get(&format!("/versions/{version_id}", version_id = self.version_id));
        r = self.client.authenticate(r);
        let res = r.send().await.unwrap().error_for_status();
        match res {
            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
            Err(res) => {
                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
                Err(anyhow::anyhow!("{:?}", text))
            }
        }
    }
}
/**Create this with the associated client method.

That method takes required values as arguments. Set optional values using builder methods on this struct.*/
pub struct GetPingRequest<'a> {
    pub(crate) client: &'a BumpClient,
}
impl<'a> GetPingRequest<'a> {
    pub async fn send(self) -> anyhow::Result<Pong> {
        let mut r = self.client.client.get("/ping");
        r = self.client.authenticate(r);
        let res = r.send().await.unwrap().error_for_status();
        match res {
            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
            Err(res) => {
                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
                Err(anyhow::anyhow!("{:?}", text))
            }
        }
    }
}