예제 #1
0
        public Channel[] GetAllChannels(string search = "")
        {
            Cursor <Channel> cursor = new Cursor <Channel>();
            string           page   = "1";

            do
            {
                if (!string.IsNullOrEmpty(cursor.Next))
                {
                    page = ExtractQueryString(cursor.Next)["page"];
                }

                using (var request = new Users.Base()
                {
                    DefaultHeaders = new WebHeaderCollection()
                    {
                        { HttpRequestHeader.Accept, "application/json" },
                        { HttpRequestHeader.ContentType, "application/json" },
                        { HttpRequestHeader.Authorization, "Token " + Auth.Token }
                    }
                }.GET(new Dictionary <string, string>()
                {
                    { "search", search },
                    { "page", page }
                })) {
                    cursor.AddRange((Channel[])Parser.JSONtoEntity(request.Payload, typeof(Channel[])));
                    cursor.Next     = request.Payload.next.ToString();
                    cursor.Previous = request.Payload.previous.ToString();
                }
            } while (!string.IsNullOrEmpty(cursor.Next));
            return(cursor.ToArray());
        }
예제 #2
0
        public Cursor <User> GetUsers(string search = "", string page = "1")
        {
            Cursor <User> cursor = new Cursor <User>();

            using (var request = new Users.Base()
            {
                DefaultHeaders = new WebHeaderCollection()
                {
                    { HttpRequestHeader.Accept, "application/json" },
                    { HttpRequestHeader.ContentType, "application/json" },
                    { HttpRequestHeader.Authorization, "Token " + Auth.Token }
                }
            }.GET(new Dictionary <string, string>()
            {
                { "search", search },
                { "page", page }
            })) {
                cursor.AddRange((User[])Parser.JSONtoEntity(request.Payload, typeof(User[])));
                cursor.Next     = request.Payload.next.ToString();
                cursor.Previous = request.Payload.previous.ToString();

                return(cursor);
            }
        }