예제 #1
0
 public void PostChannel(Channel channel)
 {
     using (var request = new Messaging.Channel.Base()
     {
         DefaultHeaders = new WebHeaderCollection()
         {
             { HttpRequestHeader.Accept, "application/json" },
             { HttpRequestHeader.ContentType, "application/json" },
             { HttpRequestHeader.Authorization, "Token " + Auth.Token }
         }
     }.POST(Parser.EntitytoJSON(channel, typeof(Channel)))) { }
 }
예제 #2
0
        public Channel[] GetAllChannels()
        {
            Cursor <Channel> cursor = new Cursor <Channel>();

            do
            {
                using (var request = new Messaging.Channel.Base()
                {
                    DefaultHeaders = new WebHeaderCollection()
                    {
                        { HttpRequestHeader.Accept, "application/json" },
                        { HttpRequestHeader.ContentType, "application/json" },
                        { HttpRequestHeader.Authorization, "Token " + Auth.Token }
                    }
                }.GET(!string.IsNullOrEmpty(cursor.Next) ? ExtractQueryString(cursor.Next) : null)) {
                    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());
        }
예제 #3
0
        public Cursor <Channel> GetChannels(string page = "1")
        {
            Cursor <Channel> cursor = new Cursor <Channel>();

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

                return(cursor);
            }
        }