Get git projects from Gogs
This commit is contained in:
parent
9fd9beb860
commit
292d7729f2
9 changed files with 122 additions and 10 deletions
27
Website/Data/GitServerApi.cs
Normal file
27
Website/Data/GitServerApi.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Website.Data.States;
|
||||
using Website.Models;
|
||||
|
||||
namespace Website.Data {
|
||||
public class GitServerApi {
|
||||
private readonly HttpClient _client;
|
||||
private readonly string _domain;
|
||||
private readonly string _token;
|
||||
|
||||
public GitServerApi(HttpClient client, string domain, string token) {
|
||||
_client = client;
|
||||
_domain = domain;
|
||||
_token = token;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GitRepository>> GetRepositories() {
|
||||
var response = await _client.GetStringAsync($"https://{_domain}/api/v1/users/rob/repos?token={_token}");
|
||||
var states = JsonConvert.DeserializeObject<IEnumerable<GitRepositoryState>>(response);
|
||||
return states.Select(state => new GitRepository(state));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue