Ejemplo n.º 1
0
        public static TestNotificationRequest ToNotificationDto(this NotificationBase notification)
        {
            var result = new TestNotificationRequest
            {
                Language               = notification.Language.CultureName,
                ObjectId               = notification.StoreId,
                ObjectTypeId           = "Store",
                Type                   = notification.Type,
                NotificationParameters = notification.GetNotificationParameters().Select(x => new NotificationParameter {
                    Type = "String", Value = x.Value, ParameterName = x.Key
                }).ToList()
            };

            return(result);
        }
        /// <summary>
        /// Sending test notification Method sending notification, that based on notification template. Template for rendering chosen by type, objectId, objectTypeId, language.              Parameters for template may be prepared by the method of getTestingParameters. Method returns string. If sending finished with success status              this string is empty, otherwise string contains error message.
        /// </summary>
        /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request">Test notification request</param>
        /// <returns>Task of ApiResponse (string)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<string>> NotificationsSendNotificationAsyncWithHttpInfo(TestNotificationRequest request)
        {
            // verify the required parameter 'request' is set
            if (request == null)
                throw new ApiException(400, "Missing required parameter 'request' when calling VirtoCommercePlatformApi->NotificationsSendNotification");

            var localVarPath = "/api/platform/notification/template/sendnotification";
            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", 
                "text/json", 
                "application/xml", 
                "text/xml", 
                "application/x-www-form-urlencoded"
            };
            string localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            string[] localVarHttpHeaderAccepts = new string[] {
                "application/json", 
                "text/json", 
                "application/xml", 
                "text/xml"
            };
            string localVarHttpHeaderAccept = 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 (request.GetType() != typeof(byte[]))
            {
                localVarPostBody = ApiClient.Serialize(request); // http body (model) parameter
            }
            else
            {
                localVarPostBody = request; // byte array
            }


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

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404))
                throw new ApiException(localVarStatusCode, "Error calling NotificationsSendNotification: " + localVarResponse.Content, localVarResponse.Content);
            else if (localVarStatusCode == 0)
                throw new ApiException(localVarStatusCode, "Error calling NotificationsSendNotification: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);

            return new ApiResponse<string>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (string)ApiClient.Deserialize(localVarResponse, typeof(string)));
            
        }
        /// <summary>
        /// Sending test notification Method sending notification, that based on notification template. Template for rendering chosen by type, objectId, objectTypeId, language.              Parameters for template may be prepared by the method of getTestingParameters. Method returns string. If sending finished with success status              this string is empty, otherwise string contains error message.
        /// </summary>
        /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request">Test notification request</param>
        /// <returns>Task of string</returns>
        public async System.Threading.Tasks.Task<string> NotificationsSendNotificationAsync(TestNotificationRequest request)
        {
             ApiResponse<string> localVarResponse = await NotificationsSendNotificationAsyncWithHttpInfo(request);
             return localVarResponse.Data;

        }
 /// <summary>
 /// Sending test notification Method sending notification, that based on notification template. Template for rendering chosen by type, objectId, objectTypeId, language.              Parameters for template may be prepared by the method of getTestingParameters. Method returns string. If sending finished with success status              this string is empty, otherwise string contains error message.
 /// </summary>
 /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="request">Test notification request</param>
 /// <returns>string</returns>
 public string NotificationsSendNotification(TestNotificationRequest request)
 {
      ApiResponse<string> localVarResponse = NotificationsSendNotificationWithHttpInfo(request);
      return localVarResponse.Data;
 }
        /// <summary>
        /// Get rendered notification content Method returns rendered content, that based on notification template. Template for rendering chosen by type, objectId, objectTypeId, language.              Parameters for template may be prepared by the method of getTestingParameters.
        /// </summary>
        /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request">Test notification request</param>
        /// <returns>Task of RenderNotificationContentResult</returns>
        public async System.Threading.Tasks.Task<RenderNotificationContentResult> NotificationsRenderNotificationContentAsync(TestNotificationRequest request)
        {
             ApiResponse<RenderNotificationContentResult> localVarResponse = await NotificationsRenderNotificationContentAsyncWithHttpInfo(request);
             return localVarResponse.Data;

        }
 /// <summary>
 /// Get rendered notification content Method returns rendered content, that based on notification template. Template for rendering chosen by type, objectId, objectTypeId, language.              Parameters for template may be prepared by the method of getTestingParameters.
 /// </summary>
 /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="request">Test notification request</param>
 /// <returns>RenderNotificationContentResult</returns>
 public RenderNotificationContentResult NotificationsRenderNotificationContent(TestNotificationRequest request)
 {
      ApiResponse<RenderNotificationContentResult> localVarResponse = NotificationsRenderNotificationContentWithHttpInfo(request);
      return localVarResponse.Data;
 }