Skip to main content

gong_rs/apis/
settings_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_trackers`]
18#[derive(Clone, Debug)]
19pub struct ListTrackersParams {
20    /// The ID of the workspace the keyword trackers are in. When empty, all trackers in all workspaces are returned.
21    pub workspace_id: Option<String>
22}
23
24
25/// struct for typed errors of method [`list_scorecards`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum ListScorecardsError {
29    Status400(models::ErrorResponse),
30    Status401(models::ErrorResponse),
31    Status404(models::ErrorResponse),
32    Status429(models::ErrorResponse),
33    Status500(models::ErrorResponse),
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`list_trackers`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum ListTrackersError {
41    Status400(models::ErrorResponse),
42    Status401(models::ErrorResponse),
43    Status404(models::ErrorResponse),
44    Status429(models::ErrorResponse),
45    Status500(models::ErrorResponse),
46    UnknownValue(serde_json::Value),
47}
48
49/// struct for typed errors of method [`list_workspaces`]
50#[derive(Debug, Clone, Serialize, Deserialize)]
51#[serde(untagged)]
52pub enum ListWorkspacesError {
53    Status400(models::ErrorResponse),
54    Status403(models::ErrorResponse),
55    Status429(models::ErrorResponse),
56    Status500(models::ErrorResponse),
57    UnknownValue(serde_json::Value),
58}
59
60
61/// Retrieve all the scorecards within the Gong system.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:settings:scorecards:read'.
62pub async fn list_scorecards(configuration: &configuration::Configuration) -> Result<models::Scorecards, Error<ListScorecardsError>> {
63    let local_var_configuration = configuration;
64
65    // unbox the parameters
66
67
68    let local_var_client = &local_var_configuration.client;
69
70    let local_var_uri_str = format!("{}/v2/settings/scorecards", local_var_configuration.base_path);
71    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
72
73    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
74        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
75    }
76    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
77        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
78    };
79
80    let local_var_req = local_var_req_builder.build()?;
81    let local_var_resp = local_var_client.execute(local_var_req).await?;
82
83    let local_var_status = local_var_resp.status();
84    let local_var_content = local_var_resp.text().await?;
85
86    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
87        serde_json::from_str(&local_var_content).map_err(Error::from)
88    } else {
89        let local_var_entity: Option<ListScorecardsError> = serde_json::from_str(&local_var_content).ok();
90        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
91        Err(Error::ResponseError(local_var_error))
92    }
93}
94
95/// Retrieves details of all keyword trackers in the system or in a given workspace.  When accessed through a Bearer token authorization method, this endpoint requires the  'api:settings:trackers:read' scope.
96pub async fn list_trackers(configuration: &configuration::Configuration, params: ListTrackersParams) -> Result<models::Trackers, Error<ListTrackersError>> {
97    let local_var_configuration = configuration;
98
99    // unbox the parameters
100    let workspace_id = params.workspace_id;
101
102
103    let local_var_client = &local_var_configuration.client;
104
105    let local_var_uri_str = format!("{}/v2/settings/trackers", local_var_configuration.base_path);
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_str) = workspace_id {
109        local_var_req_builder = local_var_req_builder.query(&[("workspaceId", &local_var_str.to_string())]);
110    }
111    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
112        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
113    }
114    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
115        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
116    };
117
118    let local_var_req = local_var_req_builder.build()?;
119    let local_var_resp = local_var_client.execute(local_var_req).await?;
120
121    let local_var_status = local_var_resp.status();
122    let local_var_content = local_var_resp.text().await?;
123
124    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
125        serde_json::from_str(&local_var_content).map_err(Error::from)
126    } else {
127        let local_var_entity: Option<ListTrackersError> = serde_json::from_str(&local_var_content).ok();
128        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
129        Err(Error::ResponseError(local_var_error))
130    }
131}
132
133/// Returns a list of all workspaces including their details.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:workspaces:read'.
134pub async fn list_workspaces(configuration: &configuration::Configuration) -> Result<models::WorkspacesMetadata, Error<ListWorkspacesError>> {
135    let local_var_configuration = configuration;
136
137    // unbox the parameters
138
139
140    let local_var_client = &local_var_configuration.client;
141
142    let local_var_uri_str = format!("{}/v2/workspaces", local_var_configuration.base_path);
143    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
144
145    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
146        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
147    }
148    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
149        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
150    };
151
152    let local_var_req = local_var_req_builder.build()?;
153    let local_var_resp = local_var_client.execute(local_var_req).await?;
154
155    let local_var_status = local_var_resp.status();
156    let local_var_content = local_var_resp.text().await?;
157
158    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
159        serde_json::from_str(&local_var_content).map_err(Error::from)
160    } else {
161        let local_var_entity: Option<ListWorkspacesError> = serde_json::from_str(&local_var_content).ok();
162        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
163        Err(Error::ResponseError(local_var_error))
164    }
165}
166