Esempio n. 1
0
        public async Task <ExportedUser> Export(string id)
        {
            var request  = this._client.BuildAppRequest(Users.Endpoint(id) + "/export", HttpMethod.GET);
            var response = await this._client.MakeRequest(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(ExportedUser.FromJObject(JObject.Parse(response.Content)));
            }

            throw StreamChatException.FromResponse(response);
        }
Esempio n. 2
0
        internal static ExportedUser FromJObject(JObject jObj)
        {
            var result = new ExportedUser();
            var data   = JsonHelpers.FromJObject(result, jObj);

            var userObj = data.GetData <JObject>("user");

            if (userObj != null)
            {
                result.User = User.FromJObject(userObj);
            }

            var reacts = data.GetData <JArray>("reactions");

            if (reacts != null)
            {
                var reactions = new List <Reaction>();
                foreach (var reaction in reacts)
                {
                    var reactionObj = reaction as JObject;
                    reactions.Add(Reaction.FromJObject(reactionObj));
                }
                result.Reactions = reactions;
            }

            var msgs = data.GetData <JArray>("messages");

            if (msgs != null)
            {
                var messages = new List <Message>();
                foreach (var msg in msgs)
                {
                    var msgObj = msg as JObject;
                    messages.Add(Message.FromJObject(msgObj));
                }
                result.Messages = messages;
            }

            return(result);
        }