mirror of
https://github.com/ckaczor/ChrisKaczor.FeverClient.git
synced 2026-01-13 17:22:17 -05:00
Initial commit
This commit is contained in:
484
.gitignore
vendored
Normal file
484
.gitignore
vendored
Normal file
@@ -0,0 +1,484 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from `dotnet new gitignore`
|
||||||
|
|
||||||
|
# dotenv files
|
||||||
|
.env
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# Tye
|
||||||
|
.tye/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
*.vbp
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
*.ncb
|
||||||
|
*.aps
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
.vshistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
*.sln.iml
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
##
|
||||||
|
## Visual studio for Mac
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
# globs
|
||||||
|
Makefile.in
|
||||||
|
*.userprefs
|
||||||
|
*.usertasks
|
||||||
|
config.make
|
||||||
|
config.status
|
||||||
|
aclocal.m4
|
||||||
|
install-sh
|
||||||
|
autom4te.cache/
|
||||||
|
*.tar.gz
|
||||||
|
tarballs/
|
||||||
|
test-results/
|
||||||
|
|
||||||
|
# Mac bundle stuff
|
||||||
|
*.dmg
|
||||||
|
*.app
|
||||||
|
|
||||||
|
# content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# content below from: https://github.com/github/gitignore/blob/main/Global/Windows.gitignore
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
# Vim temporary swap files
|
||||||
|
*.swp
|
||||||
25
Converters/BoolConverter.cs
Normal file
25
Converters/BoolConverter.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Converters
|
||||||
|
{
|
||||||
|
public class BoolTimestampConverter : JsonConverter<bool>
|
||||||
|
{
|
||||||
|
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
if (reader.TokenType != JsonTokenType.Number)
|
||||||
|
{
|
||||||
|
throw new JsonException("Expected a numeric boolean value");
|
||||||
|
}
|
||||||
|
|
||||||
|
var number = reader.GetInt64();
|
||||||
|
return number == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
var number = value ? 1 : 0;
|
||||||
|
writer.WriteNumberValue(number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Converters/CommaSeparatedListConverter.cs
Normal file
25
Converters/CommaSeparatedListConverter.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Converters;
|
||||||
|
|
||||||
|
internal class CommaSeparatedListConverter : JsonConverter<IEnumerable<int>>
|
||||||
|
{
|
||||||
|
public override IEnumerable<int> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
if (reader.TokenType != JsonTokenType.String)
|
||||||
|
{
|
||||||
|
throw new JsonException("Expected a string");
|
||||||
|
}
|
||||||
|
|
||||||
|
var commaSeparatedList = reader.GetString() ?? string.Empty;
|
||||||
|
|
||||||
|
return commaSeparatedList.Split(",").Select(int.Parse).AsEnumerable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(Utf8JsonWriter writer, IEnumerable<int> value, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
var commaSeparatedList = string.Join(",", value);
|
||||||
|
writer.WriteStringValue(commaSeparatedList);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Converters/EpochConverter.cs
Normal file
24
Converters/EpochConverter.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Converters;
|
||||||
|
|
||||||
|
public class EpochConverter : JsonConverter<DateTimeOffset>
|
||||||
|
{
|
||||||
|
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
if (reader.TokenType != JsonTokenType.Number)
|
||||||
|
{
|
||||||
|
throw new JsonException("Expected a numeric epoch timestamp");
|
||||||
|
}
|
||||||
|
|
||||||
|
var unixTimestamp = reader.GetInt64();
|
||||||
|
return DateTimeOffset.FromUnixTimeSeconds(unixTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
var unixTimestamp = value.ToUnixTimeSeconds();
|
||||||
|
writer.WriteNumberValue(unixTimestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
103
FeverClient.cs
Normal file
103
FeverClient.cs
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using ChrisKaczor.FeverClient.Converters;
|
||||||
|
using ChrisKaczor.FeverClient.Models;
|
||||||
|
using ChrisKaczor.FeverClient.Responses;
|
||||||
|
using RestSharp;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient;
|
||||||
|
|
||||||
|
public class FeverClient
|
||||||
|
{
|
||||||
|
private readonly JsonSerializerOptions _jsonSerializerOptions;
|
||||||
|
private readonly RestClient _restClient;
|
||||||
|
|
||||||
|
public FeverClient(string url, string apiKey)
|
||||||
|
{
|
||||||
|
_jsonSerializerOptions = new JsonSerializerOptions();
|
||||||
|
_jsonSerializerOptions.Converters.Add(new EpochConverter());
|
||||||
|
_jsonSerializerOptions.Converters.Add(new BoolTimestampConverter());
|
||||||
|
_jsonSerializerOptions.Converters.Add(new CommaSeparatedListConverter());
|
||||||
|
|
||||||
|
_restClient = new RestClient(url);
|
||||||
|
_restClient.AddDefaultParameter("api_key", apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<T> PostRestRequest<T>(string api)
|
||||||
|
{
|
||||||
|
var request = new RestRequest($"/fever/?api&{api}", Method.Post) { AlwaysMultipartFormData = true };
|
||||||
|
|
||||||
|
var response = await _restClient.PostAsync(request);
|
||||||
|
|
||||||
|
if (response == null)
|
||||||
|
throw new Exception("Failed to get response from Fever API");
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
throw new Exception($"Error: {response.StatusCode} - {response.Content}");
|
||||||
|
|
||||||
|
if (response.Content == null)
|
||||||
|
throw new Exception("Response content is null");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var responseObject = JsonSerializer.Deserialize<T>(response.Content, _jsonSerializerOptions);
|
||||||
|
|
||||||
|
if (responseObject == null)
|
||||||
|
throw new Exception($"Failed to deserialize response content - {response.Content}");
|
||||||
|
|
||||||
|
return responseObject;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new Exception($"Failed to deserialize response content - {response.Content}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Group>> GetGroups()
|
||||||
|
{
|
||||||
|
var groupsResponse = await PostRestRequest<GetGroupsResponse>("groups");
|
||||||
|
|
||||||
|
return groupsResponse.Groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Feed>> GetFeeds()
|
||||||
|
{
|
||||||
|
var feedsResponse = await PostRestRequest<GetFeedsResponse>("feeds");
|
||||||
|
|
||||||
|
return feedsResponse.Feeds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Favicon>> GetFavicons()
|
||||||
|
{
|
||||||
|
var faviconsResponse = await PostRestRequest<GetFaviconsResponse>("favicons");
|
||||||
|
|
||||||
|
return faviconsResponse.Favicons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<FeedItem>> GetFeedItems(int sinceId = 1)
|
||||||
|
{
|
||||||
|
var feedItemsResponse = await PostRestRequest<GetFeedItemsResponse>($"items&since_id={sinceId}");
|
||||||
|
|
||||||
|
return feedItemsResponse.FeedItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<FeedItem>> GetAllFeedItems()
|
||||||
|
{
|
||||||
|
var allFeedItems = new List<FeedItem>();
|
||||||
|
|
||||||
|
var response = (await GetFeedItems()).ToList();
|
||||||
|
|
||||||
|
while (response.Count > 0)
|
||||||
|
{
|
||||||
|
allFeedItems.AddRange(response);
|
||||||
|
|
||||||
|
response = (await GetFeedItems(response.Max(fi => fi.Id))).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return allFeedItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task MarkFeedItemAsRead(int feedItemId)
|
||||||
|
{
|
||||||
|
await PostRestRequest<BaseResponse>($"mark=item&as=read&id={feedItemId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
34
FeverClient.csproj
Normal file
34
FeverClient.csproj
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<RootNamespace>ChrisKaczor.FeverClient</RootNamespace>
|
||||||
|
<Title>ChrisKaczor.FeverClient</Title>
|
||||||
|
<Authors>Chris Kaczor</Authors>
|
||||||
|
<Product>ChrisKaczor.FeverClient</Product>
|
||||||
|
<RepositoryUrl>https://github.com/ckaczor/ChrisKaczor.FeverClient</RepositoryUrl>
|
||||||
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
|
<Description>This library can be used to read RSS feeds via the Fever API in Miniflux or other similar feed readers/servers.</Description>
|
||||||
|
<PackageId>ChrisKaczor.FeverClient</PackageId>
|
||||||
|
<AssemblyName>ChrisKaczor.FeverClient</AssemblyName>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="FeverClient.sln.DotSettings" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
|
||||||
|
<PackageReference Include="RestSharp" Version="112.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="README.md">
|
||||||
|
<Pack>True</Pack>
|
||||||
|
<PackagePath>\</PackagePath>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
25
FeverClient.sln
Normal file
25
FeverClient.sln
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 18
|
||||||
|
VisualStudioVersion = 18.0.11018.127 d18.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeverClient", "FeverClient.csproj", "{85FE0D62-97D7-43DD-AC1B-F596762D0E33}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{85FE0D62-97D7-43DD-AC1B-F596762D0E33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{85FE0D62-97D7-43DD-AC1B-F596762D0E33}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{85FE0D62-97D7-43DD-AC1B-F596762D0E33}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{85FE0D62-97D7-43DD-AC1B-F596762D0E33}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {F01F2A17-ECF5-4F99-A61E-633332945FB2}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
2
FeverClient.sln.DotSettings
Normal file
2
FeverClient.sln.DotSettings
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kaczor/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 Chris Kaczor
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
14
Models/Favicon.cs
Normal file
14
Models/Favicon.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Models;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public class Favicon
|
||||||
|
{
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public required int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("data")]
|
||||||
|
public required string Data { get; set; }
|
||||||
|
}
|
||||||
26
Models/Feed.cs
Normal file
26
Models/Feed.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Models;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public class Feed
|
||||||
|
{
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public required int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("favicon_id")]
|
||||||
|
public required int FaviconId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("title")]
|
||||||
|
public required string Title { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("url")]
|
||||||
|
public required string Url { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("site_url")]
|
||||||
|
public required string SiteUrl { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("last_updated_on_time")]
|
||||||
|
public required DateTimeOffset LastUpdatedOnTime { get; set; }
|
||||||
|
}
|
||||||
14
Models/FeedGroup.cs
Normal file
14
Models/FeedGroup.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Models;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public class FeedGroup
|
||||||
|
{
|
||||||
|
[JsonPropertyName("group_id")]
|
||||||
|
public required int GroupId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("feed_ids")]
|
||||||
|
public required IEnumerable<int> FeedIds { get; set; }
|
||||||
|
}
|
||||||
35
Models/FeedItem.cs
Normal file
35
Models/FeedItem.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Models;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public class FeedItem
|
||||||
|
{
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public required int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("feed_id")]
|
||||||
|
public required int FeedId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("title")]
|
||||||
|
public required string Title { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("author")]
|
||||||
|
public required string Author { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("html")]
|
||||||
|
public required string Html { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("url")]
|
||||||
|
public required string Url { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("is_saved")]
|
||||||
|
public required bool IsSaved { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("is_read")]
|
||||||
|
public required bool IsRead { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("created_on_time")]
|
||||||
|
public required DateTimeOffset CreatedOnTime { get; set; }
|
||||||
|
}
|
||||||
14
Models/Group.cs
Normal file
14
Models/Group.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Models;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public class Group
|
||||||
|
{
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public required int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("title")]
|
||||||
|
public required string Title { get; set; }
|
||||||
|
}
|
||||||
17
README.md
Normal file
17
README.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# ChrisKaczor.FeverClient
|
||||||
|
|
||||||
|
This library can be used to read RSS feeds via the Fever API in [Miniflux](https://miniflux.app/index.html) or other similar feed readers/servers.
|
||||||
|
|
||||||
|
Only tested with [Miniflux](https://miniflux.app/index.html) so far but works for my needs in [Feed Center](http://github.com/ckaczor/FeedCenter).
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
* **Chris Kaczor** - *Initial work* - https://github.com/ckaczor - https://chriskaczor.com
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
This code is used by my various personal projects and may not be useful or work in all use cases.
|
||||||
15
Responses/BaseResponse.cs
Normal file
15
Responses/BaseResponse.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Responses;
|
||||||
|
|
||||||
|
internal class BaseResponse
|
||||||
|
{
|
||||||
|
[JsonPropertyName("api_version")]
|
||||||
|
public int ApiVersion { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("auth")]
|
||||||
|
public bool Auth { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("last_refreshed_on_time")]
|
||||||
|
public DateTimeOffset LastRefreshedOnTime { get; set; }
|
||||||
|
}
|
||||||
10
Responses/GetFaviconsResponse.cs
Normal file
10
Responses/GetFaviconsResponse.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using ChrisKaczor.FeverClient.Models;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Responses;
|
||||||
|
|
||||||
|
internal class GetFaviconsResponse : BaseResponse
|
||||||
|
{
|
||||||
|
[JsonPropertyName("favicons")]
|
||||||
|
public required IEnumerable<Favicon> Favicons { get; set; }
|
||||||
|
}
|
||||||
13
Responses/GetFeedItemsResponse.cs
Normal file
13
Responses/GetFeedItemsResponse.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using ChrisKaczor.FeverClient.Models;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Responses;
|
||||||
|
|
||||||
|
internal class GetFeedItemsResponse : BaseResponse
|
||||||
|
{
|
||||||
|
[JsonPropertyName("items")]
|
||||||
|
public required IEnumerable<FeedItem> FeedItems { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("total_items")]
|
||||||
|
public required int TotalItems { get; set; }
|
||||||
|
}
|
||||||
13
Responses/GetFeedsResponse.cs
Normal file
13
Responses/GetFeedsResponse.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using ChrisKaczor.FeverClient.Models;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Responses;
|
||||||
|
|
||||||
|
internal class GetFeedsResponse : BaseResponse
|
||||||
|
{
|
||||||
|
[JsonPropertyName("feeds")]
|
||||||
|
public required IEnumerable<Feed> Feeds { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("feeds_groups")]
|
||||||
|
public required IEnumerable<FeedGroup> FeedGroups { get; set; }
|
||||||
|
}
|
||||||
13
Responses/GetGroupsResponse.cs
Normal file
13
Responses/GetGroupsResponse.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using ChrisKaczor.FeverClient.Models;
|
||||||
|
|
||||||
|
namespace ChrisKaczor.FeverClient.Responses;
|
||||||
|
|
||||||
|
internal class GetGroupsResponse : BaseResponse
|
||||||
|
{
|
||||||
|
[JsonPropertyName("groups")]
|
||||||
|
public required IEnumerable<Group> Groups { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("feeds_groups")]
|
||||||
|
public required IEnumerable<FeedGroup> FeedGroups { get; set; }
|
||||||
|
}
|
||||||
63
azure-pipelines.yml
Normal file
63
azure-pipelines.yml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
name: 1.0.$(Rev:r)
|
||||||
|
|
||||||
|
pr: none
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
batch: 'true'
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- main
|
||||||
|
|
||||||
|
pool:
|
||||||
|
vmImage: 'windows-latest'
|
||||||
|
|
||||||
|
variables:
|
||||||
|
buildConfiguration: 'Release'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- task: GetRevision@1
|
||||||
|
displayName: 'Get Revision'
|
||||||
|
inputs:
|
||||||
|
VariableName: Revision
|
||||||
|
|
||||||
|
- task: Assembly-Info-NetCore@3
|
||||||
|
displayName: 'Set Assembly Info'
|
||||||
|
inputs:
|
||||||
|
Path: '$(Build.SourcesDirectory)'
|
||||||
|
FileNames: '**/*.csproj'
|
||||||
|
InsertAttributes: true
|
||||||
|
FileEncoding: 'utf-8'
|
||||||
|
WriteBOM: true
|
||||||
|
FailOnWarning: true
|
||||||
|
Authors: 'Chris Kaczor'
|
||||||
|
Copyright: 'Copyright $(date:YYYY) Chris Kaczor'
|
||||||
|
FileVersion: '1.0.$(Revision)'
|
||||||
|
PackageVersion: '1.0.$(Revision)'
|
||||||
|
|
||||||
|
- task: DotNetCoreCLI@2
|
||||||
|
displayName: 'dotnet build'
|
||||||
|
inputs:
|
||||||
|
command: 'build'
|
||||||
|
arguments: '--configuration $(buildConfiguration)'
|
||||||
|
projects: 'FeverClient.csproj'
|
||||||
|
|
||||||
|
- task: DotNetCoreCLI@2
|
||||||
|
displayName: "dotnet pack"
|
||||||
|
inputs:
|
||||||
|
command: 'pack'
|
||||||
|
arguments: '--configuration $(buildConfiguration)'
|
||||||
|
packagesToPack: 'FeverClient.csproj'
|
||||||
|
nobuild: true
|
||||||
|
versioningScheme: 'byBuildNumber'
|
||||||
|
|
||||||
|
- task: NuGetCommand@2
|
||||||
|
displayName: 'nuget push'
|
||||||
|
inputs:
|
||||||
|
command: 'push'
|
||||||
|
feedsToUse: 'select'
|
||||||
|
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
|
||||||
|
nuGetFeedType: external
|
||||||
|
publishFeedCredentials: 'NuGet'
|
||||||
|
publishVstsFeed: 'Packages'
|
||||||
|
versioningScheme: 'byBuildNumber'
|
||||||
|
allowPackageConflicts: true
|
||||||
Reference in New Issue
Block a user