コード例 #1
0
ファイル: Session.cs プロジェクト: mehdi-payday/spherechat
 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
ファイル: Session.cs プロジェクト: mehdi-payday/spherechat
        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
ファイル: Session.cs プロジェクト: mehdi-payday/spherechat
        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);
            }
        }