1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GistsSlashCheckIsStarredError {
22 Status403(models::BasicError),
23 Status404(serde_json::Value),
24 UnknownValue(serde_json::Value),
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum GistsSlashCreateError {
31 Status403(models::BasicError),
32 Status404(models::BasicError),
33 Status422(models::ValidationError),
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum GistsSlashCreateCommentError {
41 Status403(models::BasicError),
42 Status404(models::BasicError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GistsSlashDeleteError {
50 Status403(models::BasicError),
51 Status404(models::BasicError),
52 UnknownValue(serde_json::Value),
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum GistsSlashDeleteCommentError {
59 Status403(models::BasicError),
60 Status404(models::BasicError),
61 UnknownValue(serde_json::Value),
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum GistsSlashForkError {
68 Status403(models::BasicError),
69 Status404(models::BasicError),
70 Status422(models::ValidationError),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GistsSlashGetError {
78 Status403(models::GistsGet403Response),
79 Status404(models::BasicError),
80 UnknownValue(serde_json::Value),
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum GistsSlashGetCommentError {
87 Status403(models::GistsGet403Response),
88 Status404(models::BasicError),
89 UnknownValue(serde_json::Value),
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
94#[serde(untagged)]
95pub enum GistsSlashGetRevisionError {
96 Status403(models::BasicError),
97 Status404(models::BasicError),
98 Status422(models::ValidationError),
99 UnknownValue(serde_json::Value),
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum GistsSlashListError {
106 Status403(models::BasicError),
107 UnknownValue(serde_json::Value),
108}
109
110#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum GistsSlashListCommentsError {
114 Status403(models::BasicError),
115 Status404(models::BasicError),
116 UnknownValue(serde_json::Value),
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum GistsSlashListCommitsError {
123 Status403(models::BasicError),
124 Status404(models::BasicError),
125 UnknownValue(serde_json::Value),
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum GistsSlashListForUserError {
132 Status422(models::ValidationError),
133 UnknownValue(serde_json::Value),
134}
135
136#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum GistsSlashListForksError {
140 Status403(models::BasicError),
141 Status404(models::BasicError),
142 UnknownValue(serde_json::Value),
143}
144
145#[derive(Debug, Clone, Serialize, Deserialize)]
147#[serde(untagged)]
148pub enum GistsSlashListPublicError {
149 Status403(models::BasicError),
150 Status422(models::ValidationError),
151 UnknownValue(serde_json::Value),
152}
153
154#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum GistsSlashListStarredError {
158 Status401(models::BasicError),
159 Status403(models::BasicError),
160 UnknownValue(serde_json::Value),
161}
162
163#[derive(Debug, Clone, Serialize, Deserialize)]
165#[serde(untagged)]
166pub enum GistsSlashStarError {
167 Status403(models::BasicError),
168 Status404(models::BasicError),
169 UnknownValue(serde_json::Value),
170}
171
172#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum GistsSlashUnstarError {
176 Status403(models::BasicError),
177 Status404(models::BasicError),
178 UnknownValue(serde_json::Value),
179}
180
181#[derive(Debug, Clone, Serialize, Deserialize)]
183#[serde(untagged)]
184pub enum GistsSlashUpdateError {
185 Status404(models::BasicError),
186 Status422(models::ValidationError),
187 UnknownValue(serde_json::Value),
188}
189
190#[derive(Debug, Clone, Serialize, Deserialize)]
192#[serde(untagged)]
193pub enum GistsSlashUpdateCommentError {
194 Status404(models::BasicError),
195 UnknownValue(serde_json::Value),
196}
197
198
199pub async fn gists_slash_check_is_starred(configuration: &configuration::Configuration, gist_id: &str) -> Result<(), Error<GistsSlashCheckIsStarredError>> {
201 let local_var_configuration = configuration;
202
203 let local_var_client = &local_var_configuration.client;
204
205 let local_var_uri_str = format!("{}/gists/{gist_id}/star", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
206 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
207
208 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
209 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
210 }
211
212 let local_var_req = local_var_req_builder.build()?;
213 let local_var_resp = local_var_client.execute(local_var_req).await?;
214
215 let local_var_status = local_var_resp.status();
216 let local_var_content = local_var_resp.text().await?;
217
218 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
219 Ok(())
220 } else {
221 let local_var_entity: Option<GistsSlashCheckIsStarredError> = serde_json::from_str(&local_var_content).ok();
222 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
223 Err(Error::ResponseError(local_var_error))
224 }
225}
226
227pub async fn gists_slash_create(configuration: &configuration::Configuration, gists_create_request: models::GistsCreateRequest) -> Result<models::GistSimple, Error<GistsSlashCreateError>> {
229 let local_var_configuration = configuration;
230
231 let local_var_client = &local_var_configuration.client;
232
233 let local_var_uri_str = format!("{}/gists", local_var_configuration.base_path);
234 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
235
236 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
237 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
238 }
239 local_var_req_builder = local_var_req_builder.json(&gists_create_request);
240
241 let local_var_req = local_var_req_builder.build()?;
242 let local_var_resp = local_var_client.execute(local_var_req).await?;
243
244 let local_var_status = local_var_resp.status();
245 let local_var_content = local_var_resp.text().await?;
246
247 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
248 serde_json::from_str(&local_var_content).map_err(Error::from)
249 } else {
250 let local_var_entity: Option<GistsSlashCreateError> = serde_json::from_str(&local_var_content).ok();
251 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
252 Err(Error::ResponseError(local_var_error))
253 }
254}
255
256pub async fn gists_slash_create_comment(configuration: &configuration::Configuration, gist_id: &str, gists_create_comment_request: models::GistsCreateCommentRequest) -> Result<models::GistComment, Error<GistsSlashCreateCommentError>> {
258 let local_var_configuration = configuration;
259
260 let local_var_client = &local_var_configuration.client;
261
262 let local_var_uri_str = format!("{}/gists/{gist_id}/comments", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
263 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
264
265 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
266 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
267 }
268 local_var_req_builder = local_var_req_builder.json(&gists_create_comment_request);
269
270 let local_var_req = local_var_req_builder.build()?;
271 let local_var_resp = local_var_client.execute(local_var_req).await?;
272
273 let local_var_status = local_var_resp.status();
274 let local_var_content = local_var_resp.text().await?;
275
276 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
277 serde_json::from_str(&local_var_content).map_err(Error::from)
278 } else {
279 let local_var_entity: Option<GistsSlashCreateCommentError> = serde_json::from_str(&local_var_content).ok();
280 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
281 Err(Error::ResponseError(local_var_error))
282 }
283}
284
285pub async fn gists_slash_delete(configuration: &configuration::Configuration, gist_id: &str) -> Result<(), Error<GistsSlashDeleteError>> {
287 let local_var_configuration = configuration;
288
289 let local_var_client = &local_var_configuration.client;
290
291 let local_var_uri_str = format!("{}/gists/{gist_id}", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
292 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
293
294 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
295 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
296 }
297
298 let local_var_req = local_var_req_builder.build()?;
299 let local_var_resp = local_var_client.execute(local_var_req).await?;
300
301 let local_var_status = local_var_resp.status();
302 let local_var_content = local_var_resp.text().await?;
303
304 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
305 Ok(())
306 } else {
307 let local_var_entity: Option<GistsSlashDeleteError> = serde_json::from_str(&local_var_content).ok();
308 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
309 Err(Error::ResponseError(local_var_error))
310 }
311}
312
313pub async fn gists_slash_delete_comment(configuration: &configuration::Configuration, gist_id: &str, comment_id: i32) -> Result<(), Error<GistsSlashDeleteCommentError>> {
315 let local_var_configuration = configuration;
316
317 let local_var_client = &local_var_configuration.client;
318
319 let local_var_uri_str = format!("{}/gists/{gist_id}/comments/{comment_id}", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id), comment_id=comment_id);
320 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
321
322 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
323 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
324 }
325
326 let local_var_req = local_var_req_builder.build()?;
327 let local_var_resp = local_var_client.execute(local_var_req).await?;
328
329 let local_var_status = local_var_resp.status();
330 let local_var_content = local_var_resp.text().await?;
331
332 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
333 Ok(())
334 } else {
335 let local_var_entity: Option<GistsSlashDeleteCommentError> = serde_json::from_str(&local_var_content).ok();
336 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
337 Err(Error::ResponseError(local_var_error))
338 }
339}
340
341pub async fn gists_slash_fork(configuration: &configuration::Configuration, gist_id: &str) -> Result<models::BaseGist, Error<GistsSlashForkError>> {
343 let local_var_configuration = configuration;
344
345 let local_var_client = &local_var_configuration.client;
346
347 let local_var_uri_str = format!("{}/gists/{gist_id}/forks", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
348 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
349
350 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
351 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
352 }
353
354 let local_var_req = local_var_req_builder.build()?;
355 let local_var_resp = local_var_client.execute(local_var_req).await?;
356
357 let local_var_status = local_var_resp.status();
358 let local_var_content = local_var_resp.text().await?;
359
360 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
361 serde_json::from_str(&local_var_content).map_err(Error::from)
362 } else {
363 let local_var_entity: Option<GistsSlashForkError> = serde_json::from_str(&local_var_content).ok();
364 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
365 Err(Error::ResponseError(local_var_error))
366 }
367}
368
369pub async fn gists_slash_get(configuration: &configuration::Configuration, gist_id: &str) -> Result<models::GistSimple, Error<GistsSlashGetError>> {
371 let local_var_configuration = configuration;
372
373 let local_var_client = &local_var_configuration.client;
374
375 let local_var_uri_str = format!("{}/gists/{gist_id}", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
376 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
377
378 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
379 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
380 }
381
382 let local_var_req = local_var_req_builder.build()?;
383 let local_var_resp = local_var_client.execute(local_var_req).await?;
384
385 let local_var_status = local_var_resp.status();
386 let local_var_content = local_var_resp.text().await?;
387
388 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
389 serde_json::from_str(&local_var_content).map_err(Error::from)
390 } else {
391 let local_var_entity: Option<GistsSlashGetError> = serde_json::from_str(&local_var_content).ok();
392 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
393 Err(Error::ResponseError(local_var_error))
394 }
395}
396
397pub async fn gists_slash_get_comment(configuration: &configuration::Configuration, gist_id: &str, comment_id: i32) -> Result<models::GistComment, Error<GistsSlashGetCommentError>> {
399 let local_var_configuration = configuration;
400
401 let local_var_client = &local_var_configuration.client;
402
403 let local_var_uri_str = format!("{}/gists/{gist_id}/comments/{comment_id}", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id), comment_id=comment_id);
404 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
405
406 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
407 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
408 }
409
410 let local_var_req = local_var_req_builder.build()?;
411 let local_var_resp = local_var_client.execute(local_var_req).await?;
412
413 let local_var_status = local_var_resp.status();
414 let local_var_content = local_var_resp.text().await?;
415
416 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
417 serde_json::from_str(&local_var_content).map_err(Error::from)
418 } else {
419 let local_var_entity: Option<GistsSlashGetCommentError> = serde_json::from_str(&local_var_content).ok();
420 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
421 Err(Error::ResponseError(local_var_error))
422 }
423}
424
425pub async fn gists_slash_get_revision(configuration: &configuration::Configuration, gist_id: &str, sha: &str) -> Result<models::GistSimple, Error<GistsSlashGetRevisionError>> {
427 let local_var_configuration = configuration;
428
429 let local_var_client = &local_var_configuration.client;
430
431 let local_var_uri_str = format!("{}/gists/{gist_id}/{sha}", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id), sha=crate::apis::urlencode(sha));
432 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
433
434 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
435 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
436 }
437
438 let local_var_req = local_var_req_builder.build()?;
439 let local_var_resp = local_var_client.execute(local_var_req).await?;
440
441 let local_var_status = local_var_resp.status();
442 let local_var_content = local_var_resp.text().await?;
443
444 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
445 serde_json::from_str(&local_var_content).map_err(Error::from)
446 } else {
447 let local_var_entity: Option<GistsSlashGetRevisionError> = serde_json::from_str(&local_var_content).ok();
448 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
449 Err(Error::ResponseError(local_var_error))
450 }
451}
452
453pub async fn gists_slash_list(configuration: &configuration::Configuration, since: Option<String>, per_page: Option<i32>, page: Option<i32>) -> Result<Vec<models::BaseGist>, Error<GistsSlashListError>> {
455 let local_var_configuration = configuration;
456
457 let local_var_client = &local_var_configuration.client;
458
459 let local_var_uri_str = format!("{}/gists", local_var_configuration.base_path);
460 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
461
462 if let Some(ref local_var_str) = since {
463 local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
464 }
465 if let Some(ref local_var_str) = per_page {
466 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
467 }
468 if let Some(ref local_var_str) = page {
469 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
470 }
471 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
472 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
473 }
474
475 let local_var_req = local_var_req_builder.build()?;
476 let local_var_resp = local_var_client.execute(local_var_req).await?;
477
478 let local_var_status = local_var_resp.status();
479 let local_var_content = local_var_resp.text().await?;
480
481 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
482 serde_json::from_str(&local_var_content).map_err(Error::from)
483 } else {
484 let local_var_entity: Option<GistsSlashListError> = serde_json::from_str(&local_var_content).ok();
485 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
486 Err(Error::ResponseError(local_var_error))
487 }
488}
489
490pub async fn gists_slash_list_comments(configuration: &configuration::Configuration, gist_id: &str, per_page: Option<i32>, page: Option<i32>) -> Result<Vec<models::GistComment>, Error<GistsSlashListCommentsError>> {
492 let local_var_configuration = configuration;
493
494 let local_var_client = &local_var_configuration.client;
495
496 let local_var_uri_str = format!("{}/gists/{gist_id}/comments", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
497 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
498
499 if let Some(ref local_var_str) = per_page {
500 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
501 }
502 if let Some(ref local_var_str) = page {
503 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
504 }
505 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
506 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
507 }
508
509 let local_var_req = local_var_req_builder.build()?;
510 let local_var_resp = local_var_client.execute(local_var_req).await?;
511
512 let local_var_status = local_var_resp.status();
513 let local_var_content = local_var_resp.text().await?;
514
515 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
516 serde_json::from_str(&local_var_content).map_err(Error::from)
517 } else {
518 let local_var_entity: Option<GistsSlashListCommentsError> = serde_json::from_str(&local_var_content).ok();
519 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
520 Err(Error::ResponseError(local_var_error))
521 }
522}
523
524pub async fn gists_slash_list_commits(configuration: &configuration::Configuration, gist_id: &str, per_page: Option<i32>, page: Option<i32>) -> Result<Vec<models::GistCommit>, Error<GistsSlashListCommitsError>> {
526 let local_var_configuration = configuration;
527
528 let local_var_client = &local_var_configuration.client;
529
530 let local_var_uri_str = format!("{}/gists/{gist_id}/commits", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
531 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
532
533 if let Some(ref local_var_str) = per_page {
534 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
535 }
536 if let Some(ref local_var_str) = page {
537 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
538 }
539 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
540 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
541 }
542
543 let local_var_req = local_var_req_builder.build()?;
544 let local_var_resp = local_var_client.execute(local_var_req).await?;
545
546 let local_var_status = local_var_resp.status();
547 let local_var_content = local_var_resp.text().await?;
548
549 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
550 serde_json::from_str(&local_var_content).map_err(Error::from)
551 } else {
552 let local_var_entity: Option<GistsSlashListCommitsError> = serde_json::from_str(&local_var_content).ok();
553 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
554 Err(Error::ResponseError(local_var_error))
555 }
556}
557
558pub async fn gists_slash_list_for_user(configuration: &configuration::Configuration, username: &str, since: Option<String>, per_page: Option<i32>, page: Option<i32>) -> Result<Vec<models::BaseGist>, Error<GistsSlashListForUserError>> {
560 let local_var_configuration = configuration;
561
562 let local_var_client = &local_var_configuration.client;
563
564 let local_var_uri_str = format!("{}/users/{username}/gists", local_var_configuration.base_path, username=crate::apis::urlencode(username));
565 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
566
567 if let Some(ref local_var_str) = since {
568 local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
569 }
570 if let Some(ref local_var_str) = per_page {
571 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
572 }
573 if let Some(ref local_var_str) = page {
574 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
575 }
576 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
577 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
578 }
579
580 let local_var_req = local_var_req_builder.build()?;
581 let local_var_resp = local_var_client.execute(local_var_req).await?;
582
583 let local_var_status = local_var_resp.status();
584 let local_var_content = local_var_resp.text().await?;
585
586 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
587 serde_json::from_str(&local_var_content).map_err(Error::from)
588 } else {
589 let local_var_entity: Option<GistsSlashListForUserError> = serde_json::from_str(&local_var_content).ok();
590 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
591 Err(Error::ResponseError(local_var_error))
592 }
593}
594
595pub async fn gists_slash_list_forks(configuration: &configuration::Configuration, gist_id: &str, per_page: Option<i32>, page: Option<i32>) -> Result<Vec<models::GistSimple>, Error<GistsSlashListForksError>> {
597 let local_var_configuration = configuration;
598
599 let local_var_client = &local_var_configuration.client;
600
601 let local_var_uri_str = format!("{}/gists/{gist_id}/forks", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
602 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
603
604 if let Some(ref local_var_str) = per_page {
605 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
606 }
607 if let Some(ref local_var_str) = page {
608 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
609 }
610 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
611 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
612 }
613
614 let local_var_req = local_var_req_builder.build()?;
615 let local_var_resp = local_var_client.execute(local_var_req).await?;
616
617 let local_var_status = local_var_resp.status();
618 let local_var_content = local_var_resp.text().await?;
619
620 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
621 serde_json::from_str(&local_var_content).map_err(Error::from)
622 } else {
623 let local_var_entity: Option<GistsSlashListForksError> = serde_json::from_str(&local_var_content).ok();
624 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
625 Err(Error::ResponseError(local_var_error))
626 }
627}
628
629pub async fn gists_slash_list_public(configuration: &configuration::Configuration, since: Option<String>, per_page: Option<i32>, page: Option<i32>) -> Result<Vec<models::BaseGist>, Error<GistsSlashListPublicError>> {
631 let local_var_configuration = configuration;
632
633 let local_var_client = &local_var_configuration.client;
634
635 let local_var_uri_str = format!("{}/gists/public", local_var_configuration.base_path);
636 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
637
638 if let Some(ref local_var_str) = since {
639 local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
640 }
641 if let Some(ref local_var_str) = per_page {
642 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
643 }
644 if let Some(ref local_var_str) = page {
645 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
646 }
647 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
648 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
649 }
650
651 let local_var_req = local_var_req_builder.build()?;
652 let local_var_resp = local_var_client.execute(local_var_req).await?;
653
654 let local_var_status = local_var_resp.status();
655 let local_var_content = local_var_resp.text().await?;
656
657 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
658 serde_json::from_str(&local_var_content).map_err(Error::from)
659 } else {
660 let local_var_entity: Option<GistsSlashListPublicError> = serde_json::from_str(&local_var_content).ok();
661 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
662 Err(Error::ResponseError(local_var_error))
663 }
664}
665
666pub async fn gists_slash_list_starred(configuration: &configuration::Configuration, since: Option<String>, per_page: Option<i32>, page: Option<i32>) -> Result<Vec<models::BaseGist>, Error<GistsSlashListStarredError>> {
668 let local_var_configuration = configuration;
669
670 let local_var_client = &local_var_configuration.client;
671
672 let local_var_uri_str = format!("{}/gists/starred", local_var_configuration.base_path);
673 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
674
675 if let Some(ref local_var_str) = since {
676 local_var_req_builder = local_var_req_builder.query(&[("since", &local_var_str.to_string())]);
677 }
678 if let Some(ref local_var_str) = per_page {
679 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
680 }
681 if let Some(ref local_var_str) = page {
682 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
683 }
684 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
685 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
686 }
687
688 let local_var_req = local_var_req_builder.build()?;
689 let local_var_resp = local_var_client.execute(local_var_req).await?;
690
691 let local_var_status = local_var_resp.status();
692 let local_var_content = local_var_resp.text().await?;
693
694 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
695 serde_json::from_str(&local_var_content).map_err(Error::from)
696 } else {
697 let local_var_entity: Option<GistsSlashListStarredError> = serde_json::from_str(&local_var_content).ok();
698 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
699 Err(Error::ResponseError(local_var_error))
700 }
701}
702
703pub async fn gists_slash_star(configuration: &configuration::Configuration, gist_id: &str) -> Result<(), Error<GistsSlashStarError>> {
705 let local_var_configuration = configuration;
706
707 let local_var_client = &local_var_configuration.client;
708
709 let local_var_uri_str = format!("{}/gists/{gist_id}/star", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
710 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
711
712 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
713 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
714 }
715
716 let local_var_req = local_var_req_builder.build()?;
717 let local_var_resp = local_var_client.execute(local_var_req).await?;
718
719 let local_var_status = local_var_resp.status();
720 let local_var_content = local_var_resp.text().await?;
721
722 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
723 Ok(())
724 } else {
725 let local_var_entity: Option<GistsSlashStarError> = serde_json::from_str(&local_var_content).ok();
726 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
727 Err(Error::ResponseError(local_var_error))
728 }
729}
730
731pub async fn gists_slash_unstar(configuration: &configuration::Configuration, gist_id: &str) -> Result<(), Error<GistsSlashUnstarError>> {
733 let local_var_configuration = configuration;
734
735 let local_var_client = &local_var_configuration.client;
736
737 let local_var_uri_str = format!("{}/gists/{gist_id}/star", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
738 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
739
740 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
741 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
742 }
743
744 let local_var_req = local_var_req_builder.build()?;
745 let local_var_resp = local_var_client.execute(local_var_req).await?;
746
747 let local_var_status = local_var_resp.status();
748 let local_var_content = local_var_resp.text().await?;
749
750 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
751 Ok(())
752 } else {
753 let local_var_entity: Option<GistsSlashUnstarError> = serde_json::from_str(&local_var_content).ok();
754 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
755 Err(Error::ResponseError(local_var_error))
756 }
757}
758
759pub async fn gists_slash_update(configuration: &configuration::Configuration, gist_id: &str, gists_update_request: Option<models::GistsUpdateRequest>) -> Result<models::GistSimple, Error<GistsSlashUpdateError>> {
761 let local_var_configuration = configuration;
762
763 let local_var_client = &local_var_configuration.client;
764
765 let local_var_uri_str = format!("{}/gists/{gist_id}", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id));
766 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
767
768 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
769 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
770 }
771 local_var_req_builder = local_var_req_builder.json(&gists_update_request);
772
773 let local_var_req = local_var_req_builder.build()?;
774 let local_var_resp = local_var_client.execute(local_var_req).await?;
775
776 let local_var_status = local_var_resp.status();
777 let local_var_content = local_var_resp.text().await?;
778
779 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
780 serde_json::from_str(&local_var_content).map_err(Error::from)
781 } else {
782 let local_var_entity: Option<GistsSlashUpdateError> = serde_json::from_str(&local_var_content).ok();
783 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
784 Err(Error::ResponseError(local_var_error))
785 }
786}
787
788pub async fn gists_slash_update_comment(configuration: &configuration::Configuration, gist_id: &str, comment_id: i32, gists_create_comment_request: models::GistsCreateCommentRequest) -> Result<models::GistComment, Error<GistsSlashUpdateCommentError>> {
790 let local_var_configuration = configuration;
791
792 let local_var_client = &local_var_configuration.client;
793
794 let local_var_uri_str = format!("{}/gists/{gist_id}/comments/{comment_id}", local_var_configuration.base_path, gist_id=crate::apis::urlencode(gist_id), comment_id=comment_id);
795 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
796
797 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
798 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
799 }
800 local_var_req_builder = local_var_req_builder.json(&gists_create_comment_request);
801
802 let local_var_req = local_var_req_builder.build()?;
803 let local_var_resp = local_var_client.execute(local_var_req).await?;
804
805 let local_var_status = local_var_resp.status();
806 let local_var_content = local_var_resp.text().await?;
807
808 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
809 serde_json::from_str(&local_var_content).map_err(Error::from)
810 } else {
811 let local_var_entity: Option<GistsSlashUpdateCommentError> = serde_json::from_str(&local_var_content).ok();
812 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
813 Err(Error::ResponseError(local_var_error))
814 }
815}
816