Skip to main content

gong_rs/apis/
stats_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 [`list_answered_scorecards`]
18#[derive(Clone, Debug)]
19pub struct ListAnsweredScorecardsParams {
20    pub public_api_base_request_v2_answered_scorecards_filter: models::PublicApiBaseRequestV2AnsweredScorecardsFilter
21}
22
23/// struct for passing parameters to the method [`list_interaction_stats`]
24#[derive(Clone, Debug)]
25pub struct ListInteractionStatsParams {
26    pub public_api_base_request_v2_multiple_users_with_dates: models::PublicApiBaseRequestV2MultipleUsersWithDates
27}
28
29/// struct for passing parameters to the method [`list_multiple_users_aggregate_activity`]
30#[derive(Clone, Debug)]
31pub struct ListMultipleUsersAggregateActivityParams {
32    pub public_api_base_request_v2_multiple_users_with_dates: models::PublicApiBaseRequestV2MultipleUsersWithDates
33}
34
35/// struct for passing parameters to the method [`list_multiple_users_aggregate_by_period`]
36#[derive(Clone, Debug)]
37pub struct ListMultipleUsersAggregateByPeriodParams {
38    pub request_with_time_period: models::RequestWithTimePeriod
39}
40
41/// struct for passing parameters to the method [`list_multiple_users_day_by_day_activity`]
42#[derive(Clone, Debug)]
43pub struct ListMultipleUsersDayByDayActivityParams {
44    pub public_api_base_request_v2_multiple_users_with_dates: models::PublicApiBaseRequestV2MultipleUsersWithDates
45}
46
47
48/// struct for typed errors of method [`list_answered_scorecards`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum ListAnsweredScorecardsError {
52    Status400(models::ErrorResponse),
53    Status401(models::ErrorResponse),
54    Status404(models::ErrorResponse),
55    Status429(models::ErrorResponse),
56    Status500(models::ErrorResponse),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`list_interaction_stats`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListInteractionStatsError {
64    Status400(models::ErrorResponse),
65    Status401(models::ErrorResponse),
66    Status404(models::ErrorResponse),
67    Status429(models::ErrorResponse),
68    Status500(models::ErrorResponse),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`list_multiple_users_aggregate_activity`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum ListMultipleUsersAggregateActivityError {
76    Status400(models::ErrorResponse),
77    Status401(models::ErrorResponse),
78    Status404(models::ErrorResponse),
79    Status429(models::ErrorResponse),
80    Status500(models::ErrorResponse),
81    UnknownValue(serde_json::Value),
82}
83
84/// struct for typed errors of method [`list_multiple_users_aggregate_by_period`]
85#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum ListMultipleUsersAggregateByPeriodError {
88    Status400(models::ErrorResponse),
89    Status401(models::ErrorResponse),
90    Status404(models::ErrorResponse),
91    Status429(models::ErrorResponse),
92    Status500(models::ErrorResponse),
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`list_multiple_users_day_by_day_activity`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum ListMultipleUsersDayByDayActivityError {
100    Status400(models::ErrorResponse),
101    Status401(models::ErrorResponse),
102    Status404(models::ErrorResponse),
103    Status429(models::ErrorResponse),
104    Status500(models::ErrorResponse),
105    UnknownValue(serde_json::Value),
106}
107
108
109/// Retrieve all the answers for the scorecards that were reviewed during a specified date range, for calls that took place during a specified date range, for specific scorecards or for specific reviewed users.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:stats:scorecards'.
110pub async fn list_answered_scorecards(configuration: &configuration::Configuration, params: ListAnsweredScorecardsParams) -> Result<models::AnsweredScorecards, Error<ListAnsweredScorecardsError>> {
111    let local_var_configuration = configuration;
112
113    // unbox the parameters
114    let public_api_base_request_v2_answered_scorecards_filter = params.public_api_base_request_v2_answered_scorecards_filter;
115
116
117    let local_var_client = &local_var_configuration.client;
118
119    let local_var_uri_str = format!("{}/v2/stats/activity/scorecards", local_var_configuration.base_path);
120    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
121
122    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
123        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
124    }
125    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
126        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
127    };
128    local_var_req_builder = local_var_req_builder.json(&public_api_base_request_v2_answered_scorecards_filter);
129
130    let local_var_req = local_var_req_builder.build()?;
131    let local_var_resp = local_var_client.execute(local_var_req).await?;
132
133    let local_var_status = local_var_resp.status();
134    let local_var_content = local_var_resp.text().await?;
135
136    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
137        serde_json::from_str(&local_var_content).map_err(Error::from)
138    } else {
139        let local_var_entity: Option<ListAnsweredScorecardsError> = serde_json::from_str(&local_var_content).ok();
140        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
141        Err(Error::ResponseError(local_var_error))
142    }
143}
144
145/// Returns interaction stats for users based on calls that have Whisper turned on.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:stats:interaction'.
146pub async fn list_interaction_stats(configuration: &configuration::Configuration, params: ListInteractionStatsParams) -> Result<models::CompanyUsersIntercationStatsResponse, Error<ListInteractionStatsError>> {
147    let local_var_configuration = configuration;
148
149    // unbox the parameters
150    let public_api_base_request_v2_multiple_users_with_dates = params.public_api_base_request_v2_multiple_users_with_dates;
151
152
153    let local_var_client = &local_var_configuration.client;
154
155    let local_var_uri_str = format!("{}/v2/stats/interaction", local_var_configuration.base_path);
156    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
157
158    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
159        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
160    }
161    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
162        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
163    };
164    local_var_req_builder = local_var_req_builder.json(&public_api_base_request_v2_multiple_users_with_dates);
165
166    let local_var_req = local_var_req_builder.build()?;
167    let local_var_resp = local_var_client.execute(local_var_req).await?;
168
169    let local_var_status = local_var_resp.status();
170    let local_var_content = local_var_resp.text().await?;
171
172    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
173        serde_json::from_str(&local_var_content).map_err(Error::from)
174    } else {
175        let local_var_entity: Option<ListInteractionStatsError> = serde_json::from_str(&local_var_content).ok();
176        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
177        Err(Error::ResponseError(local_var_error))
178    }
179}
180
181/// Lists the activity of multiple users within the Gong system during a defined period. Given the period, this endpoint returns multiple records, one for each user, with an applicable activity during the period. Each record includes statistics about the user's activity.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:stats:user-actions'.
182pub async fn list_multiple_users_aggregate_activity(configuration: &configuration::Configuration, params: ListMultipleUsersAggregateActivityParams) -> Result<models::CompanyUsersAggregateActivityResponse, Error<ListMultipleUsersAggregateActivityError>> {
183    let local_var_configuration = configuration;
184
185    // unbox the parameters
186    let public_api_base_request_v2_multiple_users_with_dates = params.public_api_base_request_v2_multiple_users_with_dates;
187
188
189    let local_var_client = &local_var_configuration.client;
190
191    let local_var_uri_str = format!("{}/v2/stats/activity/aggregate", local_var_configuration.base_path);
192    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
193
194    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
195        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
196    }
197    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
198        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
199    };
200    local_var_req_builder = local_var_req_builder.json(&public_api_base_request_v2_multiple_users_with_dates);
201
202    let local_var_req = local_var_req_builder.build()?;
203    let local_var_resp = local_var_client.execute(local_var_req).await?;
204
205    let local_var_status = local_var_resp.status();
206    let local_var_content = local_var_resp.text().await?;
207
208    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
209        serde_json::from_str(&local_var_content).map_err(Error::from)
210    } else {
211        let local_var_entity: Option<ListMultipleUsersAggregateActivityError> = serde_json::from_str(&local_var_content).ok();
212        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
213        Err(Error::ResponseError(local_var_error))
214    }
215}
216
217/// Lists the aggregated activity of multiple users within the Gong system for each time period within the defined date range. This endpoint returns multiple records, one for each user. For each user there are items for every time period in the date range, including statistics about the user's activity. Records are returned only for users with activity in the range.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:stats:user-actions'.
218pub async fn list_multiple_users_aggregate_by_period(configuration: &configuration::Configuration, params: ListMultipleUsersAggregateByPeriodParams) -> Result<models::UsersAggregateByPeriodActivity, Error<ListMultipleUsersAggregateByPeriodError>> {
219    let local_var_configuration = configuration;
220
221    // unbox the parameters
222    let request_with_time_period = params.request_with_time_period;
223
224
225    let local_var_client = &local_var_configuration.client;
226
227    let local_var_uri_str = format!("{}/v2/stats/activity/aggregate-by-period", local_var_configuration.base_path);
228    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
229
230    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
231        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
232    }
233    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
234        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
235    };
236    local_var_req_builder = local_var_req_builder.json(&request_with_time_period);
237
238    let local_var_req = local_var_req_builder.build()?;
239    let local_var_resp = local_var_client.execute(local_var_req).await?;
240
241    let local_var_status = local_var_resp.status();
242    let local_var_content = local_var_resp.text().await?;
243
244    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
245        serde_json::from_str(&local_var_content).map_err(Error::from)
246    } else {
247        let local_var_entity: Option<ListMultipleUsersAggregateByPeriodError> = serde_json::from_str(&local_var_content).ok();
248        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
249        Err(Error::ResponseError(local_var_error))
250    }
251}
252
253/// Retrieve the daily activity of multiple users within the Gong system for a range of dates. This endpoint returns records including statistics about each user's activity, on the daily level. Records are returned only for users with activity in the range.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:stats:user-actions:detailed'.
254pub async fn list_multiple_users_day_by_day_activity(configuration: &configuration::Configuration, params: ListMultipleUsersDayByDayActivityParams) -> Result<models::UsersDayByDayActivity, Error<ListMultipleUsersDayByDayActivityError>> {
255    let local_var_configuration = configuration;
256
257    // unbox the parameters
258    let public_api_base_request_v2_multiple_users_with_dates = params.public_api_base_request_v2_multiple_users_with_dates;
259
260
261    let local_var_client = &local_var_configuration.client;
262
263    let local_var_uri_str = format!("{}/v2/stats/activity/day-by-day", local_var_configuration.base_path);
264    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
265
266    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
267        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
268    }
269    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
270        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
271    };
272    local_var_req_builder = local_var_req_builder.json(&public_api_base_request_v2_multiple_users_with_dates);
273
274    let local_var_req = local_var_req_builder.build()?;
275    let local_var_resp = local_var_client.execute(local_var_req).await?;
276
277    let local_var_status = local_var_resp.status();
278    let local_var_content = local_var_resp.text().await?;
279
280    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
281        serde_json::from_str(&local_var_content).map_err(Error::from)
282    } else {
283        let local_var_entity: Option<ListMultipleUsersDayByDayActivityError> = serde_json::from_str(&local_var_content).ok();
284        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
285        Err(Error::ResponseError(local_var_error))
286    }
287}
288