Module: ExTwitter::ExistingApi
- Included in:
- Client
- Defined in:
- lib/ex_twitter/existing_api.rb
Instance Method Summary collapse
- #favorites(*args) ⇒ Object
- #follower_ids(*args) ⇒ Object
-
#followers(*args) ⇒ Object
specify reduce: false to use tweet for inactive_*.
- #friend_ids(*args) ⇒ Object
-
#friends(*args) ⇒ Object
specify reduce: false to use tweet for inactive_*.
- #friendship?(*args) ⇒ Boolean
- #home_timeline(*args) ⇒ Object
- #mentions_timeline(*args) ⇒ Object
- #search(*args) ⇒ Object
- #user(*args) ⇒ Object
- #user?(*args) ⇒ Boolean
- #user_timeline(*args) ⇒ Object
-
#users(*args) ⇒ Object
use compact, not use sort and uniq specify reduce: false to use tweet for inactive_* TODO Perhaps ‘old_users` automatically merges result…
- #verify_credentials(*args) ⇒ Object
Instance Method Details
#favorites(*args) ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/ex_twitter/existing_api.rb', line 111 def favorites(*args) = {count: 100, call_count: 1}.merge(args.) args[0] = verify_credentials(skip_status: true).id if args.empty? fetch_cache_or_call_api(__method__, args[0], ) { collect_with_max_id("old_#{__method__}", *args, ) } end |
#follower_ids(*args) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/ex_twitter/existing_api.rb', line 41 def follower_ids(*args) = {count: 5000, cursor: -1}.merge(args.) args[0] = verify_credentials(skip_status: true).id if args.empty? fetch_cache_or_call_api(__method__, args[0], ) { collect_with_cursor("old_#{__method__}", *args, ) } end |
#followers(*args) ⇒ Object
specify reduce: false to use tweet for inactive_*
60 61 62 63 64 65 66 67 |
# File 'lib/ex_twitter/existing_api.rb', line 60 def followers(*args) = {count: 200, include_user_entities: true, cursor: -1}.merge(args.) [:reduce] = false unless .has_key?(:reduce) args[0] = verify_credentials(skip_status: true).id if args.empty? fetch_cache_or_call_api(__method__, args[0], ) { collect_with_cursor("old_#{__method__}", *args, ) } end |
#friend_ids(*args) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ex_twitter/existing_api.rb', line 33 def friend_ids(*args) = {count: 5000, cursor: -1}.merge(args.) args[0] = verify_credentials(skip_status: true).id if args.empty? fetch_cache_or_call_api(__method__, args[0], ) { collect_with_cursor("old_#{__method__}", *args, ) } end |
#friends(*args) ⇒ Object
specify reduce: false to use tweet for inactive_*
50 51 52 53 54 55 56 57 |
# File 'lib/ex_twitter/existing_api.rb', line 50 def friends(*args) = {count: 200, include_user_entities: true, cursor: -1}.merge(args.) [:reduce] = false unless .has_key?(:reduce) args[0] = verify_credentials(skip_status: true).id if args.empty? fetch_cache_or_call_api(__method__, args[0], ) { collect_with_cursor("old_#{__method__}", *args, ) } end |
#friendship?(*args) ⇒ Boolean
10 11 12 13 14 15 |
# File 'lib/ex_twitter/existing_api.rb', line 10 def friendship?(*args) = args. fetch_cache_or_call_api(__method__, args) { call_old_method("old_#{__method__}", *args, ) } end |
#home_timeline(*args) ⇒ Object
89 90 91 92 93 94 |
# File 'lib/ex_twitter/existing_api.rb', line 89 def home_timeline(*args) = {count: 200, include_rts: true, call_limit: 3}.merge(args.) fetch_cache_or_call_api(__method__, user.id, ) { collect_with_max_id("old_#{__method__}", ) } end |
#mentions_timeline(*args) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/ex_twitter/existing_api.rb', line 104 def mentions_timeline(*args) = {count: 200, include_rts: true, call_limit: 1}.merge(args.) fetch_cache_or_call_api(__method__, user.id, ) { collect_with_max_id("old_#{__method__}", ) } end |
#search(*args) ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/ex_twitter/existing_api.rb', line 119 def search(*args) = {count: 100, result_type: :recent, call_limit: 1}.merge(args.) [:reduce] = false fetch_cache_or_call_api(__method__, args[0], ) { collect_with_max_id("old_#{__method__}", *args, ) { |response| response.attrs[:statuses] } } end |
#user(*args) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ex_twitter/existing_api.rb', line 25 def user(*args) = args. args[0] = verify_credentials(skip_status: true).id if args.empty? fetch_cache_or_call_api(__method__, args[0], ) { call_old_method("old_#{__method__}", args[0], ) } end |
#user?(*args) ⇒ Boolean
17 18 19 20 21 22 23 |
# File 'lib/ex_twitter/existing_api.rb', line 17 def user?(*args) = args. args[0] = verify_credentials(skip_status: true).id if args.empty? fetch_cache_or_call_api(__method__, args[0], ) { call_old_method("old_#{__method__}", args[0], ) } end |
#user_timeline(*args) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/ex_twitter/existing_api.rb', line 96 def user_timeline(*args) = {count: 200, include_rts: true, call_limit: 3}.merge(args.) args[0] = verify_credentials(skip_status: true).id if args.empty? fetch_cache_or_call_api(__method__, args[0], ) { collect_with_max_id("old_#{__method__}", *args, ) } end |
#users(*args) ⇒ Object
use compact, not use sort and uniq specify reduce: false to use tweet for inactive_* TODO Perhaps ‘old_users` automatically merges result…
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ex_twitter/existing_api.rb', line 72 def users(*args) = args. [:reduce] = false users_per_workers = args.first.compact.each_slice(100).to_a processed_users = [] Parallel.each_with_index(users_per_workers, in_threads: [users_per_workers.size, 10].min) do |users_per_worker, i| _users = fetch_cache_or_call_api(__method__, users_per_worker, ) { call_old_method("old_#{__method__}", users_per_worker, ) } processed_users << {i: i, users: _users} end processed_users.sort_by{|p| p[:i] }.map{|p| p[:users] }.flatten.compact end |
#verify_credentials(*args) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/ex_twitter/existing_api.rb', line 3 def verify_credentials(*args) = {skip_status: true}.merge(args.) fetch_cache_or_call_api(__method__, args) { call_old_method("old_#{__method__}", *args, ) } end |