Skip to main content

gong_rs/apis/
users_api.rs

1/*
2 * Gong API
3 *
4 * <h2>Overview</h2> <p> The Gong API allows you to: </p> <ol> <li> Receive the following information from Gong: <ol type=\"a\"> <li> Your company's <a href=\"#tag--Calls\">calls</a> in Gong </li> <li> Your company's <a href=\"#tag--Users\">users</a> in Gong </li> <li> Your company's user <a href=\"#tag--Stats\">stats</a> in Gong </li> <li> Your company's user <a href=\"#tag--Settings\">settings</a> in Gong </li> <li> Your company's <a href=\"#tag--Library\">libraries</a> in Gong </li> </ol></li> <li> <a href=\"#post-/v2/calls\">Upload</a> new or  <a href=\"#put-/v2/calls/-id-/media\">update</a>  call recordings in Gong, in order to support cases where you have an internal system that records  calls or obtains them from a third-party entity. </li> <li> <a href=\"#post-/v2/data-privacy/erase-data-for-email-address\">Data Privacy</a>:  Delete users and all their associated elements.</li> <li> Upload <a href=\"#tag--CRM\">CRM</a> data into Gong.  </li> </ol> <p>Check <a href=\"https://app.gong.io/company/api-authentication?currentTab=MY_API_TAB\">here</a> what's your base URL for all API calls. </p> <h2>Authentication</h2>  <p> There are two ways to retrieve credentials to the Gong Public API: </p> <ol><li>Retrieve Manually:<br> <p> In the <a href=\"https://app.gong.io/company/api\">Gong API Page</a> (you must be a technical administrator in Gong), click \"Create\" to receive an <b>Access Key</b>  and an <b>Access Key Secret</b>.<br> </p> <p> Use the Basic Authorization HTTP header (as per <a target=\"_blank\" href=\"https://www.rfc-editor.org/rfc/rfc7617.txt\">RFC</a>) to access the Public API as shown below:<br> <code>Authorization: Basic &lt;token&gt;</code><br> </p> <p> To create the basic token, combine the <b>Access Key</b> and the <b>Access Key Secret</b> with  colon (:) and then encode in Base64 as following:<br> <code>Base64(&lt;accessKey&gt; : &lt;accessKeySecret&gt;)</code><br><br> </p></li> <li>Retrieve through OAuth<br> <p> To obtain the Bearer token, follow the steps described in the <a target=\"_blank\" href=\"https://help.gong.io/hc/en-us/articles/13944551222157-Create-an-app-for-Gong\">Gong OAuth Guide</a>. <br></p> <p> After obtaining the token, use the Bearer Authorization HTTP header (as per <a target=\"_blank\" href=\"https://www.rfc-editor.org/rfc/rfc6750.txt\">RFC</a>) to access the Public API as shown below:<br> <code>Authorization: Bearer &lt;token&gt;</code> </p> </li></ol> <h2>Limits</h2>  <p> By default Gong limits your company's access to the service to 3 API calls per second, and 10,000 API calls per day. </p> <p> When the rate of API calls exceeds these limits an HTTP status code <b>429</b> is returned and a <b>Retry-After</b> header indicates  how many seconds to wait before making a new request. </p><p> If required, contact <a target=\"_blank\" href=\"https://help.gong.io\">help.gong.io</a> to change these limits. </p>  <h2>Cursors</h2>  <p> Some API calls that return a list are limited in the amount of records they may return, so multiple API calls may be  required to bring all records. Such an API call also returns a <b>records</b> field, which contains the number of records  in the current page, the current page number and the total number of records. </p> <p> In cases where the total number of records exceeds the number of records thus far retrieved, the <b>records</b> field will also  contain a <b>cursor</b> field which can be used to access the next page of records. To retrieve the next page, repeat the API call with  the <b>cursor</b> value as supplied by the previous API call. All other request inputs should remain the same. </p> <h2>Forward Compatibility</h2>  <p> When coding a system to accept Gong data, take into account that Gong may, without prior warning, add fields to the JSON output.  It is recommended to future proof your code so that it disregards all JSON fields you don't actually use.  </p><p></p>
5 *
6 * The version of the OpenAPI document: V2
7 * Contact: mail@cedric-ziel.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17/// struct for passing parameters to the method [`get_user`]
18#[derive(Clone, Debug)]
19pub struct GetUserParams {
20    /// Gong's unique numeric identifier for the user (up to 20 digits).
21    pub id: String
22}
23
24/// struct for passing parameters to the method [`get_user_history`]
25#[derive(Clone, Debug)]
26pub struct GetUserHistoryParams {
27    /// Gong's unique numeric identifier for the user (up to 20 digits).
28    pub id: String
29}
30
31/// struct for passing parameters to the method [`list_multiple_users`]
32#[derive(Clone, Debug)]
33pub struct ListMultipleUsersParams {
34    pub public_api_base_request_v2_multiple_users_request_with_creation_dates: models::PublicApiBaseRequestV2MultipleUsersRequestWithCreationDates
35}
36
37/// struct for passing parameters to the method [`list_users`]
38#[derive(Clone, Debug)]
39pub struct ListUsersParams {
40    /// When paging is needed, provide the value supplied by the previous API call to bring the following page of records.
41    pub cursor: Option<String>,
42    /// Avatars are synthetic users representing Gong employees (CSMs and support providers) when they access your instance. References to avatars' IDs may be found in the outputs of other API endpoints. This parameter is optional, if not provided avatars will not be included in the results.
43    pub include_avatars: Option<bool>
44}
45
46
47/// struct for typed errors of method [`get_user`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum GetUserError {
51    Status400(models::ErrorResponse),
52    Status401(models::ErrorResponse),
53    Status404(models::ErrorResponse),
54    Status429(models::ErrorResponse),
55    Status500(models::ErrorResponse),
56    UnknownValue(serde_json::Value),
57}
58
59/// struct for typed errors of method [`get_user_history`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum GetUserHistoryError {
63    Status400(models::ErrorResponse),
64    Status401(models::ErrorResponse),
65    Status404(models::ErrorResponse),
66    Status429(models::ErrorResponse),
67    Status500(models::ErrorResponse),
68    UnknownValue(serde_json::Value),
69}
70
71/// struct for typed errors of method [`list_multiple_users`]
72#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum ListMultipleUsersError {
75    Status400(models::ErrorResponse),
76    Status401(models::ErrorResponse),
77    Status404(models::ErrorResponse),
78    Status429(models::ErrorResponse),
79    Status500(models::ErrorResponse),
80    UnknownValue(serde_json::Value),
81}
82
83/// struct for typed errors of method [`list_users`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum ListUsersError {
87    Status400(models::ErrorResponse),
88    Status403(models::ErrorResponse),
89    Status429(models::ErrorResponse),
90    Status500(models::ErrorResponse),
91    UnknownValue(serde_json::Value),
92}
93
94
95/// Retrieve a specific user.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:users:read'.
96pub async fn get_user(configuration: &configuration::Configuration, params: GetUserParams) -> Result<models::User, Error<GetUserError>> {
97    let local_var_configuration = configuration;
98
99    // unbox the parameters
100    let id = params.id;
101
102
103    let local_var_client = &local_var_configuration.client;
104
105    let local_var_uri_str = format!("{}/v2/users/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
106    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
107
108    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
109        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
110    }
111    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
112        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
113    };
114
115    let local_var_req = local_var_req_builder.build()?;
116    let local_var_resp = local_var_client.execute(local_var_req).await?;
117
118    let local_var_status = local_var_resp.status();
119    let local_var_content = local_var_resp.text().await?;
120
121    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
122        serde_json::from_str(&local_var_content).map_err(Error::from)
123    } else {
124        let local_var_entity: Option<GetUserError> = serde_json::from_str(&local_var_content).ok();
125        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
126        Err(Error::ResponseError(local_var_error))
127    }
128}
129
130/// Retrieve a specific user's settings history.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:users:read'.
131pub async fn get_user_history(configuration: &configuration::Configuration, params: GetUserHistoryParams) -> Result<models::SettingsHistory, Error<GetUserHistoryError>> {
132    let local_var_configuration = configuration;
133
134    // unbox the parameters
135    let id = params.id;
136
137
138    let local_var_client = &local_var_configuration.client;
139
140    let local_var_uri_str = format!("{}/v2/users/{id}/settings-history", local_var_configuration.base_path, id=crate::apis::urlencode(id));
141    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
142
143    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
144        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
145    }
146    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
147        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
148    };
149
150    let local_var_req = local_var_req_builder.build()?;
151    let local_var_resp = local_var_client.execute(local_var_req).await?;
152
153    let local_var_status = local_var_resp.status();
154    let local_var_content = local_var_resp.text().await?;
155
156    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
157        serde_json::from_str(&local_var_content).map_err(Error::from)
158    } else {
159        let local_var_entity: Option<GetUserHistoryError> = serde_json::from_str(&local_var_content).ok();
160        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
161        Err(Error::ResponseError(local_var_error))
162    }
163}
164
165/// List multiple Users.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:users:read'.
166pub async fn list_multiple_users(configuration: &configuration::Configuration, params: ListMultipleUsersParams) -> Result<models::UsersMetadata, Error<ListMultipleUsersError>> {
167    let local_var_configuration = configuration;
168
169    // unbox the parameters
170    let public_api_base_request_v2_multiple_users_request_with_creation_dates = params.public_api_base_request_v2_multiple_users_request_with_creation_dates;
171
172
173    let local_var_client = &local_var_configuration.client;
174
175    let local_var_uri_str = format!("{}/v2/users/extensive", local_var_configuration.base_path);
176    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
177
178    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
179        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
180    }
181    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
182        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
183    };
184    local_var_req_builder = local_var_req_builder.json(&public_api_base_request_v2_multiple_users_request_with_creation_dates);
185
186    let local_var_req = local_var_req_builder.build()?;
187    let local_var_resp = local_var_client.execute(local_var_req).await?;
188
189    let local_var_status = local_var_resp.status();
190    let local_var_content = local_var_resp.text().await?;
191
192    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
193        serde_json::from_str(&local_var_content).map_err(Error::from)
194    } else {
195        let local_var_entity: Option<ListMultipleUsersError> = serde_json::from_str(&local_var_content).ok();
196        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
197        Err(Error::ResponseError(local_var_error))
198    }
199}
200
201/// List all of the company's users.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:users:read'.
202pub async fn list_users(configuration: &configuration::Configuration, params: ListUsersParams) -> Result<models::UsersMetadata, Error<ListUsersError>> {
203    let local_var_configuration = configuration;
204
205    // unbox the parameters
206    let cursor = params.cursor;
207    let include_avatars = params.include_avatars;
208
209
210    let local_var_client = &local_var_configuration.client;
211
212    let local_var_uri_str = format!("{}/v2/users", local_var_configuration.base_path);
213    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
214
215    if let Some(ref local_var_str) = cursor {
216        local_var_req_builder = local_var_req_builder.query(&[("cursor", &local_var_str.to_string())]);
217    }
218    if let Some(ref local_var_str) = include_avatars {
219        local_var_req_builder = local_var_req_builder.query(&[("includeAvatars", &local_var_str.to_string())]);
220    }
221    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
222        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
223    }
224    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
225        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
226    };
227
228    let local_var_req = local_var_req_builder.build()?;
229    let local_var_resp = local_var_client.execute(local_var_req).await?;
230
231    let local_var_status = local_var_resp.status();
232    let local_var_content = local_var_resp.text().await?;
233
234    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
235        serde_json::from_str(&local_var_content).map_err(Error::from)
236    } else {
237        let local_var_entity: Option<ListUsersError> = serde_json::from_str(&local_var_content).ok();
238        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
239        Err(Error::ResponseError(local_var_error))
240    }
241}
242