1use anyhow::Result;
2
3use crate::Client;
4#[derive(Clone, Debug)]
5pub struct Me {
6 pub client: Client,
7}
8
9impl Me {
10 #[doc(hidden)]
11 pub fn new(client: Client) -> Self {
12 Self { client }
13 }
14
15 #[doc = "Retrieve my SSO information\n\nSSO information of the current user\n- Requires: `API \
16 Tier 1`\n- Expandable fields: `company`\n\n**Parameters:**\n\n- `expand: \
17 Option<String>`\n\n```rust,no_run\nasync fn example_me_list_sso() -> \
18 anyhow::Result<()> {\n let client = rippling_api::Client::new_from_env();\n let \
19 result: rippling_api::types::Ssome = client\n .me()\n \
20 .list_sso(Some(\"some-string\".to_string()))\n .await?;\n \
21 println!(\"{:?}\", result);\n Ok(())\n}\n```"]
22 #[tracing::instrument]
23 pub async fn list_sso<'a>(
24 &'a self,
25 expand: Option<String>,
26 ) -> Result<crate::types::Ssome, crate::types::error::Error> {
27 let mut req = self.client.client.request(
28 http::Method::GET,
29 format!("{}/{}", self.client.base_url, "sso-me"),
30 );
31 req = req.bearer_auth(&self.client.token);
32 let mut query_params = vec![];
33 if let Some(p) = expand {
34 query_params.push(("expand", p));
35 }
36
37 req = req.query(&query_params);
38 let resp = req.send().await?;
39 let status = resp.status();
40 if status.is_success() {
41 let text = resp.text().await.unwrap_or_default();
42 serde_json::from_str(&text).map_err(|err| {
43 crate::types::error::Error::from_serde_error(
44 format_serde_error::SerdeError::new(text.to_string(), err),
45 status,
46 )
47 })
48 } else {
49 let text = resp.text().await.unwrap_or_default();
50 Err(crate::types::error::Error::Server {
51 body: text.to_string(),
52 status,
53 })
54 }
55 }
56}