using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; namespace Octokit { /// /// Represents an oauth access given to a particular application. /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class Authorization { // TODO: I'd love to not need this public Authorization() { } public Authorization(int id, string url, Application application, string note, string noteUrl, DateTimeOffset createdAt, DateTimeOffset updateAt, string[] scopes) { Id = id; Url = url; Application = application; // TODO: testable ctor for new values //Token = token; Note = note; NoteUrl = noteUrl; CreatedAt = createdAt; UpdateAt = updateAt; Scopes = scopes; } /// /// The Id of this . /// public int Id { get; protected set; } /// /// The API URL for this . /// public string Url { get; protected set; } /// /// The that created this . /// public Application Application { get; protected set; } /// /// The last eight characters of the user's token /// public string TokenLastEight { get; protected set; } /// /// Base-64 encoded representation of the SHA-256 digest of the token /// public string HashedToken { get; protected set; } /// /// Optional parameter that allows an OAuth application to create /// multiple authorizations for a single user /// public string Fingerprint { get; protected set; } /// /// Notes about this particular . /// public string Note { get; protected set; } /// /// A url for more information about notes. /// public string NoteUrl { get; protected set; } /// /// When this was created. /// public DateTimeOffset CreatedAt { get; protected set; } /// /// When this was last updated. /// public DateTimeOffset UpdateAt { get; protected set; } /// /// The scopes that this has. This is the kind of access that the token allows. /// [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Special type of model object that only updates none-null fields.")] public string[] Scopes { get; protected set; } public string ScopesDelimited { get { return string.Join(",", Scopes); } } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Id: {0} CreatedAt: {1} ", Id, CreatedAt); } } } }