CocoaTweet
key.h
Go to the documentation of this file.
1 #ifndef COCOATWEET_OAUTH_KEY_H_
2 #define COCOATWEET_OAUTH_KEY_H_
3 
4 #include <string>
5 #include <map>
6 
7 namespace CocoaTweet::OAuth {
8 class Key {
9  std::string consumerKey_;
10  std::string consumerSecret_;
11  std::string accessToken_;
12  std::string accessTokenSecret_;
13  std::string bearerToken_;
14 
15 public:
16  Key() : consumerKey_(""), consumerSecret_(""), accessToken_(""), accessTokenSecret_("") {}
17  Key(const std::string& _consumerKey, const std::string& _consumerSecret,
18  const std::string& _accessToken, const std::string& _accessTokenSecret)
19  : consumerKey_(_consumerKey),
20  consumerSecret_(_consumerSecret),
21  accessToken_(_accessToken),
22  accessTokenSecret_(_accessTokenSecret) {}
23  Key(const std::string& _consumerKey, const std::string& _consumerSecret)
24  : consumerKey_(_consumerKey), consumerSecret_(_consumerSecret) {}
25 
26  void consumerKey(const std::string& _consumerKey) {
27  consumerKey_ = _consumerKey;
28  }
29 
30  void consumerSecret(const std::string& _consumerSecret) {
31  consumerSecret_ = _consumerSecret;
32  }
33 
34  void accessToken(const std::string& _accessToken) {
35  accessToken_ = _accessToken;
36  }
37 
38  void accessTokenSecret(const std::string& _accessTokenSecret) {
39  accessTokenSecret_ = _accessTokenSecret;
40  }
41 
42  void bearerToken(const std::string& _bearer) {
43  bearerToken_ = _bearer;
44  }
45  const std::string& consumerKey() const {
46  return consumerKey_;
47  }
48  const std::string& consumerSecret() const {
49  return consumerSecret_;
50  }
51  const std::string& accessToken() const {
52  return accessToken_;
53  }
54  const std::string& accessTokenSecret() const {
55  return accessTokenSecret_;
56  }
57 
58  const std::string& bearerToken() const {
59  return bearerToken_;
60  }
61 
62  std::map<std::string, std::string> noSecret() const {
63  return std::map<std::string, std::string>{{"oauth_consumer_key", consumerKey_},
64  {"oauth_token", accessToken_}};
65  }
66  const std::map<std::string, std::string> secret() const {
67  return std::map<std::string, std::string>{{"oauth_consumer_key", consumerSecret_},
68  {"oauth_token", accessTokenSecret_}};
69  }
70 
71  static Key fromJsonFile(const std::string _jsonFile);
72 };
73 } // namespace CocoaTweet::OAuth
74 
75 #endif
CocoaTweet::OAuth::Key::bearerToken
void bearerToken(const std::string &_bearer)
Definition: key.h:42
CocoaTweet::OAuth::Key::Key
Key(const std::string &_consumerKey, const std::string &_consumerSecret)
Definition: key.h:23
CocoaTweet::OAuth::Key::accessTokenSecret
void accessTokenSecret(const std::string &_accessTokenSecret)
Definition: key.h:38
CocoaTweet::OAuth::Key::secret
const std::map< std::string, std::string > secret() const
Definition: key.h:66
CocoaTweet::OAuth::Key::fromJsonFile
static Key fromJsonFile(const std::string _jsonFile)
Definition: key.cc:8
CocoaTweet::OAuth::Key::consumerKey
const std::string & consumerKey() const
Definition: key.h:45
CocoaTweet::OAuth::Key::Key
Key(const std::string &_consumerKey, const std::string &_consumerSecret, const std::string &_accessToken, const std::string &_accessTokenSecret)
Definition: key.h:17
CocoaTweet::OAuth::Key::consumerSecret
void consumerSecret(const std::string &_consumerSecret)
Definition: key.h:30
CocoaTweet::OAuth::Key
Definition: key.h:8
CocoaTweet::OAuth::Key::noSecret
std::map< std::string, std::string > noSecret() const
Definition: key.h:62
CocoaTweet::OAuth::Key::accessToken
const std::string & accessToken() const
Definition: key.h:51
CocoaTweet::OAuth::Key::bearerToken
const std::string & bearerToken() const
Definition: key.h:58
CocoaTweet::OAuth::Key::consumerSecret
const std::string & consumerSecret() const
Definition: key.h:48
CocoaTweet::OAuth::Key::accessToken
void accessToken(const std::string &_accessToken)
Definition: key.h:34
CocoaTweet::OAuth::Key::accessTokenSecret
const std::string & accessTokenSecret() const
Definition: key.h:54
CocoaTweet::OAuth::Key::Key
Key()
Definition: key.h:16
CocoaTweet::OAuth::Key::consumerKey
void consumerKey(const std::string &_consumerKey)
Definition: key.h:26
CocoaTweet::OAuth
Definition: key.cc:7