Skip to content

Commit

Permalink
Added function to get total active pastes
Browse files Browse the repository at this point in the history
  • Loading branch information
dentolos19 committed May 29, 2022
1 parent 5cef3de commit cb84e67
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions PasteMystNet/PasteMystPaste.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PasteMystNet.Core;

namespace PasteMystNet;
Expand Down Expand Up @@ -48,4 +49,14 @@ public static async Task DeletePasteAsync(string id, PasteMystToken token)
response.EnsureSuccessStatusCode();
}

public static async Task<int> GetTotalActivePastesAsync()
{
using var httpClient = new HttpClient();
var response = await httpClient.GetAsync(PasteMystConstants.GetTotalActivePastesEndpoint);
response.EnsureSuccessStatusCode();
var responseContent = await response.Content.ReadAsStringAsync();
var json = JsonConvert.DeserializeObject<JObject>(responseContent);
return json["numPastes"].ToObject<int>();
}

}

0 comments on commit cb84e67

Please sign in to comment.