Files
octokit.net/Octokit/Models/Response/RepositoryTrafficView.cs
Martin Scholz a57fb1278d [WIP] Add repository traffic preview (#1457)
* Add response models

* Supress message

* correct spelling Timestamp

* implement traffic client

* add reactive client

* [WIP] unit tests

* add argument check

* finish unit tests

* add integration tests

* Change repositoryId from int to long
Remove GetAll naming of endpoints and add to PaginationTest exclusions
Rename View and Clone classes to be more specific
Add handling of TimeStamp fields being UtcUnix time
Add integration tests for repositoryId methods
2016-09-29 01:16:58 +10:00

70 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Octokit.Helpers;
using Octokit.Internal;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RepositoryTrafficViewSummary
{
public RepositoryTrafficViewSummary() { }
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")]
public RepositoryTrafficViewSummary(int count, int uniques, IReadOnlyList<RepositoryTrafficView> views)
{
Count = count;
Uniques = uniques;
Views = views;
}
public int Count { get; protected set; }
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")]
public int Uniques { get; protected set; }
public IReadOnlyList<RepositoryTrafficView> Views { get; protected set; }
internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Number: {0} Uniques: {1}", Count, Uniques); }
}
}
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RepositoryTrafficView
{
public RepositoryTrafficView() { }
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")]
public RepositoryTrafficView(long timestamp, int count, int uniques)
{
TimestampAsUtcEpochSeconds = timestamp;
Count = count;
Uniques = uniques;
}
[Parameter(Key = "ignoreThisField")]
public DateTimeOffset Timestamp
{
get { return TimestampAsUtcEpochSeconds.FromUnixTime(); }
}
[Parameter(Key = "timestamp")]
public long TimestampAsUtcEpochSeconds { get; protected set; }
public int Count { get; protected set; }
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")]
public int Uniques { get; protected set; }
internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Timestamp: {0} Number: {1} Uniques: {2}", Timestamp, Count, Uniques); }
}
}
}