/// <summary> /// Get an archive of a given repository's contents, in a specific format /// </summary> /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param> /// <param name="reference">A valid Git reference.</param> /// <param name="timeout"> Time span until timeout </param> public async Task <byte[]> GetArchive(int repositoryId, ArchiveFormat archiveFormat, string reference, TimeSpan timeout) { Ensure.ArgumentNotNull(reference, "reference"); Ensure.GreaterThanZero(timeout, "timeout"); var endpoint = ApiUrls.RepositoryArchiveLink(repositoryId, archiveFormat, reference); var response = await Connection.Get <byte[]>(endpoint, timeout).ConfigureAwait(false); return(response.Body); }
/// <summary> /// Get an archive of a given repository's contents, in a specific format /// </summary> /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param> /// <param name="reference">A valid Git reference.</param> /// <param name="timeout"> Time span until timeout </param> /// <returns>The binary contents of the archive</returns> public async Task <byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.GreaterThanZero(timeout, "timeout"); var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference); var response = await Connection.Get <byte[]>(endpoint, timeout); return(response.Body); }
Task <IApiResponse <T> > SendData <T>( Uri uri, HttpMethod method, object body, string accepts, string contentType, TimeSpan timeout, CancellationToken cancellationToken, string twoFactorAuthenticationCode = null, Uri baseAddress = null) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.GreaterThanZero(timeout, nameof(timeout)); var request = new Request { Method = method, BaseAddress = baseAddress ?? BaseAddress, Endpoint = uri, Timeout = timeout }; return(SendDataInternal <T>(body, accepts, contentType, cancellationToken, twoFactorAuthenticationCode, request)); }