[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
This commit is contained in:
Martin Scholz
2016-09-28 17:16:58 +02:00
committed by Ryan Gribble
parent 693cc29dd5
commit a57fb1278d
31 changed files with 1281 additions and 2 deletions

View File

@@ -0,0 +1,69 @@
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); }
}
}
}