Exemplo n.º 1
0
        static async Task TestClients(SpeckleApiClient myClient)
        {
            string clientId = "lol";

            Console.WriteLine();
            try
            {
                Console.WriteLine("Creating a client.");
                var Response = await myClient.ClientCreateAsync(new AppClient()
                {
                    DocumentGuid = "fakester", Role = "Sender", Online = false
                });

                Console.WriteLine("OK: " + Response.Resource.ToJson());

                clientId = Response.Resource._id;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();
            try
            {
                Console.WriteLine("Updating a client.");
                var Response = await myClient.ClientUpdateAsync(clientId, new AppClient()
                {
                    Role = "Receiver", DocumentLocation = "C£aapppdata/x/xdfsdf.gh"
                });

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

            Console.WriteLine();
            try
            {
                Console.WriteLine("Getting a client.");
                var Response = await myClient.ClientGetAsync(clientId);

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

            Console.WriteLine();
            try
            {
                Console.WriteLine("Getting all users clients.");
                var Response = await myClient.ClientGetAllAsync();

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

            Console.WriteLine();
            try
            {
                Console.WriteLine("Deleteing  a client.");
                var Response = await myClient.ClientDeleteAsync(clientId);

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