about summary refs log tree commit diff stats
path: root/src/client.h
blob: 5e2ab1ce1a7fcf0d2e922d1c3dd8fbd034304bfd (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef TWITTER_H_ABFF6A12
#define TWITTER_H_ABFF6A12

#include <list>
#include <set>
#include <ctime>
#include <memory>
#include "codes.h"
#include "tweet.h"
#include "auth.h"
#include "configuration.h"
#include "util.h"
#include "timeline.h"

namespace twitter {

  class client {
  public:

    client(const auth& arg);

    tweet updateStatus(std::string msg, std::list<long> media_ids = {}) const;
    long uploadMedia(std::string media_type, const char* data, long data_length) const;

    tweet replyToTweet(std::string msg, tweet_id in_response_to, std::list<long> media_ids = {}) const;
    tweet replyToTweet(std::string msg, const tweet& in_response_to, std::list<long> media_ids = {}) const;

    std::set<user_id> getFriends(user_id id) const;
    std::set<user_id> getFriends(const user& u) const;
    std::set<user_id> getFriends() const;

    std::set<user_id> getFollowers(user_id id) const;
    std::set<user_id> getFollowers(const user& u) const;
    std::set<user_id> getFollowers() const;

    std::set<user_id> getBlocks() const;

    void follow(user_id toFollow) const;
    void follow(const user& toFollow) const;

    void unfollow(user_id toUnfollow) const;
    void unfollow(const user& toUnfollow) const;

    const user& getUser() const;

    const configuration& getConfiguration() const;

    timeline& getHomeTimeline()
    {
      return homeTimeline_;
    }

    timeline& getMentionsTimeline()
    {
      return mentionsTimeline_;
    }

  private:

    const auth& auth_;

    user currentUser_;

    mutable std::unique_ptr<configuration> _configuration;
    mutable time_t _last_configuration_update;

    timeline homeTimeline_ {
      auth_,
      "https://api.twitter.com/1.1/statuses/home_timeline.json"};

    timeline mentionsTimeline_ {
      auth_,
      "https://api.twitter.com/1.1/statuses/mentions_timeline.json"};
  };

};

#endif /* end of include guard: TWITTER_H_ABFF6A12 */