Initial commit.
This commit is contained in:
37
Services/TriliumService.cs
Normal file
37
Services/TriliumService.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using TriliumMind.Models;
|
||||
|
||||
namespace TriliumMind.Services;
|
||||
|
||||
public class TriliumService
|
||||
{
|
||||
private readonly Serilog.ILogger _log;
|
||||
private readonly AppConfigs _configs;
|
||||
public TriliumService(AppConfigs configs)
|
||||
{
|
||||
_log = Log.ForContext<TriliumService>();
|
||||
_configs = configs;
|
||||
}
|
||||
public async Task<string> FettchPageContentsAsync(Issue issue)
|
||||
{
|
||||
var baseUrl = _configs.AppSettings.Trilium.EtapiBaseUrl;
|
||||
var pageId = "QxxFqCNAtIOy";
|
||||
var requstUrl = $"{baseUrl}/notes/{pageId}/content";
|
||||
|
||||
var client = new HttpClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, requstUrl);
|
||||
request.Headers.Add("Authorization", "");
|
||||
var response = await client.SendAsync(request);
|
||||
response.EnsureSuccessStatusCode();
|
||||
Console.WriteLine(await response.Content.ReadAsStringAsync());
|
||||
|
||||
// Return new page ID after creating a new page
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user