/// <summary> /// Create Rule Create a new Rule /// </summary> /// <exception cref="CLOUD.Artik.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="ruleInfo">Rule object that needs to be added</param> /// <param name="userId">User ID</param> /// <returns>Task of RuleEnvelope</returns> public async System.Threading.Tasks.Task <RuleEnvelope> CreateRuleAsync(RuleCreationInfo ruleInfo, string userId) { ApiResponse <RuleEnvelope> localVarResponse = await CreateRuleAsyncWithHttpInfo(ruleInfo, userId); return(localVarResponse.Data); }
/// <summary> /// Create Rule Create a new Rule /// </summary> /// <exception cref="CLOUD.Artik.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="ruleInfo">Rule object that needs to be added</param> /// <param name="userId">User ID</param> /// <returns>Task of ApiResponse (RuleEnvelope)</returns> public async System.Threading.Tasks.Task <ApiResponse <RuleEnvelope> > CreateRuleAsyncWithHttpInfo(RuleCreationInfo ruleInfo, string userId) { // verify the required parameter 'ruleInfo' is set if (ruleInfo == null) { throw new ApiException(400, "Missing required parameter 'ruleInfo' when calling RulesApi->CreateRule"); } // verify the required parameter 'userId' is set if (userId == null) { throw new ApiException(400, "Missing required parameter 'userId' when calling RulesApi->CreateRule"); } var localVarPath = "/rules"; 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[] { }; 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 (userId != null) { localVarQueryParams.Add("userId", Configuration.ApiClient.ParameterToString(userId)); // query parameter } if (ruleInfo != null && ruleInfo.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(ruleInfo); // http body (model) parameter } else { localVarPostBody = ruleInfo; // byte array } // authentication (artikcloud_oauth) required // oauth required if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; } // 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 (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreateRule", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <RuleEnvelope>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (RuleEnvelope)Configuration.ApiClient.Deserialize(localVarResponse, typeof(RuleEnvelope)))); }
/// <summary> /// Create Rule Create a new Rule /// </summary> /// <exception cref="CLOUD.Artik.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="ruleInfo">Rule object that needs to be added</param> /// <param name="userId">User ID</param> /// <returns>RuleEnvelope</returns> public RuleEnvelope CreateRule(RuleCreationInfo ruleInfo, string userId) { ApiResponse <RuleEnvelope> localVarResponse = CreateRuleWithHttpInfo(ruleInfo, userId); return(localVarResponse.Data); }