Exemplo n.º 1
0
        internal static PNGetUuidMetadataResult GetObject(List <object> listObject)
        {
            PNGetUuidMetadataResult     result        = null;
            Dictionary <string, object> getUserDicObj = (listObject.Count >= 2) ? JsonDataParseInternalUtil.ConvertToDictionaryObject(listObject[1]) : null;

            if (getUserDicObj != null && getUserDicObj.ContainsKey("data"))
            {
                result = new PNGetUuidMetadataResult();

                Dictionary <string, object> userDataDic = JsonDataParseInternalUtil.ConvertToDictionaryObject(getUserDicObj["data"]);
                if (userDataDic != null && userDataDic.Count > 0)
                {
                    var usrData = new PNGetUuidMetadataResult
                    {
                        Uuid       = (userDataDic.ContainsKey("id") && userDataDic["id"] != null) ? userDataDic["id"].ToString() : null,
                        Name       = (userDataDic.ContainsKey("name") && userDataDic["name"] != null) ? userDataDic["name"].ToString() : null,
                        ExternalId = (userDataDic.ContainsKey("externalId") && userDataDic["externalId"] != null) ? userDataDic["externalId"].ToString() : null,
                        ProfileUrl = (userDataDic.ContainsKey("profileUrl") && userDataDic["profileUrl"] != null) ? userDataDic["profileUrl"].ToString() : null,
                        Email      = (userDataDic.ContainsKey("email") && userDataDic["email"] != null) ? userDataDic["email"].ToString() : null,
                        Updated    = (userDataDic.ContainsKey("updated") && userDataDic["updated"] != null) ? userDataDic["updated"].ToString() : null
                    };

                    if (userDataDic.ContainsKey("custom"))
                    {
                        usrData.Custom = JsonDataParseInternalUtil.ConvertToDictionaryObject(userDataDic["custom"]);
                    }
                    result = usrData;
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private async Task <PNResult <PNGetUuidMetadataResult> > GetSingleUuidMetadata(string uuid, bool includeCustom, Dictionary <string, object> externalQueryParam)
        {
            if (string.IsNullOrEmpty(uuid))
            {
                uuid = config.Uuid;
            }
            PNResult <PNGetUuidMetadataResult> ret = new PNResult <PNGetUuidMetadataResult>();

            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null) ? PubnubInstance.InstanceId : "");

            Uri request = urlBuilder.BuildGetSingleUuidMetadataRequest("GET", "", uuid, includeCustom, externalQueryParam);

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

            requestState.ResponseType      = PNOperationType.PNGetUuidMetadataOperation;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            requestState.UsePostMethod = false;
            Tuple <string, PNStatus> JsonAndStatusTuple = await UrlProcessRequest(request, requestState, false).ConfigureAwait(false);

            ret.Status = JsonAndStatusTuple.Item2;
            string json = JsonAndStatusTuple.Item1;

            if (!string.IsNullOrEmpty(json))
            {
                List <object>           resultList      = ProcessJsonResponse(requestState, json);
                ResponseBuilder         responseBuilder = new ResponseBuilder(config, jsonLibrary, pubnubLog);
                PNGetUuidMetadataResult responseResult  = responseBuilder.JsonToObject <PNGetUuidMetadataResult>(resultList, true);
                if (responseResult != null)
                {
                    ret.Result = responseResult;
                }
            }

            return(ret);
        }