summaryrefslogtreecommitdiff
path: root/include/minifluxapi.h
blob: 9b2dff824d6d9d1c3ef00b073df73623ac8c76c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef NEWSBOAT_MINIFLUXAPI_H_
#define NEWSBOAT_MINIFLUXAPI_H_

#include "3rd-party/json.hpp"
#include "remoteapi.h"
#include "rss/feed.h"
#include "utils.h"

using HTTPMethod = newsboat::utils::HTTPMethod;

namespace newsboat {

class CurlHandle;

class MinifluxApi : public RemoteApi {
public:
	explicit MinifluxApi(ConfigContainer* cfg);
	~MinifluxApi() override;
	bool authenticate() override;
	std::vector<TaggedFeedUrl> get_subscribed_urls() override;
	bool mark_all_read(const std::string& feedurl) override;
	bool mark_article_read(const std::string& guid, bool read) override;
	bool update_article_flags(const std::string& oldflags,
		const std::string& newflags,
		const std::string& guid) override;
	void add_custom_headers(curl_slist**) override;
	rsspp::Feed fetch_feed(const std::string& id);
	rsspp::Feed fetch_feed(const std::string& id, CurlHandle& easyhandle);

private:
	virtual nlohmann::json run_op(const std::string& path,
		const nlohmann::json& req_data,
		const HTTPMethod method = HTTPMethod::GET);
	virtual nlohmann::json run_op(const std::string& path,
		const nlohmann::json& req_data,
		CurlHandle& cached_handle,
		const HTTPMethod method = HTTPMethod::GET);
	TaggedFeedUrl feed_from_json(const nlohmann::json& jfeed,
		const std::vector<std::string>& tags);
	bool flag_changed(const std::string& oldflags,
		const std::string& newflags,
		const std::string& flagstr);
	bool update_articles(const std::vector<std::string> guids,
		nlohmann::json& args);
	bool update_article(const std::string& guid, nlohmann::json& args);
	std::string auth_info;
	std::string server;
};

} // namespace newsboat

#endif /* NEWSBOAT_MINIFLUXAPI_H_ */