-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gist get support #225
Add gist get support #225
Changes from 4 commits
0b0661a
cc77928
f0ea90b
ae34ccd
383ec59
011bfa7
c7a1766
0440888
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Net.Http.Headers; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Integration | ||
{ | ||
public class GistsClientTests | ||
{ | ||
readonly IGitHubClient _gitHubClient; | ||
readonly IGistsClient _gistsClient; | ||
|
||
public GistsClientTests() | ||
{ | ||
this._gitHubClient = new GitHubClient(new ProductHeaderValue("OctokitTests")) | ||
{ | ||
Credentials = Helper.Credentials | ||
}; | ||
|
||
this._gistsClient = this._gitHubClient.Gist; | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task CanGetGist() | ||
{ | ||
var retrieved = await this._gistsClient.Get("6305249"); | ||
Assert.NotNull(retrieved); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using NSubstitute; | ||
using Octokit; | ||
using Xunit; | ||
|
||
public class GistsClientTests | ||
{ | ||
public class TheGetMethod | ||
{ | ||
[Fact] | ||
public void RequestsCorrectUrl() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new GistsClient(connection); | ||
|
||
client.Get("1"); | ||
|
||
connection.Received().Get<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1"), null); | ||
} | ||
} | ||
|
||
public class TheCtor | ||
{ | ||
[Fact] | ||
public void EnsuresArgument() | ||
{ | ||
Assert.Throws<ArgumentNullException>(() => new GistsClient(null)); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Octokit | ||
{ | ||
public class GistsClient : ApiClient, IGistsClient | ||
{ | ||
public GistsClient(IApiConnection apiConnection) : | ||
base(apiConnection) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets a gist | ||
/// </summary> | ||
/// <remarks> | ||
/// http://developer.github.com/v3/gists/#get-a-single-gist | ||
/// </remarks> | ||
/// <param name="id">The id of the gist</param> | ||
public Task<Gist> Get(string id) | ||
{ | ||
return ApiConnection.Get<Gist>(ApiUrls.Gist(id)); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Threading.Tasks; | ||
|
||
namespace Octokit | ||
{ | ||
public interface IGistsClient | ||
{ | ||
/// <summary> | ||
/// Gets a gist | ||
/// </summary> | ||
/// <remarks> | ||
/// http://developer.github.com/v3/gists/#get-a-single-gist | ||
/// </remarks> | ||
/// <param name="id">The id of the gist</param> | ||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", | ||
Justification = "Method makes a network request")] | ||
Task<Gist> Get(string id); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a little less whitespace |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Octokit | ||
{ | ||
public class Gist | ||
{ | ||
/// <summary> | ||
/// The API URL for this <see cref="Gist"/>. | ||
/// </summary> | ||
public string Url { get; set; } | ||
|
||
/// <summary> | ||
/// The Id of this <see cref="Gist"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// Given a gist url of https://gist.github.com/UserName/1234 the Id would be '1234'. | ||
/// </remarks> | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// A description of the <see cref="Gist"/>. | ||
/// </summary> | ||
public string Description { get; set; } | ||
|
||
/// <summary> | ||
/// Indicates if the <see cref="Gist"/> is private or public. | ||
/// </summary> | ||
public bool Public { get; set; } | ||
|
||
/// <summary> | ||
/// The <see cref="User"/> who owns this <see cref="Gist"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// Given a gist url of https://gist.github.com/UserName/1234 the Owner would be 'UserName'. | ||
/// </remarks> | ||
public User Owner { get; set; } | ||
|
||
/// <summary> | ||
/// A <see cref="IDictionary{TKey,TValue}"/> containing all <see cref="GistFile"/>s in this <see cref="Gist"/>. | ||
/// </summary> | ||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] | ||
public IDictionary<string, GistFile> Files { get; set; } | ||
|
||
/// <summary> | ||
/// The number of comments on this <see cref="Gist"/>. | ||
/// </summary> | ||
public int Comments { get; set; } | ||
|
||
/// <summary> | ||
/// A url to retrieve the comments for this <see cref="Gist"/>. | ||
/// </summary> | ||
public string CommentsUrl { get; set; } | ||
|
||
public string HtmlUrl { get; set; } | ||
|
||
/// <summary> | ||
/// The git url to pull from to retrieve the contents for this <see cref="Gist"/>. | ||
/// </summary> | ||
public string GitPullUrl { get; set; } | ||
|
||
/// <summary> | ||
/// The git url to push to when changing this <see cref="Gist"/>. | ||
/// </summary> | ||
public string GitPushUrl { get; set; } | ||
|
||
/// <summary> | ||
/// The <see cref="DateTimeOffset"/> for when this <see cref="Gist"/> was created. | ||
/// </summary> | ||
public DateTimeOffset CreatedAt { get; set; } | ||
|
||
/// <summary> | ||
/// The <see cref="DateTimeOffset"/> for when this <see cref="Gist"/> was last updated. | ||
/// </summary> | ||
public DateTimeOffset UpdatedAt { get; set; } | ||
|
||
/// <summary> | ||
/// A <see cref="IList{T}"/> of all <see cref="GistFork"/> that exist for this <see cref="Gist"/>. | ||
/// </summary> | ||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] | ||
public IList<GistFork> Forks { get; set; } | ||
|
||
/// <summary> | ||
/// A <see cref="IList{T}"/> of all <see cref="GistHistory"/> containing the full history for this <see cref="Gist"/>. | ||
/// </summary> | ||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] | ||
public IList<GistHistory> History { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Octokit | ||
{ | ||
/// <summary> | ||
/// User by <see cref="GistHistory"/> to indicate the level of change. | ||
/// </summary> | ||
public class GistChangeStatus | ||
{ | ||
/// <summary> | ||
/// The number of deletions that occurred as part of this change. | ||
/// </summary> | ||
public int Deletions { get; set; } | ||
|
||
/// <summary> | ||
/// The number of additions that occurred as part of this change. | ||
/// </summary> | ||
public int Additions { get; set; } | ||
|
||
/// <summary> | ||
/// The total number of changes. | ||
/// </summary> | ||
public int Total { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Octokit | ||
{ | ||
public class GistFile | ||
{ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doot |
||
/// <summary> | ||
/// The size in bytes of the file. | ||
/// </summary> | ||
public int Size { get; set; } | ||
|
||
/// <summary> | ||
/// The name of the file | ||
/// </summary> | ||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")] | ||
public string Filename { get; set; } | ||
|
||
/// <summary> | ||
/// The mime type of the file | ||
/// </summary> | ||
[SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] | ||
public string Type { get; set; } | ||
|
||
/// <summary> | ||
/// The programming language of the file, if any. | ||
/// </summary> | ||
public string Language { get; set; } | ||
|
||
/// <summary> | ||
/// The text content of the file. | ||
/// </summary> | ||
public string Content { get; set; } | ||
|
||
/// <summary> | ||
/// The url to download the file. | ||
/// </summary> | ||
public string RawUrl { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
|
||
namespace Octokit | ||
{ | ||
public class GistFork | ||
{ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bamf |
||
/// <summary> | ||
/// The <see cref="User"/> that created this <see cref="GistFork"/> | ||
/// </summary> | ||
public User User { get; set; } | ||
|
||
/// <summary> | ||
/// The API URL for this <see cref="GistFork"/>. | ||
/// </summary> | ||
public string Url { get; set; } | ||
|
||
/// <summary> | ||
/// The <see cref="DateTimeOffset"/> for when this <see cref="Gist"/> was created. | ||
/// </summary> | ||
public DateTimeOffset CreatedAt { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
|
||
namespace Octokit | ||
{ | ||
/// <summary> | ||
/// A historical version of a <see cref="Gist"/> | ||
/// </summary> | ||
public class GistHistory | ||
{ | ||
/// <summary> | ||
/// The url that can be used by the API to retrieve this version of the <see cref="Gist"/>. | ||
/// </summary> | ||
public string Url { get; set; } | ||
|
||
/// <summary> | ||
/// A git sha representing the version. | ||
/// </summary> | ||
public string Version { get; set; } | ||
|
||
/// <summary> | ||
/// The <see cref="User"/> who create this version. | ||
/// </summary> | ||
public User User { get; set; } | ||
|
||
/// <summary> | ||
/// A <see cref="GistHistory"/> that represents the level of change for this <see cref="GistHistory"/>. | ||
/// </summary> | ||
public GistChangeStatus ChangeStatus { get; set; } | ||
|
||
/// <summary> | ||
/// The <see cref="DateTimeOffset"/> the version was created. | ||
/// </summary> | ||
public DateTimeOffset CommittedAt { get; set; } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resharper did that on its own. i suspect if u update to latest resharper it would do the same for you.
Want me to roll it back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's drop it, If it comes up with the latest R# we can revisit it then.