summaryrefslogtreecommitdiff
path: root/include/newsblurapi.h
blob: 9ace6f1a95ed889c3f33d2fbaaf959b5ca2637d1 (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
#ifndef NEWSBOAT_NEWSBLURAPI_H_
#define NEWSBOAT_NEWSBLURAPI_H_

#include <json.h>

#include "remoteapi.h"
#include "rss/feed.h"
#include "utils.h"

#define ID_SEPARATOR "/////"

using HTTPMethod = newsboat::utils::HTTPMethod;

namespace newsboat {

typedef std::map<std::string, rsspp::Feed> FeedMap;

class NewsBlurApi : public RemoteApi {
public:
	explicit NewsBlurApi(ConfigContainer* c);
	~NewsBlurApi() override;
	bool authenticate() override;
	std::vector<TaggedFeedUrl> get_subscribed_urls() override;
	void add_custom_headers(curl_slist** custom_headers) 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;
	rsspp::Feed fetch_feed(const std::string& id);

private:
	std::string retrieve_auth();
	json_object* query_api(const std::string& url,
		const std::string* body,
		const HTTPMethod method = HTTPMethod::GET);
	std::map<std::string, std::vector<std::string>> mk_feeds_to_tags(
			json_object*);
	std::string api_location;
	FeedMap known_feeds;
	unsigned int min_pages;
};

} // namespace newsboat

#endif /* NEWSBOAT_NEWSBLURAPI_H_ */