Sha256: 285d94f1557dba6a3f3d42db736953369c221f7b225856f12caa3f726f538785
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require "httparty" require "date" require_relative "hash" class MinifluxApi include HTTParty maintain_method_across_redirects true def initialize(host:, token:) self.class.base_uri "#{host}/v1/" @options = { :headers => { "X-Auth-Token": token, "Accept": "application/json" } } end def get_entries(before:, limit: 100, offset:, status: 'unread', direction: 'asc') begin custom_options = @options.deep_merge({ :query => { :status => status, :direction => direction, :before => before, :offset => offset, :limit => limit } }) response = self.class.get("/entries", custom_options) response_code = response.code.to_i if response_code >= 400 raise response.parsed_response else response.parsed_response["entries"] end rescue => error puts "Could not get entries from your Miniflux server. More details to follow.", error exit end end # Pass in an array of IDs def mark_entries_read(ids:) new_options = @options.deep_merge({ :headers => { "Content-Type": "application/json" }, :body => { :entry_ids => ids, :status => "read" }.to_json }) response = self.class.put("/entries", new_options) if response.code.to_i == 204 puts "Marked entries with ID #{ids.join ", "} as read." else puts "Could not mark entries with ID #{ids.join ", "} as read" exit(false) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
miniflux_sanity-0.2.2 | lib/miniflux_api.rb |
miniflux_sanity-0.2.1 | lib/miniflux_api.rb |
miniflux_sanity-0.2.0 | lib/miniflux_api.rb |