gong_rs/apis/library_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 <token></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(<accessKey> : <accessKeySecret>)</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 <token></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_calls_in_specific_folder`]
18#[derive(Clone, Debug)]
19pub struct GetCallsInSpecificFolderParams {
20 /// Gong's unique numeric identifier for the folder (up to 20 digits).
21 pub folder_id: Option<String>
22}
23
24/// struct for passing parameters to the method [`get_library_structure`]
25#[derive(Clone, Debug)]
26pub struct GetLibraryStructureParams {
27 /// Workspace identifier. We will retrieve folders which are related to this specific workspace.
28 pub workspace_id: Option<String>
29}
30
31
32/// struct for typed errors of method [`get_calls_in_specific_folder`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetCallsInSpecificFolderError {
36 Status400(models::ErrorResponse),
37 Status401(models::ErrorResponse),
38 Status404(models::ErrorResponse),
39 Status429(models::ErrorResponse),
40 Status500(models::ErrorResponse),
41 UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`get_library_structure`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum GetLibraryStructureError {
48 Status400(models::ErrorResponse),
49 Status401(models::ErrorResponse),
50 Status404(models::ErrorResponse),
51 Status429(models::ErrorResponse),
52 Status500(models::ErrorResponse),
53 UnknownValue(serde_json::Value),
54}
55
56
57/// Given a folder id, this endpoint retrieves a list of calls in it. When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:library:read'.
58pub async fn get_calls_in_specific_folder(configuration: &configuration::Configuration, params: GetCallsInSpecificFolderParams) -> Result<models::LibraryFolderListOfCallsResponse, Error<GetCallsInSpecificFolderError>> {
59 let local_var_configuration = configuration;
60
61 // unbox the parameters
62 let folder_id = params.folder_id;
63
64
65 let local_var_client = &local_var_configuration.client;
66
67 let local_var_uri_str = format!("{}/v2/library/folder-content", local_var_configuration.base_path);
68 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
69
70 if let Some(ref local_var_str) = folder_id {
71 local_var_req_builder = local_var_req_builder.query(&[("folderId", &local_var_str.to_string())]);
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<GetCallsInSpecificFolderError> = 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/// Use this endpoint to retrieve a list of public library folders. We do not allow retrieval of either private or archived folders. When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:library:read'.
96pub async fn get_library_structure(configuration: &configuration::Configuration, params: GetLibraryStructureParams) -> Result<models::LibraryResponse, Error<GetLibraryStructureError>> {
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/library/folders", 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<GetLibraryStructureError> = 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