Skip to content

Commit

Permalink
Some small fixes: "nocheck" is "no-check". Downloading attachments wa…
Browse files Browse the repository at this point in the history
…s wrongly named, PictureAsync -> AttachAsync. Also added a method to get the list of spaces.
  • Loading branch information
Lakritzator committed Mar 11, 2016
1 parent 48def67 commit 25d4208
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Dapplo.Confluence.Shared/ConfluenceApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ConfluenceApi(Uri baseUri, IHttpSettings httpSettings = null)
HttpSettings = httpSettings,
OnHttpRequestMessageCreated = httpMessage =>
{
httpMessage?.Headers.TryAddWithoutValidation("X-Atlassian-Token", "nocheck");
httpMessage?.Headers.TryAddWithoutValidation("X-Atlassian-Token", "no-check");
if (!string.IsNullOrEmpty(_user) && _password != null)
{
httpMessage?.SetBasicAuthorization(_user, _password);
Expand Down Expand Up @@ -104,7 +104,7 @@ public void SetBasicAuthentication(string user, string password)
{
_behaviour.MakeCurrent();
var attachUri = ConfluenceBaseUri.AppendSegments("content", contentId, "child", "attachments");
var response = await attachUri.PostAsync<HttpResponse<Result<Attachment>, Error>>(cancellationToken).ConfigureAwait(false);
var response = await attachUri.PostAsync<HttpResponse<Result<Attachment>, Error>>(content, cancellationToken).ConfigureAwait(false);
if (response.HasError)
{
throw new Exception(response.ErrorResponse.Message);
Expand All @@ -122,7 +122,7 @@ public void SetBasicAuthentication(string user, string password)
/// <param name="attachment">Attachment</param>
/// <param name="cancellationToken">CancellationToken</param>
/// <returns>Bitmap,BitmapSource or MemoryStream (etc) depending on TResponse</returns>
public async Task<TResponse> PictureAsync<TResponse>(Attachment attachment, CancellationToken cancellationToken = default(CancellationToken))
public async Task<TResponse> AttachmentAsync<TResponse>(Attachment attachment, CancellationToken cancellationToken = default(CancellationToken))
where TResponse : class
{
_behaviour.MakeCurrent();
Expand Down Expand Up @@ -179,6 +179,23 @@ public void SetBasicAuthentication(string user, string password)
return response.Response;
}

/// <summary>
/// Get Spaces see <a href="https://docs.atlassian.com/confluence/REST/latest/#d3e164">here</a>
/// </summary>
/// <param name="cancellationToken">CancellationToken</param>
/// <returns>List of Space</returns>
public async Task<IList<Space>> SpacesAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var spacesUri = ConfluenceBaseUri.AppendSegments("space");
_behaviour.MakeCurrent();
var response = await spacesUri.GetAsAsync<HttpResponse<Result<Space>, Error>>(cancellationToken).ConfigureAwait(false);
if (response.HasError)
{
throw new Exception(response.ErrorResponse.Message);
}
return response.Response.Results;
}

/// <summary>
/// Get Content information see <a href="https://docs.atlassian.com/confluence/REST/latest/#d3e164">here</a>
/// </summary>
Expand Down

0 comments on commit 25d4208

Please sign in to comment.