コード例 #1
0
        public Promise <AuthResponse> Auth(Auth model)
        {
            string url = string.Format("http://my.api.com/api/auth");

            return(FakeHttpClient.Post <Auth, AuthResponse>(url, model, fakeResponse: () => new AuthResponse {
                UserId = 150, DisplayName = "Chiko", Token = "Chiko::150"
            })
                   .Then(delegate(AuthResponse x)
            {
                AuthResponse auth = x;
                return auth;       // By doing this you will be returning - Promise<User>
            }));                   //NOTE: USE THE ONE BELOW INSTEAD! This is just for showing purposes only.
            //.Then(x => x.Content);
        }
コード例 #2
0
        public Promise <User> Get(int id)
        {
            string url = string.Format("http://my.api.com/api/user/{0}", id);

            return(FakeHttpClient.Get <User>(url, fakeResponse: () => new User {
                Id = 150, Name = "Stephen", Score = 1337, Level = "LevelAwesome"
            })
                   .Then(delegate(User x)
            {
                User user = x;
                //throw new PingException("TROLOL");
                return user;       // By doing this you will be returning - Promise<User>
            }));                   //NOTE: USE THE ONE BELOW INSTEAD! This is just for showing purposes only.
            //.Then(x => x.Content);
        }