Skip to main content

atlassian_rust_api/jira/endpoints/attachments/
get_attachment.rs

1use std::sync::Arc;
2
3use crate::{Jira, Result, rest_client::RestClient, web::Endpoint};
4
5#[derive(Debug, Clone)]
6pub struct GetAttachmentBuilder {
7	client: Arc<RestClient>,
8	request: GetAttachmentRequest,
9}
10
11#[derive(Debug, Clone, Default)]
12struct GetAttachmentRequest {
13	id: u32,
14}
15
16impl Endpoint for GetAttachmentRequest {
17	fn endpoint(&self) -> std::borrow::Cow<'static, str> {
18		format!("attachment/{}", self.id).into()
19	}
20}
21
22impl GetAttachmentBuilder {
23	fn new(client: Arc<RestClient>) -> GetAttachmentBuilder {
24		GetAttachmentBuilder { client, request: GetAttachmentRequest::default() }
25	}
26
27	fn id(mut self, id: u32) -> GetAttachmentBuilder {
28		self.request.id = id;
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 the meta-data for an attachment, including the URI of the actual attached file.
39	pub fn get_attachment(&self, id: u32) -> GetAttachmentBuilder {
40		GetAttachmentBuilder::new(Arc::clone(&self.client)).id(id)
41	}
42}