Class: MinifluxApi
Instance Method Summary collapse
- #get_entries(before:, limit: 100, offset:, status: 'unread', direction: 'asc') ⇒ Object
-
#initialize(host:, token:) ⇒ MinifluxApi
constructor
A new instance of MinifluxApi.
-
#mark_entries_read(ids:) ⇒ Object
Pass in an array of IDs.
Constructor Details
#initialize(host:, token:) ⇒ MinifluxApi
Returns a new instance of MinifluxApi.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/miniflux_api.rb', line 9 def initialize(host:, token:) self.class.base_uri "#{host}/v1/" @options = { :headers => { "X-Auth-Token": token, "Accept": "application/json" } } end |
Instance Method Details
#get_entries(before:, limit: 100, offset:, status: 'unread', direction: 'asc') ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/miniflux_api.rb', line 20 def get_entries(before:, limit: 100, offset:, status: 'unread', direction: 'asc') begin = @options.deep_merge({ :query => { :status => status, :direction => direction, :before => before, :offset => offset, :limit => limit } }) response = self.class.get("/entries", ) 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 |
#mark_entries_read(ids:) ⇒ Object
Pass in an array of IDs
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/miniflux_api.rb', line 46 def mark_entries_read(ids:) = @options.deep_merge({ :headers => { "Content-Type": "application/json" }, :body => { :entry_ids => ids, :status => "read" }.to_json }) response = self.class.put("/entries", ) 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 |