Esempio n. 1
0
        /// <summary>
        /// Query organization API Usage -  After calling this method, you will then need to poll for the query results based on the returned execution Id
        /// </summary>
        /// <exception cref="PureCloudPlatform.Client.V2.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Query</param>
        /// <returns>Task of UsageExecutionResult</returns>
        public async System.Threading.Tasks.Task <UsageExecutionResult> PostUsageQueryAsync(ApiUsageQuery body)
        {
            ApiResponse <UsageExecutionResult> localVarResponse = await PostUsageQueryAsyncWithHttpInfo(body);

            return(localVarResponse.Data);
        }
Esempio n. 2
0
        /// <summary>
        /// Query organization API Usage -  After calling this method, you will then need to poll for the query results based on the returned execution Id
        /// </summary>
        /// <exception cref="PureCloudPlatform.Client.V2.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Query</param>
        /// <returns>Task of ApiResponse (UsageExecutionResult)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <UsageExecutionResult> > PostUsageQueryAsyncWithHttpInfo(ApiUsageQuery body)
        {
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling UsageApi->PostUsageQuery");
            }


            var    localVarPath         = "/api/v2/usage/query";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <Tuple <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");

            // Path params

            // Query params

            // Header params

            // Form params

            // Body param
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }
            // authentication (PureCloud OAuth) required
            // oauth required
            if (!String.IsNullOrEmpty(Configuration.AccessToken))
            {
                localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken;
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            Dictionary <string, string> localVarHeaders = localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());

            if (localVarStatusCode >= 400)
            {
                throw new ApiException(localVarStatusCode, "Error calling PostUsageQuery: " + localVarResponse.Content, localVarResponse.Content, localVarHeaders);
            }
            else if (localVarStatusCode == 0)
            {
                throw new ApiException(localVarStatusCode, "Error calling PostUsageQuery: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
            }

            return(new ApiResponse <UsageExecutionResult>(localVarStatusCode,
                                                          localVarHeaders,
                                                          (UsageExecutionResult)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(UsageExecutionResult)),
                                                          localVarResponse.Content,
                                                          localVarResponse.StatusDescription));
        }
Esempio n. 3
0
        /// <summary>
        /// Query organization API Usage -  After calling this method, you will then need to poll for the query results based on the returned execution Id
        /// </summary>
        /// <exception cref="PureCloudPlatform.Client.V2.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Query</param>
        /// <returns>UsageExecutionResult</returns>
        public UsageExecutionResult PostUsageQuery(ApiUsageQuery body)
        {
            ApiResponse <UsageExecutionResult> localVarResponse = PostUsageQueryWithHttpInfo(body);

            return(localVarResponse.Data);
        }