Skip to main content

atlassian_rust_api/jira/endpoints/avatars/
get_all_system_avatars.rs

1use std::sync::Arc;
2
3use crate::{Jira, Result, rest_client::RestClient, web::Endpoint};
4
5#[derive(Debug, Clone)]
6pub struct GetAllSystemAvatarsBuilder {
7	client: Arc<RestClient>,
8	request: GetAllSystemAvatarsRequest,
9}
10
11#[derive(Debug, Clone, Default)]
12struct GetAllSystemAvatarsRequest {
13	avatar_type: String,
14}
15
16impl Endpoint for GetAllSystemAvatarsRequest {
17	fn endpoint(&self) -> std::borrow::Cow<'static, str> {
18		format!("avatar/{}/system", &self.avatar_type).into()
19	}
20}
21
22impl GetAllSystemAvatarsBuilder {
23	fn new(client: Arc<RestClient>) -> GetAllSystemAvatarsBuilder {
24		GetAllSystemAvatarsBuilder { client, request: GetAllSystemAvatarsRequest::default() }
25	}
26
27	fn avatar_type(mut self, avatar_type: impl Into<String>) -> GetAllSystemAvatarsBuilder {
28		self.request.avatar_type = avatar_type.into();
29		self
30	}
31
32	pub async fn send(self) -> Result<serde_json::Value> {
33		self.client.get(self.request).await
34	}
35}
36
37impl Jira {
38	/// Returns all system avatars of the given type
39	pub fn get_all_system_avatars(&self, avatar_type: impl Into<String>) -> GetAllSystemAvatarsBuilder {
40		GetAllSystemAvatarsBuilder::new(Arc::clone(&self.client)).avatar_type(avatar_type)
41	}
42}