Beispiel #1
0
        static async Task TestAccounts(SpeckleApiClient myClient)
        {
            Console.WriteLine();
            try
            {
                Console.WriteLine("Logging in a user.");
                var Response = await myClient.UserLoginAsync(new User()
                {
                    Email = "*****@*****.**", Password = "******"
                });

                Console.WriteLine("OK Got user: "******"Registering user." );
            //try
            //{
            //  var Response = await myClient.UserRegisterAsync( new User() { Name = "Dim", Email = DateTime.Now.ToString() + "*****@*****.**", Password = "******" } );
            //  Console.WriteLine( "OK Results:: " + Response.Resource.ToJson() );
            //}
            //catch ( Exception e )
            //{
            //  Console.WriteLine( e.Message );
            //}

            Console.WriteLine();
            Console.WriteLine("Searching for some users.");
            try
            {
                var Response = await myClient.UserSearchAsync(new User()
                {
                    Email = "testing.com"
                });

                Console.WriteLine("OK Results:: " + Response.Resources.Count);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            Console.WriteLine();
            Console.WriteLine("Getting profile.");
            try
            {
                var Response = await myClient.UserGetAsync();

                Console.WriteLine("OK Results:: " + Response.Resource.Email);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            Console.WriteLine();
            Console.WriteLine("Updating profile.");
            try
            {
                var Response = await myClient.UserUpdateProfileAsync(new User()
                {
                    Company = "BARARARA"
                });

                Console.WriteLine("OK Results:: " + Response.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            string userId = "lol";

            Console.WriteLine();
            Console.WriteLine("Getting profile.");
            try
            {
                var Response = await myClient.UserGetAsync(); userId = Response.Resource._id;
                Console.WriteLine("OK Results:: " + Response.Resource.Company);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            Console.WriteLine();
            Console.WriteLine("Getting profile by id.");
            try
            {
                var Response = await myClient.UserGetProfileByIdAsync(userId);

                Console.WriteLine("OK Results:: " + Response.Resource.Company);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }