JetBrains / YouTrackSharp

.NET Standard 2.0 Library to access YouTrack API.
https://www.jetbrains.com/youtrack
Apache License 2.0
134 stars 105 forks source link

Get YouTrack build number #75

Closed MarkHutchings closed 6 years ago

MarkHutchings commented 6 years ago

I've added this myself as an extension to Connection for now:

        public class BuildVersionResult
        {
            [JsonProperty( "build" )]
            public string Build;
        }

        public static async Task<BuildVersionResult> BuildVersion( this Connection connection )
        {
            var httpClient = await connection.GetAuthenticatedHttpClient();
            var client     = httpClient;
            var response   = await client.GetAsync($"api/config?fields=build" );
            response.EnsureSuccessStatusCode();

            var str = await response.Content.ReadAsStringAsync();

            var f = JsonConvert.DeserializeObject<BuildVersionResult>( str );

            return f;
        }
maartenba commented 6 years ago

@MarkAudax do you happen to have a link to the documentation in the REST API for this one?

Tenebrous commented 6 years ago

@maartenba Sorry no, but I got the idea from here: https://github.com/JetBrains/youtrack-rest-python-library/blob/1140fe3697d3bbd233f967a1ea0eac8544040e22/youtrack/connection.py#L1223

maartenba commented 6 years ago

Let me see if I can add it.

MarkHutchings commented 6 years ago

That was quick, thanks very much!

maartenba commented 6 years ago

Release will be done later today. Thanks @MarkAudax for suggesting! (and PR's are always welcome :))

MarkHutchings commented 6 years ago

Perfect - I have forked and I'll get set up for PRs :)