Skip to main content

gong_rs/apis/
calls_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 [`add_call`]
18#[derive(Clone, Debug)]
19pub struct AddCallParams {
20    pub new_call_adding_request: models::NewCallAddingRequest
21}
22
23/// struct for passing parameters to the method [`get_call`]
24#[derive(Clone, Debug)]
25pub struct GetCallParams {
26    /// Gong's unique numeric identifier for the call (up to 20 digits).
27    pub id: String
28}
29
30/// struct for passing parameters to the method [`get_call_transcripts`]
31#[derive(Clone, Debug)]
32pub struct GetCallTranscriptsParams {
33    pub public_api_base_request_v2_calls_filter: models::PublicApiBaseRequestV2CallsFilter
34}
35
36/// struct for passing parameters to the method [`list_calls`]
37#[derive(Clone, Debug)]
38pub struct ListCallsParams {
39    /// Date and time (in ISO-8601 format: '2018-02-18T02:30:00-07:00' or '2018-02-18T08:00:00Z', where Z stands for UTC) from which to list recorded calls. Returns calls that started on or after the specified date and time. If not provided, list starts with earliest call. For web-conference calls recorded by Gong, the date denotes its scheduled time, otherwise, it denotes its actual start time.
40    pub from_date_time: String,
41    /// Date and time (in ISO-8601 format: '2018-02-18T02:30:00-07:00' or '2018-02-18T08:00:00Z', where Z stands for UTC) until which to list recorded calls. Returns calls that started up to but excluding specified date and time. If not provided, list ends with most recent call. For web-conference calls recorded by Gong, the date denotes its scheduled time, otherwise, it denotes its actual start time.
42    pub to_date_time: String,
43    /// When paging is needed, provide the value supplied by the previous API call to bring the following page of records.
44    pub cursor: Option<String>,
45    /// Optional Workspace identifier, if supplied the API will return only the calls belonging to this workspace.
46    pub workspace_id: Option<String>
47}
48
49/// struct for passing parameters to the method [`list_calls_extensive`]
50#[derive(Clone, Debug)]
51pub struct ListCallsExtensiveParams {
52    pub public_api_base_request_with_data_v2_calls_request_filter_with_owners_content_selector: models::PublicApiBaseRequestWithDataV2CallsRequestFilterWithOwnersContentSelector
53}
54
55/// struct for passing parameters to the method [`list_crm_calls_manual_association`]
56#[derive(Clone, Debug)]
57pub struct ListCrmCallsManualAssociationParams {
58    /// Association time filter - only the associations made after that time will be listed. The time is in the ISO-8601 format (e.g., '2018-02-18T02:30:00-07:00' or '2018-02-18T08:00:00Z', where Z stands for UTC); if not specified all association events will be listed.
59    pub from_date_time: Option<String>,
60    /// When paging is needed, provide the value supplied by the previous API call to bring the following page of records.
61    pub cursor: Option<String>
62}
63
64
65/// struct for typed errors of method [`add_call`]
66#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum AddCallError {
69    Status400(models::ErrorResponse),
70    Status401(models::ErrorResponse),
71    Status409(models::ErrorResponse),
72    Status429(models::ErrorResponse),
73    Status500(models::ErrorResponse),
74    UnknownValue(serde_json::Value),
75}
76
77/// struct for typed errors of method [`get_call`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum GetCallError {
81    Status400(models::ErrorResponse),
82    Status401(models::ErrorResponse),
83    Status404(models::ErrorResponse),
84    Status429(models::ErrorResponse),
85    Status500(models::ErrorResponse),
86    UnknownValue(serde_json::Value),
87}
88
89/// struct for typed errors of method [`get_call_transcripts`]
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum GetCallTranscriptsError {
93    Status400(models::ErrorResponse),
94    Status401(models::ErrorResponse),
95    Status404(models::ErrorResponse),
96    Status429(models::ErrorResponse),
97    Status500(models::ErrorResponse),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`list_calls`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum ListCallsError {
105    Status400(models::ErrorResponse),
106    Status401(models::ErrorResponse),
107    Status404(models::ErrorResponse),
108    Status429(models::ErrorResponse),
109    Status500(models::ErrorResponse),
110    UnknownValue(serde_json::Value),
111}
112
113/// struct for typed errors of method [`list_calls_extensive`]
114#[derive(Debug, Clone, Serialize, Deserialize)]
115#[serde(untagged)]
116pub enum ListCallsExtensiveError {
117    Status400(models::ErrorResponse),
118    Status401(models::ErrorResponse),
119    Status404(models::ErrorResponse),
120    Status429(models::ErrorResponse),
121    Status500(models::ErrorResponse),
122    UnknownValue(serde_json::Value),
123}
124
125/// struct for typed errors of method [`list_crm_calls_manual_association`]
126#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum ListCrmCallsManualAssociationError {
129    Status400(models::ErrorResponse),
130    Status401(models::ErrorResponse),
131    Status500(models::ErrorResponse),
132    UnknownValue(serde_json::Value),
133}
134
135
136/// When using this endpoint, either provide a downloadMediaUrl or use the returned callId in a follow-up request to /v2/calls/{id}/media to upload the media file.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:calls:create'.
137pub async fn add_call(configuration: &configuration::Configuration, params: AddCallParams) -> Result<models::NewCallAddingResponse, Error<AddCallError>> {
138    let local_var_configuration = configuration;
139
140    // unbox the parameters
141    let new_call_adding_request = params.new_call_adding_request;
142
143
144    let local_var_client = &local_var_configuration.client;
145
146    let local_var_uri_str = format!("{}/v2/calls", local_var_configuration.base_path);
147    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
148
149    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
150        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
151    }
152    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
153        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
154    };
155    local_var_req_builder = local_var_req_builder.json(&new_call_adding_request);
156
157    let local_var_req = local_var_req_builder.build()?;
158    let local_var_resp = local_var_client.execute(local_var_req).await?;
159
160    let local_var_status = local_var_resp.status();
161    let local_var_content = local_var_resp.text().await?;
162
163    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
164        serde_json::from_str(&local_var_content).map_err(Error::from)
165    } else {
166        let local_var_entity: Option<AddCallError> = serde_json::from_str(&local_var_content).ok();
167        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
168        Err(Error::ResponseError(local_var_error))
169    }
170}
171
172/// Retrieve data for a specific call.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:calls:read:basic'.
173pub async fn get_call(configuration: &configuration::Configuration, params: GetCallParams) -> Result<models::SpecificCall, Error<GetCallError>> {
174    let local_var_configuration = configuration;
175
176    // unbox the parameters
177    let id = params.id;
178
179
180    let local_var_client = &local_var_configuration.client;
181
182    let local_var_uri_str = format!("{}/v2/calls/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
183    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
184
185    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
186        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
187    }
188    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
189        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
190    };
191
192    let local_var_req = local_var_req_builder.build()?;
193    let local_var_resp = local_var_client.execute(local_var_req).await?;
194
195    let local_var_status = local_var_resp.status();
196    let local_var_content = local_var_resp.text().await?;
197
198    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
199        serde_json::from_str(&local_var_content).map_err(Error::from)
200    } else {
201        let local_var_entity: Option<GetCallError> = serde_json::from_str(&local_var_content).ok();
202        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
203        Err(Error::ResponseError(local_var_error))
204    }
205}
206
207/// Returns transcripts for calls that took place during the specified date period. If call IDs are specified, only transcripts for calls with those IDs that took place during the time period are returned.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:calls:read:transcript'.
208pub async fn get_call_transcripts(configuration: &configuration::Configuration, params: GetCallTranscriptsParams) -> Result<models::CallTranscripts, Error<GetCallTranscriptsError>> {
209    let local_var_configuration = configuration;
210
211    // unbox the parameters
212    let public_api_base_request_v2_calls_filter = params.public_api_base_request_v2_calls_filter;
213
214
215    let local_var_client = &local_var_configuration.client;
216
217    let local_var_uri_str = format!("{}/v2/calls/transcript", local_var_configuration.base_path);
218    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
219
220    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
221        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
222    }
223    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
224        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
225    };
226    local_var_req_builder = local_var_req_builder.json(&public_api_base_request_v2_calls_filter);
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<GetCallTranscriptsError> = 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
243/// List calls that took place during a specified date range.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:calls:read:basic'.
244pub async fn list_calls(configuration: &configuration::Configuration, params: ListCallsParams) -> Result<models::CallsResponse, Error<ListCallsError>> {
245    let local_var_configuration = configuration;
246
247    // unbox the parameters
248    let from_date_time = params.from_date_time;
249    let to_date_time = params.to_date_time;
250    let cursor = params.cursor;
251    let workspace_id = params.workspace_id;
252
253
254    let local_var_client = &local_var_configuration.client;
255
256    let local_var_uri_str = format!("{}/v2/calls", local_var_configuration.base_path);
257    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
258
259    if let Some(ref local_var_str) = cursor {
260        local_var_req_builder = local_var_req_builder.query(&[("cursor", &local_var_str.to_string())]);
261    }
262    local_var_req_builder = local_var_req_builder.query(&[("fromDateTime", &from_date_time.to_string())]);
263    local_var_req_builder = local_var_req_builder.query(&[("toDateTime", &to_date_time.to_string())]);
264    if let Some(ref local_var_str) = workspace_id {
265        local_var_req_builder = local_var_req_builder.query(&[("workspaceId", &local_var_str.to_string())]);
266    }
267    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
268        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
269    }
270    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
271        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
272    };
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<ListCallsError> = 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
289/// Lists detailed call data for calls that took place during a specified date range, have specified call IDs or hosted by specified users.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:calls:read:extensive'.  Moreover, clients requesting media download URLs by the contentSelector.exposedFields.media field should also have the scope 'api:calls:read:media-url'.
290pub async fn list_calls_extensive(configuration: &configuration::Configuration, params: ListCallsExtensiveParams) -> Result<models::Calls, Error<ListCallsExtensiveError>> {
291    let local_var_configuration = configuration;
292
293    // unbox the parameters
294    let public_api_base_request_with_data_v2_calls_request_filter_with_owners_content_selector = params.public_api_base_request_with_data_v2_calls_request_filter_with_owners_content_selector;
295
296
297    let local_var_client = &local_var_configuration.client;
298
299    let local_var_uri_str = format!("{}/v2/calls/extensive", local_var_configuration.base_path);
300    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
301
302    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
303        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
304    }
305    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
306        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
307    };
308    local_var_req_builder = local_var_req_builder.json(&public_api_base_request_with_data_v2_calls_request_filter_with_owners_content_selector);
309
310    let local_var_req = local_var_req_builder.build()?;
311    let local_var_resp = local_var_client.execute(local_var_req).await?;
312
313    let local_var_status = local_var_resp.status();
314    let local_var_content = local_var_resp.text().await?;
315
316    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
317        serde_json::from_str(&local_var_content).map_err(Error::from)
318    } else {
319        let local_var_entity: Option<ListCallsExtensiveError> = serde_json::from_str(&local_var_content).ok();
320        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
321        Err(Error::ResponseError(local_var_error))
322    }
323}
324
325/// Returns a list of all calls that were manually associated or re-associated with CRM account and deal/opportunity since a given time.  Actions will be listed in the ascending order of their timing.   Notice if a call was associated and later re-associated the API will return both events.  When accessed through a Bearer token authorization method, this endpoint requires the scope 'api:crm-calls:manual-association:read'.
326pub async fn list_crm_calls_manual_association(configuration: &configuration::Configuration, params: ListCrmCallsManualAssociationParams) -> Result<models::ManualAssociationResponse, Error<ListCrmCallsManualAssociationError>> {
327    let local_var_configuration = configuration;
328
329    // unbox the parameters
330    let from_date_time = params.from_date_time;
331    let cursor = params.cursor;
332
333
334    let local_var_client = &local_var_configuration.client;
335
336    let local_var_uri_str = format!("{}/v2/calls/manual-crm-associations", local_var_configuration.base_path);
337    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
338
339    if let Some(ref local_var_str) = from_date_time {
340        local_var_req_builder = local_var_req_builder.query(&[("fromDateTime", &local_var_str.to_string())]);
341    }
342    if let Some(ref local_var_str) = cursor {
343        local_var_req_builder = local_var_req_builder.query(&[("cursor", &local_var_str.to_string())]);
344    }
345    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
346        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
347    }
348    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
349        local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned());
350    };
351
352    let local_var_req = local_var_req_builder.build()?;
353    let local_var_resp = local_var_client.execute(local_var_req).await?;
354
355    let local_var_status = local_var_resp.status();
356    let local_var_content = local_var_resp.text().await?;
357
358    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
359        serde_json::from_str(&local_var_content).map_err(Error::from)
360    } else {
361        let local_var_entity: Option<ListCrmCallsManualAssociationError> = serde_json::from_str(&local_var_content).ok();
362        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
363        Err(Error::ResponseError(local_var_error))
364    }
365}
366