whop_sdk 1.0.13

The official Rust SDK for the Whop API.
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;

pub struct LogsClient {
    pub http_client: HttpClient,
}

impl LogsClient {
    pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
        Ok(Self {
            http_client: HttpClient::new(config.clone())?,
        })
    }

    /// Lists activity for a member and all of their non-drafted memberships, most recent first.
    ///
    /// # Arguments
    ///
    /// * `id` - Member ID (`mber_` tag).
    /// * `first` - Number of log entries to return from the start of the window.
    /// * `after` - Cursor to paginate forwards from.
    /// * `last` - Number of log entries to return from the end of the window.
    /// * `before` - Cursor to paginate backwards from.
    /// * `options` - Additional request options such as headers, timeout, etc.
    ///
    /// # Returns
    ///
    /// JSON response from the API
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use whop_sdk::prelude::*;
    ///
    /// #[tokio::main]
    /// async fn main() {
    ///     let config = ClientConfig {
    ///         token: Some("<token>".to_string()),
    ///         ..Default::default()
    ///     };
    ///     let client = Whop::new(config).expect("Failed to build client");
    ///     client
    ///         .members
    ///         .logs
    ///         .list(
    ///             &"id".to_string(),
    ///             &MembersLogsListQueryRequest {
    ///                 ..Default::default()
    ///             },
    ///             None,
    ///         )
    ///         .await;
    /// }
    /// ```
    pub async fn list(
        &self,
        id: &str,
        request: &MembersLogsListQueryRequest,
        options: Option<RequestOptions>,
    ) -> Result<ListLogsResponse, ApiError> {
        self.http_client
            .execute_request(
                Method::GET,
                &format!("members/{}/logs", id),
                None,
                QueryBuilder::new()
                    .int("first", request.first.clone())
                    .string("after", request.after.clone())
                    .int("last", request.last.clone())
                    .string("before", request.before.clone())
                    .build(),
                options,
            )
            .await
    }
}