about summary refs log tree commit diff stats
path: root/src/client.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2016-11-29 16:18:25 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2016-11-29 16:18:25 -0500
commit7c44fd17bb6be54a2ea4b60761e91053ca988977 (patch)
tree42f08e0db610617fd0629b117610bfa1a365acaf /src/client.cpp
parentd90a1e74c77ba67f25a812609fd49d479bc464dd (diff)
downloadlibtwittercpp-7c44fd17bb6be54a2ea4b60761e91053ca988977.tar.gz
libtwittercpp-7c44fd17bb6be54a2ea4b60761e91053ca988977.tar.bz2
libtwittercpp-7c44fd17bb6be54a2ea4b60761e91053ca988977.zip
Made tweets, users, and notifications into copyable objects
Notifications are now also mutable. Users and tweets no longer have helper methods for interacting with the client. Fixed a bug (possibly introduced by a change to the Twitter API) that caused non-reply tweets to be marked as unknown notifications.
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/client.cpp b/src/client.cpp index f8908fd..e16e30b 100644 --- a/src/client.cpp +++ b/src/client.cpp
@@ -330,7 +330,7 @@ namespace twitter {
330 _oauth_token.get()); 330 _oauth_token.get());
331 331
332 _current_user = 332 _current_user =
333 make_unique<user>(*this, 333 make_unique<user>(
334 get(*_oauth_client, 334 get(*_oauth_client,
335 "https://api.twitter.com/1.1/account/verify_credentials.json") 335 "https://api.twitter.com/1.1/account/verify_credentials.json")
336 .perform()); 336 .perform());
@@ -349,7 +349,7 @@ namespace twitter {
349 datastrstream << twitter::implode(std::begin(media_ids), std::end(media_ids), ","); 349 datastrstream << twitter::implode(std::begin(media_ids), std::end(media_ids), ",");
350 } 350 }
351 351
352 return tweet(*this, 352 return tweet(
353 post(*_oauth_client, 353 post(*_oauth_client,
354 "https://api.twitter.com/1.1/statuses/update.json", 354 "https://api.twitter.com/1.1/statuses/update.json",
355 datastrstream.str()) 355 datastrstream.str())
@@ -369,7 +369,7 @@ namespace twitter {
369 datastrstream << twitter::implode(std::begin(media_ids), std::end(media_ids), ","); 369 datastrstream << twitter::implode(std::begin(media_ids), std::end(media_ids), ",");
370 } 370 }
371 371
372 return tweet(*this, 372 return tweet(
373 post(*_oauth_client, 373 post(*_oauth_client,
374 "https://api.twitter.com/1.1/statuses/update.json", 374 "https://api.twitter.com/1.1/statuses/update.json",
375 datastrstream.str()) 375 datastrstream.str())
@@ -533,6 +533,16 @@ namespace twitter {
533 return result; 533 return result;
534 } 534 }
535 535
536 std::set<user_id> client::getFriends(const user& id) const
537 {
538 return getFriends(id.getID());
539 }
540
541 std::set<user_id> client::getFriends() const
542 {
543 return getFriends(getUser().getID());
544 }
545
536 std::set<user_id> client::getFollowers(user_id id) const 546 std::set<user_id> client::getFollowers(user_id id) const
537 { 547 {
538 long long cursor = -1; 548 long long cursor = -1;
@@ -567,6 +577,16 @@ namespace twitter {
567 return result; 577 return result;
568 } 578 }
569 579
580 std::set<user_id> client::getFollowers(const user& id) const
581 {
582 return getFollowers(id.getID());
583 }
584
585 std::set<user_id> client::getFollowers() const
586 {
587 return getFollowers(getUser().getID());
588 }
589
570 void client::follow(user_id toFollow) const 590 void client::follow(user_id toFollow) const
571 { 591 {
572 std::stringstream datastrstream; 592 std::stringstream datastrstream;
@@ -576,6 +596,11 @@ namespace twitter {
576 post(*_oauth_client, "https://api.twitter.com/1.1/friendships/create.json", datastrstream.str()).perform(); 596 post(*_oauth_client, "https://api.twitter.com/1.1/friendships/create.json", datastrstream.str()).perform();
577 } 597 }
578 598
599 void client::follow(const user& toFollow) const
600 {
601 return follow(toFollow.getID());
602 }
603
579 void client::unfollow(user_id toUnfollow) const 604 void client::unfollow(user_id toUnfollow) const
580 { 605 {
581 std::stringstream datastrstream; 606 std::stringstream datastrstream;
@@ -584,6 +609,11 @@ namespace twitter {
584 609
585 post(*_oauth_client, "https://api.twitter.com/1.1/friendships/destroy.json", datastrstream.str()).perform(); 610 post(*_oauth_client, "https://api.twitter.com/1.1/friendships/destroy.json", datastrstream.str()).perform();
586 } 611 }
612
613 void client::unfollow(const user& toUnfollow) const
614 {
615 return unfollow(toUnfollow.getID());
616 }
587 617
588 const user& client::getUser() const 618 const user& client::getUser() const
589 { 619 {