-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLists.gs
190 lines (164 loc) · 8 KB
/
Lists.gs
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// Pinned Lists
/**
* Enables the authenticated user to pin a List.
*
* @param {string} id The user ID who you are pinning a List on behalf of. It must match your own user ID or that of an authenticating user, meaning that you must pass the Access Tokens associated with the user ID when authenticating your request.
* @param {string} list_id The ID of the List that you would like the user <code>id</code> to pin.
* @return {Object} returns parsed response
*/
function pinnList(id,list_id){ return fetchPost_(ENDPOINT.concat(`users/${id}/pinned_lists`),{ list_id:list_id }); }
/**
* Enables the authenticated user to unpin a List.
*
* @param {string} id The user ID who you are unpin a List on behalf of. It must match your own user ID or that of an authenticating user, meaning that you must pass the Access Tokens associated with the user ID when authenticating your request.
* @param {string} list_id The ID of the List that you would like the user <code>id</code> to unpin.
* @return {Object} returns parsed response
*/
function unpinList(id,list_id){ return fetchDelete_(ENDPOINT.concat(`users/${id}/pinned_lists/${list_id}`)); }
/**
* Returns the Lists pinned by a specified user.
*
* @param {string} id The user ID whose pinned Lists you would like to retrieve. The user’s ID must correspond to the user ID of the authenticating user, meaning that you must pass the Access Tokens associated with the user ID when authenticating your request.
* @param {Object} fields see https://developer.twitter.com/en/docs/twitter-api/lists/pinned-lists/api-reference/get-users-id-pinned_lists for possible fields
* @return {Object} returns parsed response
*/
function getPinnedLists(id,fields){
if( !id ) throw 'user id is required';
return fetchGet_(ENDPOINT.concat(`users/${id}/pinned_lists`),fields);
}
// List follows
/**
* Enables the authenticated user to unfollow a List.
*
* @param {string} id The user ID who you are unfollowing a List on behalf of.
* @param {string} list_id The ID of the List that you would like the user id to unfollow.
* @return {Object} returns parsed response
*/
function unfollowList(id,list_id){ return fetchDelete_(ENDPOINT.concat(`users/${id}/followed_lists/${list_id}`)); }
/**
* Enables the authenticated user to follow a List.
*
* @param {string} id The user ID who you are following a List on behalf of.
* @param {string} list_id The ID of the List that you would like the user <code>id</code> to follow.
* @return {Object} returns parsed response
*/
function followList(id,list_id){ return fetchPost_(ENDPOINT.concat(`users/${id}/followed_lists`),{ list_id:list_id }); }
/**
* Returns all Lists a specified user follows.
*
* @param {string} id The user ID whose followed Lists you would like to retrieve.
* @param {Object} fields see https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/api-reference/get-users-id-followed_lists for possible fields
* @return {Object} returns parsed response
*/
function followedLists(id,fields){
if( !id ) throw 'user id is required';
return fetchGet_(ENDPOINT.concat(`users/${id}/followed_lists`),fields);
}
/**
* Returns a list of users who are followers of the specified List.
*
* @param {string} id The ID of the List whose followers you would like to retrieve.
* @param {Object} fields see https://developer.twitter.com/en/docs/twitter-api/lists/list-follows/api-reference/get-lists-id-followers for possible fields
* @return {Object} returns parsed response
*/
function listFollowers(id,fields){
if( !id ) throw 'list id is required';
return fetchGet_(ENDPOINT.concat(`lists/${id}/followers`),fields);
}
// List members
/**
* Enables the authenticated user to add a member to a List they own.
*
* @param {stirng} id The ID of the List you are adding a member to.
* @param {string} user_id The ID of the user you wish to add as a member of the List.
* @return {Object} returns parsed response
*/
function addListMember(id,user_id){ return fetchPost_(ENDPOINT.concat(`lists/${id}/members`),{ user_id:user_id }); }
/**
* Enables the authenticated user to remove a member from a List they own.
*
* @param {string} id The ID of the List you are removing a member from.
* @param {string} user_id The ID of the user you wish to remove as a member of the List.
* @return {Object} returns parsed response
*/
function deleteListMember(id,user_id){ return fetchDelete_(ENDPOINT.concat(`lists/${id}/members/${user_id}`)); }
/**
* Returns all Lists a specified user is a member of.
*
* @param {string} id The user ID whose List memberships you would like to retrieve.
* @param {Object} fields see https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/get-users-id-list_memberships for possible fields
* @return {Object} returns parsed response
*/
function listMemberships(id,fields){
if( !id ) throw 'user id is required';
return fetchGet_(ENDPOINT.concat(`users/${id}/list_memberships`),fields);
}
/**
* Returns a list of users who are members of the specified List.
*
* @param {string} id The ID of the List whose members you would like to retrieve.
* @param {Object} fields see https://developer.twitter.com/en/docs/twitter-api/lists/list-members/api-reference/get-lists-id-members for possible fields
* @return {Object} returns parsed response
*/
function listMembers(id,fields){
if( !id ) throw 'list id is required';
return fetchGet_(ENDPOINT.concat(`lists/${id}/members`),fields );
}
// List Tweets lookup
/**
* Returns a list of Tweets from the specified List.
*
* @param {string} id The ID of the List whose Tweets you would like to retrieve.
* @param {Object} fields see https://developer.twitter.com/en/docs/twitter-api/lists/list-tweets/api-reference/get-lists-id-tweets for possible fields
* @return {Object} returns parsed response
*/
function getListTweets(id,fields){
if( !id ) throw 'list id is required';
return fetchGet_(ENDPOINT.concat(`lists/${id}/tweets`),fields );
}
// Manage Lists
/**
* Enables the authenticated user to delete a List that they own.
*
* @param {string} id The ID of the List to be deleted.
* @return {Object} returns parsed response
*/
function deleteList(id){ return fetchDelete_(ENDPOINT.concat(`lists/${id}`)); }
/**
* Enables the authenticated user to update the meta data of a specified List that they own.
*
* @param {string} id The ID of the List to be updated.
* @param {Object} body see https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/put-lists-id for possible params
* @return {Object} returns parsed response
*/
function updateList(id,body){ return fetchPut_(ENDPOINT.concat(`lists/${id}`),body); }
/**
* Enables the authenticated user to create a List.
*
* @param {Object} body see https://developer.twitter.com/en/docs/twitter-api/lists/manage-lists/api-reference/post-lists for possible params
* @return {Object} returns parsed response
*/
function createList(body){ return fetchPost_(ENDPOINT.concat('lists'),body); }
// List lookup
/**
* Returns all Lists owned by the specified user.
*
* @param {string} id The user ID whose owned Lists you would like to retrieve.
* @param {Object} fields see https://developer.twitter.com/en/docs/twitter-api/lists/list-lookup/api-reference/get-users-id-owned_lists for possible fields
* @return {Object} returns parsed response
*/
function getownedLists(id,fields){
if( !id ) throw 'user id is required';
return fetchGet_(ENDPOINT.concat(`users/${id}/owned_lists`),fields);
}
/**
* Returns the details of a specified List.
*
* @param {(string|number)} id The ID of the List to lookup.
* @param {Object} fields see https://developer.twitter.com/en/docs/twitter-api/lists/list-lookup/api-reference/get-lists-id for possible fields
* @return {Object} returns parsed response
*/
function getList(id, fields){
if( !id ) throw 'list id is required';
return fetchGet_(ENDPOINT.concat(`lists/${id}`),fields);
}