steel-rs 0.1.3

Steel API client
Documentation
use crate::client::{MultipartRequestBuilder, RequestBuilder, Steel};
use crate::types::*;

pub struct Profiles<'a> {
    client: &'a Steel,
}

impl<'a> Profiles<'a> {
    pub fn new(client: &'a Steel) -> Self {
        Self { client }
    }

    /// List all profiles
    pub fn list(
        &self,
        query: ProfileListParams,
    ) -> RequestBuilder<'_, ProfileListParams, (), ProfileListResponse> {
        let path = "/v1/profiles".to_string();
        self.client
            .call(reqwest::Method::GET, path, Some(query), None::<()>)
    }

    /// Create a profile
    pub fn create(
        &self,
        body: ProfileCreateParams,
    ) -> MultipartRequestBuilder<
        '_,
        impl Fn() -> Result<reqwest::multipart::Form, reqwest::Error>,
        (),
        ProfileCreateResponse,
    > {
        let path = "/v1/profiles".to_string();
        self.client
            .multipart_call(reqwest::Method::POST, path, None::<()>, move || {
                body.to_form()
            })
    }

    /// Get a profile
    pub fn get(
        &self,
        id: &str,
        query: ProfileGetParams,
    ) -> RequestBuilder<'_, ProfileGetParams, (), ProfileGetResponse> {
        let path = format!("/v1/profiles/{}", crate::client::encode_path(id));
        self.client
            .call(reqwest::Method::GET, path, Some(query), None::<()>)
    }

    /// Update a profile
    pub fn update(
        &self,
        id: &str,
        body: ProfileUpdateParams,
        query: ProfileUpdateQueryParams,
    ) -> MultipartRequestBuilder<
        '_,
        impl Fn() -> Result<reqwest::multipart::Form, reqwest::Error>,
        ProfileUpdateQueryParams,
        ProfileUpdateResponse,
    > {
        let path = format!("/v1/profiles/{}", crate::client::encode_path(id));
        self.client
            .multipart_call(reqwest::Method::PATCH, path, Some(query), move || {
                body.to_form()
            })
    }
}