using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Octokit
{
///
/// Extra information returned as part of each API response.
///
public class ApiInfo
{
public ApiInfo(IDictionary links,
IList oauthScopes,
IList acceptedOauthScopes,
string etag,
RateLimit rateLimit,
TimeSpan serverTimeDifference = default)
{
Ensure.ArgumentNotNull(links, nameof(links));
Ensure.ArgumentNotNull(oauthScopes, nameof(oauthScopes));
Ensure.ArgumentNotNull(acceptedOauthScopes, nameof(acceptedOauthScopes));
Links = new ReadOnlyDictionary(links);
OauthScopes = new ReadOnlyCollection(oauthScopes);
AcceptedOauthScopes = new ReadOnlyCollection(acceptedOauthScopes);
Etag = etag;
RateLimit = rateLimit;
ServerTimeDifference = serverTimeDifference;
}
///
/// Oauth scopes that were included in the token used to make the request.
///
public IReadOnlyList OauthScopes { get; private set; }
///
/// Oauth scopes accepted for this particular call.
///
public IReadOnlyList AcceptedOauthScopes { get; private set; }
///
/// Etag
///
public string Etag { get; private set; }
///
/// Links to things like next/previous pages
///
public IReadOnlyDictionary Links { get; private set; }
///
/// Information about the API rate limit
///
public RateLimit RateLimit { get; private set; }
///
/// The best-effort time difference between the server and the client.
///
///
/// If both the server and the client have reasonably accurate clocks,
/// the value of this property will be close to .
/// The actual value is sensitive to network transmission and processing
/// delays.
///
public TimeSpan ServerTimeDifference { get; }
///
/// Allows you to clone ApiInfo
///
/// A clone of
public ApiInfo Clone()
{
return new ApiInfo(Links.Clone(),
OauthScopes.Clone(),
AcceptedOauthScopes.Clone(),
Etag != null ? new string(Etag.ToCharArray()) : null,
RateLimit != null ? RateLimit.Clone() : null,
ServerTimeDifference);
}
}
}