basecamp-sdk 0.38.0

Official client for Basecamp - https://basecamp.com
Documentation
// Generated by basecamp-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

//! Attachments operations.

#![allow(
    clippy::too_many_arguments,
    clippy::wildcard_imports,
    clippy::doc_markdown
)]

use bytes::Bytes;

use crate::client::AccountClient;
use crate::error::Error;
use crate::generated::routes;
#[allow(unused_imports)]
use crate::generated::types::*;

/// `Attachments` operations, sent through one [`AccountClient`].
#[derive(Debug, Clone, Copy)]
pub struct AttachmentsService<'a> {
    client: &'a AccountClient,
}

impl<'a> AttachmentsService<'a> {
    pub(crate) fn new(client: &'a AccountClient) -> Self {
        Self { client }
    }

    /// The client this service sends through.
    pub fn client(&self) -> &'a AccountClient {
        self.client
    }

    /// Create an attachment (upload a file for embedding)
    ///
    /// `POST /attachments.json` — not idempotent, sent exactly once.
    pub async fn create(
        &self,
        name: &str,
        content_type: &str,
        body: Bytes,
    ) -> Result<CreateAttachmentResponseContent, Error> {
        let mut operation = self.client.operation(&routes::CREATE_ATTACHMENT, &[]);
        operation.query("name", name);
        operation.bytes(content_type, body);
        self.client.send(operation).await
    }
}