Esempio n. 1
0
        private void DeleteUser(string userId, Dictionary <string, object> externalQueryParam, PNCallback <PNDeleteUserResult> callback)
        {
            if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(userId.Trim()))
            {
                throw new ArgumentException("Missing Id");
            }

            if (string.IsNullOrEmpty(config.SubscribeKey) || string.IsNullOrEmpty(config.SubscribeKey.Trim()) || config.SubscribeKey.Length <= 0)
            {
                throw new MissingMemberException("Invalid Subscribe key");
            }

            if (callback == null)
            {
                throw new ArgumentException("Missing userCallback");
            }


            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr);

            urlBuilder.PubnubInstanceId = (PubnubInstance != null) ? PubnubInstance.InstanceId : "";
            Uri request = urlBuilder.BuildDeleteUserRequest(userId, externalQueryParam);

            RequestState <PNDeleteUserResult> requestState = new RequestState <PNDeleteUserResult>();

            requestState.ResponseType      = PNOperationType.PNDeleteUserOperation;
            requestState.PubnubCallback    = callback;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            string json = "";

            json = UrlProcessRequest <PNDeleteUserResult>(request, requestState, false);

            if (!string.IsNullOrEmpty(json))
            {
                List <object> result = ProcessJsonResponse <PNDeleteUserResult>(requestState, json);
                ProcessResponseCallbacks(result, requestState);
            }
        }