/// <summary>
        /// PROVISIONAL -  Share a piece of content into Symphony Given a 3rd party content (eg. news article), it can share to the given stream.\nThe stream can be a chatroom, an IM or a multiparty IM.\n
        /// </summary>
        /// <exception cref="SymphonyOSS.RestApiClient.Generated.OpenApi.AgentApi.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="sid">Stream ID</param>
        /// <param name="sessionToken">Session authentication token.</param>
        /// <param name="shareContent"></param>
        /// <param name="keyManagerToken">Key Manager authentication token. (optional)</param>
        /// <returns>Task of ApiResponse (V2Message)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <V2Message> > V3StreamSidSharePostAsyncWithHttpInfo(string sid, string sessionToken, ShareContent shareContent, string keyManagerToken = null)
        {
            // verify the required parameter 'sid' is set
            if (sid == null)
            {
                throw new ApiException(400, "Missing required parameter 'sid' when calling ShareApi->V3StreamSidSharePost");
            }
            // verify the required parameter 'sessionToken' is set
            if (sessionToken == null)
            {
                throw new ApiException(400, "Missing required parameter 'sessionToken' when calling ShareApi->V3StreamSidSharePost");
            }
            // verify the required parameter 'shareContent' is set
            if (shareContent == null)
            {
                throw new ApiException(400, "Missing required parameter 'shareContent' when calling ShareApi->V3StreamSidSharePost");
            }

            var    localVarPath         = "/v3/stream/{sid}/share";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <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 = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = 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");
            if (sid != null)
            {
                localVarPathParams.Add("sid", Configuration.ApiClient.ParameterToString(sid));              // path parameter
            }
            if (sessionToken != null)
            {
                localVarHeaderParams.Add("sessionToken", Configuration.ApiClient.ParameterToString(sessionToken));                       // header parameter
            }
            if (keyManagerToken != null)
            {
                localVarHeaderParams.Add("keyManagerToken", Configuration.ApiClient.ParameterToString(keyManagerToken));                          // header parameter
            }
            if (shareContent.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(shareContent); // http body (model) parameter
            }
            else
            {
                localVarPostBody = shareContent; // byte array
            }


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

            int localVarStatusCode = (int)localVarResponse.StatusCode;

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

            return(new ApiResponse <V2Message>(localVarStatusCode,
                                               localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                               (V2Message)Configuration.ApiClient.Deserialize(localVarResponse, typeof(V2Message))));
        }
Exemple #2
0
        /// <summary>
        /// PROVISIONAL -  Share a piece of content into Symphony Given a 3rd party content (eg. news article), it can share to the given stream. The stream can be a chatroom, an IM or a multiparty IM.
        /// </summary>
        /// <exception cref="SymphonyOSS.RestApiClient.Generated.OpenApi.AgentApi.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="sid">Stream ID</param>
        /// <param name="sessionToken">Session authentication token.</param>
        /// <param name="shareContent"></param>
        /// <param name="keyManagerToken">Key Manager authentication token. (optional)</param>
        /// <returns>ApiResponse of V2Message</returns>
        public ApiResponse <V2Message> V3StreamSidSharePostWithHttpInfo(string sid, string sessionToken, ShareContent shareContent, string keyManagerToken = null)
        {
            // verify the required parameter 'sid' is set
            if (sid == null)
            {
                throw new ApiException(400, "Missing required parameter 'sid' when calling ShareApi->V3StreamSidSharePost");
            }
            // verify the required parameter 'sessionToken' is set
            if (sessionToken == null)
            {
                throw new ApiException(400, "Missing required parameter 'sessionToken' when calling ShareApi->V3StreamSidSharePost");
            }
            // verify the required parameter 'shareContent' is set
            if (shareContent == null)
            {
                throw new ApiException(400, "Missing required parameter 'shareContent' when calling ShareApi->V3StreamSidSharePost");
            }

            var    localVarPath         = "./v3/stream/{sid}/share";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <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 = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

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

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

            if (sid != null)
            {
                localVarPathParams.Add("sid", Configuration.ApiClient.ParameterToString(sid));              // path parameter
            }
            if (sessionToken != null)
            {
                localVarHeaderParams.Add("sessionToken", Configuration.ApiClient.ParameterToString(sessionToken));                       // header parameter
            }
            if (keyManagerToken != null)
            {
                localVarHeaderParams.Add("keyManagerToken", Configuration.ApiClient.ParameterToString(keyManagerToken));                          // header parameter
            }
            if (shareContent != null && shareContent.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(shareContent); // http body (model) parameter
            }
            else
            {
                localVarPostBody = shareContent; // byte array
            }


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

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("V3StreamSidSharePost", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <V2Message>(localVarStatusCode,
                                               localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()),
                                               (V2Message)Configuration.ApiClient.Deserialize(localVarResponse, typeof(V2Message))));
        }