1 module twitter.twitter; 2 3 import twitter.api; 4 import twitter.twitterbase; 5 6 import std.conv : to; 7 import vibe.data.json : Json; 8 import vibe.http.common : HTTPMethod; 9 10 /// 11 class Twitter : TwitterBase, TwitterAPI 12 { 13 /// 14 this(TwitterCredentials credentials) 15 { 16 super(credentials); 17 } 18 19 /// 20 FollowersList followers(string screen_name, long cursor = -1, 21 bool skip_status = true, bool include_user_entities = false) 22 { 23 static immutable METHOD_URL = "/1.1/followers/list.json"; 24 25 string[string] params; 26 params["screen_name"] = screen_name; 27 params["cursor"] = cursor.to!string; 28 params["skip_status"] = skip_status.to!string; 29 params["include_user_entities"] = include_user_entities.to!string; 30 31 return this.request!(FollowersList)(METHOD_URL, HTTPMethod.GET, params); 32 } 33 34 /// 35 IdsList friendsIds(string screen_name, long cursor = -1) 36 { 37 static immutable METHOD_URL = "/1.1/friends/ids.json"; 38 39 string[string] params; 40 params["screen_name"] = screen_name; 41 params["cursor"] = cursor.to!string; 42 43 return this.request!(IdsList)(METHOD_URL, HTTPMethod.GET, params); 44 } 45 46 /// 47 Json appRateLimitStatus() 48 { 49 static immutable METHOD_URL = "/1.1/application/rate_limit_status.json"; 50 51 string[string] params; 52 53 return this.request!(Json)(METHOD_URL, HTTPMethod.GET, params); 54 } 55 56 /// 57 Status status(string status) 58 { 59 static immutable METHOD_URL = "/1.1/statuses/update.json"; 60 61 string[string] params; 62 params["status"] = status; 63 64 return this.request!(Status)(METHOD_URL, HTTPMethod.POST, params); 65 } 66 67 /// 68 Status statusShow(long id) 69 { 70 static immutable METHOD_URL = "/1.1/statuses/show.json"; 71 72 string[string] params; 73 params["id"] = id.to!string; 74 75 return this.request!(Status)(METHOD_URL, HTTPMethod.GET, params); 76 } 77 78 /// 79 SearchResult searchTweets(string q, string lang = null, int count = 15) 80 { 81 static immutable METHOD_URL = "/1.1/search/tweets.json"; 82 83 string[string] params; 84 params["q"] = q; 85 params["count"] = count.to!string; 86 if (lang) 87 params["lang"] = lang; 88 89 return this.request!(SearchResult)(METHOD_URL, HTTPMethod.GET, params); 90 } 91 92 /// 93 TwitterUser friendshipsCreate(ulong user_id) 94 { 95 static immutable METHOD_URL = "/1.1/friendships/create.json"; 96 97 string[string] params; 98 params["user_id"] = user_id.to!string; 99 100 return this.request!(TwitterUser)(METHOD_URL, HTTPMethod.POST, params); 101 } 102 103 /// 104 TwitterUser friendshipsDestroy(ulong user_id) 105 { 106 static immutable METHOD_URL = "/1.1/friendships/destroy.json"; 107 108 string[string] params; 109 params["user_id"] = user_id.to!string; 110 111 return this.request!(TwitterUser)(METHOD_URL, HTTPMethod.POST, params); 112 } 113 }