Пример #1
0
        /// <summary>
        /// Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with the customer ID.
        /// You associate a customer ID with data by passing the X-Watson-Metadata header with a request that passes data.
        /// For more information about personal data and customer IDs, see [**Information security**](https://cloud.ibm.com/docs/services/discovery/information-security.html).
        /// </summary>
        /// <param name="successCallback">The function that is called when the operation is successful.</param>
        /// <param name="failCallback">The function that is called when the operation fails.</param>
        /// <param name="customerId">The customer ID for which all data is to be deleted.</param>
        /// <returns><see cref="object" />object</returns>
        /// <param name="customData">A Dictionary<string, object> of data that will be passed to the callback. The raw json output from the REST call will be passed in this object as the value of the 'json' key.</string></param>
        public bool DeleteUserData(SuccessCallback <object> successCallback, FailCallback failCallback, string customerId, Dictionary <string, object> customData = null)
        {
            if (successCallback == null)
            {
                throw new ArgumentNullException("successCallback");
            }
            if (failCallback == null)
            {
                throw new ArgumentNullException("failCallback");
            }
            if (string.IsNullOrEmpty(customerId))
            {
                throw new ArgumentNullException("customerId");
            }

            DeleteUserDataRequestObj req = new DeleteUserDataRequestObj();

            req.SuccessCallback        = successCallback;
            req.FailCallback           = failCallback;
            req.HttpMethod             = UnityWebRequest.kHttpVerbDELETE;
            req.DisableSslVerification = DisableSslVerification;
            req.CustomData             = customData == null ? new Dictionary <string, object>() : customData;
            if (req.CustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS))
            {
                foreach (KeyValuePair <string, string> kvp in req.CustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary <string, string> )
                {
                    req.Headers.Add(kvp.Key, kvp.Value);
                }
            }
            req.Parameters["customer_id"] = customerId;
            req.Parameters["version"]     = VersionDate;

            req.OnResponse = OnDeleteUserDataResponse;
            req.Headers["X-IBMCloud-SDK-Analytics"] = "service_name=conversation;service_version=v1;operation_id=DeleteUserData";

            RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/user_data");

            if (connector == null)
            {
                return(false);
            }

            return(connector.Send(req));
        }
Пример #2
0
        /// <summary>
        /// Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with the customer ID.
        /// You associate a customer ID with data by passing the X-Watson-Metadata header with a request that passes data.
        /// For more information about personal data and customer IDs, see [**Information security**](https://console.bluemix.net/docs/services/discovery/information-security.html).
        /// </summary>
        /// <param name="successCallback">The function that is called when the operation is successful.</param>
        /// <param name="failCallback">The function that is called when the operation fails.</param>
        /// <param name="customerId">The customer ID for which all data is to be deleted.</param>
        /// <returns><see cref="object" />object</returns>
        /// <param name="customData">A Dictionary<string, object> of data that will be passed to the callback. The raw json output from the REST call will be passed in this object as the value of the 'json' key.</string></param>
        public bool DeleteUserData(SuccessCallback <object> successCallback, FailCallback failCallback, string customerId, Dictionary <string, object> customData = null)
        {
            if (successCallback == null)
            {
                throw new ArgumentNullException("successCallback");
            }
            if (failCallback == null)
            {
                throw new ArgumentNullException("failCallback");
            }
            if (string.IsNullOrEmpty(customerId))
            {
                throw new ArgumentNullException("customerId");
            }

            DeleteUserDataRequestObj req = new DeleteUserDataRequestObj();

            req.SuccessCallback = successCallback;
            req.FailCallback    = failCallback;
            req.CustomData      = customData == null ? new Dictionary <string, object>() : customData;
            if (req.CustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS))
            {
                foreach (KeyValuePair <string, string> kvp in req.CustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary <string, string> )
                {
                    req.Headers.Add(kvp.Key, kvp.Value);
                }
            }
            req.Parameters["customer_id"] = customerId;
            req.Parameters["version"]     = VersionDate;
            req.Delete = true;

            req.OnResponse = OnDeleteUserDataResponse;

            RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/user_data");

            if (connector == null)
            {
                return(false);
            }

            return(connector.Send(req));
        }