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.

//! Pings operations.

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

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

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

impl<'a> PingsService<'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 a Ping with people, or return the one that already holds exactly
    /// them.
    ///
    /// The caller is always included. Without `new_group`, an existing active
    /// Ping with exactly these people (the oldest, if several) is returned rather
    /// than a second one created; with `new_group: true` and more than one other
    /// person, a new group is created every time. Either way the answer is
    /// `201 Created` with the Ping.
    ///
    /// Answers `403 Forbidden` (`{"error": "Pings have been disabled"}`) when the
    /// caller cannot ping, and a bodiless `422` when nobody in the Ping would be a
    /// person who can ping.
    ///
    /// `POST /circles.json` — not idempotent, sent exactly once.
    pub async fn create(
        &self,
        body: &CreatePingRequestContent,
    ) -> Result<CreatePingResponseContent, Error> {
        let mut operation = self.client.operation(&routes::CREATE_PING, &[]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Get a Ping by its id, which is its bucket's id.
    ///
    /// Answers `403 Forbidden` (`{"error": "Pings have been disabled"}`) when the
    /// caller cannot ping, and `404 Not Found` for a bucket that is not a Ping the
    /// caller is in.
    ///
    /// `GET /circles/{pingId}` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn get(&self, ping_id: i64) -> Result<GetPingResponseContent, Error> {
        let operation = self.client.operation(&routes::GET_PING, &[&ping_id]);
        self.client.send(operation).await
    }

    /// Get Pings: the caller's active Pings that have a line in them, most
    /// recently updated first, in one unpaginated response. Archived Pings, and
    /// Pings no one has posted in yet, are not listed; GetPing reads either by id.
    ///
    /// Answers `403 Forbidden` (`{"error": "Pings have been disabled"}`) when the
    /// caller cannot ping.
    ///
    /// `GET /circles.json` — idempotent; retries up to 3 attempt(s) on 429, 503.
    pub async fn list(&self) -> Result<ListPingsResponseContent, Error> {
        let operation = self.client.operation(&routes::LIST_PINGS, &[]);
        self.client.send(operation).await
    }
}