Exemplo n.º 1
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var serviceCollection = new ServiceCollection();
            var token             = "1ba000c750cbce7264b89d0b212e0cec581362f38a";

            serviceCollection.AddHttpClient("SpeckleClient", c =>
            {
                c.BaseAddress = new Uri("http://localhost:3000/graphql");
                c.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
            });

            serviceCollection.AddSpeckleClient();
            serviceCollection.AddSingleton <IValueSerializer, JSONObjectSerializer>();

            IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
            ISpeckleClient   client          = serviceProvider.GetRequiredService <ISpeckleClient>();

            var result = await client.GetServerInfoAsync();

            Console.WriteLine(result.Data.ServerInfo.Name);
            Console.WriteLine(result.Data.ServerInfo.Company);
            Console.WriteLine(result.Data.ServerInfo.TermsOfService);
            Console.WriteLine(string.Join(", ", result.Data.ServerInfo.Roles.Select(role => role.Name).ToArray()));

            // var testStream = await client.GetStreamAsync("154eaa6a1b");
            // Console.WriteLine("-------- Stream -------- /n");
            // Console.WriteLine(testStream.Data.Stream.Name);
            // Console.WriteLine(testStream.Data.Stream.Commits.TotalCount);
            // Console.WriteLine(testStream.Data.Stream.CreatedAt.ToString());

            var profile = await client.GetMyProfileAsync();

            Console.WriteLine($"My name is now {profile.Data.User.Name}");
            var testUEdit = await client.UserEditAsync(new Optional <UserEditInput>(new UserEditInput {
                Name = "Balrog The Third"
            }));

            var profile2 = await client.GetMyProfileAsync();

            Console.WriteLine($"My name is now {profile2.Data.User.Name}");
        }
Exemplo n.º 2
0
        static async Task Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();
            var token             = "e90c8db18d0a5175877bd106105fa0806bba36e621";

            serviceCollection.AddHttpClient("SpeckleClient", c =>
            {
                c.BaseAddress = new Uri("http://localhost:3000/graphql");
                c.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
            });
            serviceCollection.AddSpeckleClient();
            serviceCollection.AddSingleton <IValueSerializer, JSONObjectSerializer>();

            IServiceProvider services = serviceCollection.BuildServiceProvider();



            ISpeckleClient client = services.GetRequiredService <ISpeckleClient>();

            IOperationResult <IGetServerInfo> result = await client.GetServerInfoAsync();

            Console.WriteLine(result.Data.ServerInfo.Name);
            Console.WriteLine(result.Data.ServerInfo.Company);
            Console.WriteLine(result.Data.ServerInfo.TermsOfService);
            Console.WriteLine(string.Join(", ", result.Data.ServerInfo.Roles.Select(role => role.Name).ToArray()));

            var myProfile = await client.GetMyProfileAsync();

            Console.WriteLine(myProfile.Data.User.Name);
            Console.WriteLine(myProfile.Data.User.Id);
            Console.WriteLine(myProfile.Data.User.Email);

            var testStream = await client.GetStreamAsync("154eaa6a1b");

            Console.WriteLine(testStream.Data.Stream.Name);
            Console.WriteLine(testStream.Data.Stream.Commits.TotalCount);
        }