From cdc93d2a030958edbec136907aa51f3580f15fc0 Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Wed, 24 Sep 2025 19:35:13 -0400 Subject: [PATCH] Initial commit --- .gitignore | 484 ++++++++++++++++++++++ Converters/BoolConverter.cs | 25 ++ Converters/CommaSeparatedListConverter.cs | 25 ++ Converters/EpochConverter.cs | 24 ++ FeverClient.cs | 103 +++++ FeverClient.csproj | 34 ++ FeverClient.sln | 25 ++ FeverClient.sln.DotSettings | 2 + LICENSE | 21 + Models/Favicon.cs | 14 + Models/Feed.cs | 26 ++ Models/FeedGroup.cs | 14 + Models/FeedItem.cs | 35 ++ Models/Group.cs | 14 + README.md | 17 + Responses/BaseResponse.cs | 15 + Responses/GetFaviconsResponse.cs | 10 + Responses/GetFeedItemsResponse.cs | 13 + Responses/GetFeedsResponse.cs | 13 + Responses/GetGroupsResponse.cs | 13 + azure-pipelines.yml | 63 +++ 21 files changed, 990 insertions(+) create mode 100644 .gitignore create mode 100644 Converters/BoolConverter.cs create mode 100644 Converters/CommaSeparatedListConverter.cs create mode 100644 Converters/EpochConverter.cs create mode 100644 FeverClient.cs create mode 100644 FeverClient.csproj create mode 100644 FeverClient.sln create mode 100644 FeverClient.sln.DotSettings create mode 100644 LICENSE create mode 100644 Models/Favicon.cs create mode 100644 Models/Feed.cs create mode 100644 Models/FeedGroup.cs create mode 100644 Models/FeedItem.cs create mode 100644 Models/Group.cs create mode 100644 README.md create mode 100644 Responses/BaseResponse.cs create mode 100644 Responses/GetFaviconsResponse.cs create mode 100644 Responses/GetFeedItemsResponse.cs create mode 100644 Responses/GetFeedsResponse.cs create mode 100644 Responses/GetGroupsResponse.cs create mode 100644 azure-pipelines.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc78471 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/Converters/BoolConverter.cs b/Converters/BoolConverter.cs new file mode 100644 index 0000000..b3e70d4 --- /dev/null +++ b/Converters/BoolConverter.cs @@ -0,0 +1,25 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace ChrisKaczor.FeverClient.Converters +{ + public class BoolTimestampConverter : JsonConverter + { + 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); + } + } +} \ No newline at end of file diff --git a/Converters/CommaSeparatedListConverter.cs b/Converters/CommaSeparatedListConverter.cs new file mode 100644 index 0000000..d4d72d6 --- /dev/null +++ b/Converters/CommaSeparatedListConverter.cs @@ -0,0 +1,25 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace ChrisKaczor.FeverClient.Converters; + +internal class CommaSeparatedListConverter : JsonConverter> +{ + public override IEnumerable 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 value, JsonSerializerOptions options) + { + var commaSeparatedList = string.Join(",", value); + writer.WriteStringValue(commaSeparatedList); + } +} \ No newline at end of file diff --git a/Converters/EpochConverter.cs b/Converters/EpochConverter.cs new file mode 100644 index 0000000..368e13f --- /dev/null +++ b/Converters/EpochConverter.cs @@ -0,0 +1,24 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace ChrisKaczor.FeverClient.Converters; + +public class EpochConverter : JsonConverter +{ + 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); + } +} \ No newline at end of file diff --git a/FeverClient.cs b/FeverClient.cs new file mode 100644 index 0000000..0d92f30 --- /dev/null +++ b/FeverClient.cs @@ -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 PostRestRequest(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(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> GetGroups() + { + var groupsResponse = await PostRestRequest("groups"); + + return groupsResponse.Groups; + } + + public async Task> GetFeeds() + { + var feedsResponse = await PostRestRequest("feeds"); + + return feedsResponse.Feeds; + } + + public async Task> GetFavicons() + { + var faviconsResponse = await PostRestRequest("favicons"); + + return faviconsResponse.Favicons; + } + + public async Task> GetFeedItems(int sinceId = 1) + { + var feedItemsResponse = await PostRestRequest($"items&since_id={sinceId}"); + + return feedItemsResponse.FeedItems; + } + + public async Task> GetAllFeedItems() + { + var allFeedItems = new List(); + + 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($"mark=item&as=read&id={feedItemId}"); + } +} \ No newline at end of file diff --git a/FeverClient.csproj b/FeverClient.csproj new file mode 100644 index 0000000..054f52f --- /dev/null +++ b/FeverClient.csproj @@ -0,0 +1,34 @@ + + + + net8.0 + enable + enable + ChrisKaczor.FeverClient + ChrisKaczor.FeverClient + Chris Kaczor + ChrisKaczor.FeverClient + https://github.com/ckaczor/ChrisKaczor.FeverClient + README.md + This library can be used to read RSS feeds via the Fever API in Miniflux or other similar feed readers/servers. + ChrisKaczor.FeverClient + ChrisKaczor.FeverClient + + + + + + + + + + + + + + True + \ + + + + diff --git a/FeverClient.sln b/FeverClient.sln new file mode 100644 index 0000000..35e9d68 --- /dev/null +++ b/FeverClient.sln @@ -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 diff --git a/FeverClient.sln.DotSettings b/FeverClient.sln.DotSettings new file mode 100644 index 0000000..c960585 --- /dev/null +++ b/FeverClient.sln.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c3e95b8 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/Models/Favicon.cs b/Models/Favicon.cs new file mode 100644 index 0000000..a673c22 --- /dev/null +++ b/Models/Favicon.cs @@ -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; } +} \ No newline at end of file diff --git a/Models/Feed.cs b/Models/Feed.cs new file mode 100644 index 0000000..8f15f4d --- /dev/null +++ b/Models/Feed.cs @@ -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; } +} \ No newline at end of file diff --git a/Models/FeedGroup.cs b/Models/FeedGroup.cs new file mode 100644 index 0000000..fc98900 --- /dev/null +++ b/Models/FeedGroup.cs @@ -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 FeedIds { get; set; } +} \ No newline at end of file diff --git a/Models/FeedItem.cs b/Models/FeedItem.cs new file mode 100644 index 0000000..4c2e5a9 --- /dev/null +++ b/Models/FeedItem.cs @@ -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; } +} \ No newline at end of file diff --git a/Models/Group.cs b/Models/Group.cs new file mode 100644 index 0000000..81b30fb --- /dev/null +++ b/Models/Group.cs @@ -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; } +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d925747 --- /dev/null +++ b/README.md @@ -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. \ No newline at end of file diff --git a/Responses/BaseResponse.cs b/Responses/BaseResponse.cs new file mode 100644 index 0000000..354b6ac --- /dev/null +++ b/Responses/BaseResponse.cs @@ -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; } +} \ No newline at end of file diff --git a/Responses/GetFaviconsResponse.cs b/Responses/GetFaviconsResponse.cs new file mode 100644 index 0000000..5874fbe --- /dev/null +++ b/Responses/GetFaviconsResponse.cs @@ -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 Favicons { get; set; } +} \ No newline at end of file diff --git a/Responses/GetFeedItemsResponse.cs b/Responses/GetFeedItemsResponse.cs new file mode 100644 index 0000000..3fa9ce3 --- /dev/null +++ b/Responses/GetFeedItemsResponse.cs @@ -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 FeedItems { get; set; } + + [JsonPropertyName("total_items")] + public required int TotalItems { get; set; } +} \ No newline at end of file diff --git a/Responses/GetFeedsResponse.cs b/Responses/GetFeedsResponse.cs new file mode 100644 index 0000000..27d426a --- /dev/null +++ b/Responses/GetFeedsResponse.cs @@ -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 Feeds { get; set; } + + [JsonPropertyName("feeds_groups")] + public required IEnumerable FeedGroups { get; set; } +} \ No newline at end of file diff --git a/Responses/GetGroupsResponse.cs b/Responses/GetGroupsResponse.cs new file mode 100644 index 0000000..4c9b336 --- /dev/null +++ b/Responses/GetGroupsResponse.cs @@ -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 Groups { get; set; } + + [JsonPropertyName("feeds_groups")] + public required IEnumerable FeedGroups { get; set; } +} \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..b527f93 --- /dev/null +++ b/azure-pipelines.yml @@ -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 \ No newline at end of file