tweetust 0.10.0

The Twitter API wrapper
Documentation
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
#namespace RestTest
#description This contains several types of api for testing.

// comment
# comment
/*
    multi
    line
    comment
    (last line must starts with */, or will be ignored)
*/

/*
Usage:

endpoint (Type | void | Listed<Type> | Cursored<Type> | Dictionary<Type>) Name : (Impl | (Get | Post) endpoint_name)
{
    with // optional
    {
        JsonPath=jsonpath-if-needed
        OmitExcept=static,asyncstatic
        [Attribute]=description for attribute
    }
    description
    {
        Description of the endpoint.
    }
    returns
    {
        Description of returning value.
    }
    params
    {
        required int required_number
        optional string optional_string
        semi-optional int cursor
        either int id
        either string screen_name with !NET35
        either[1] int id_2
        either[1] string screen_name_2
        either string slug, string owner_screen_name
        and-any-type can be-used
    }
    pe // optional
    {
        custom.MethodBody("for params Expression<>[] overload");
    }

    id // optional
    {
        custom.MethodBody("for IDictionary<> overload");
    }

    t // optional
    {
        custom.MethodBody("for <T> overload");
    }

    static // optional
    {
        custom.MethodBody("for static overload");
        parameters.IsAvailableAs<IDictionary<string, object>>();
    }

    asyncpe // optional
    {
        custom.MethodBody("for async params Expression<>[] overload");
    }

    asyncid // optional
    {
        custom.MethodBody("for async IDictionary<> overload");
    }

    asynct // optional
    {
        custom.MethodBody("for async <T> overload");
    }

    asyncstatic // optional
    {
        custom.MethodBody("for async static overload");
        parameters.IsAvailableAs<IDictionary<string, object>>();
    }
}

// #raw
//    public void RawCSharpCode()
//    {
//        DoSomething();
//    }
// #endraw

*/

// normal
endpoint StatusResponse Update : Get statuses/update
{
    description
    {
        Updates the authenticating user's current status, also known as tweeting.
        To upload an image to accompany the tweet, use POST statuses/update_with_media.
        For each parameters attempt, the parameters text is compared with the authenticating user's recent tweets.
        Any attempt that would result in duplication will be blocked, resulting in a 403 error.
        Therefore, a user cannot submit the same status twice in a row.
        While not rate limited by the API a user is limited in the number of tweets they can create at a time.
        If the number of updates posted by the user reaches the current allowed limit this method will return an HTTP 403 error.
    }
    returns
    {
        The updated status.
    }
    params
    {
        required string status
        optional long in_reply_to_status_id
        optional double lat
        optional double @long
        optional string place_id
        optional bool display_coordinates
        optional bool trim_user
    }
}

// reservednormal
endpoint StatusResponse Show : Get statuses/show/{id}
{
    description
    {
        Returns a single Tweet, specified by the id parameter.
        The Tweet's author will also be embedded within the tweet.
    }
    returns
    {
        The status.
    }
    params
    {
        required int id
        optional bool trim_user
        optional bool include_entities
    }
}

// listed
endpoint Listed<Status> MentionsTimeline : Get statuses/mentions_timeline
{
    description
    {
        Returns the 20 most recent mentions (tweets containing a users's &#64;screen_name) for the authenticating user.
        The timeline returned is the equivalent of the one seen when you view your mentions on twitter.com.
        This method can only return up to 800 tweets.
    }
    returns
    {
        The statuses.
    }
    params
    {
        optional int count
        optional int since_id
        optional int max_id
        optional bool trim_user
        optional bool contributor_details
        optional bool include_entities
    }
}

// reservedlisted
endpoint Listed<Status> Retweets : Get statuses/retweets/{id}
{
    description
    {
        Returns up to 100 of the first retweets of a given tweet.
    }
    returns
    {
        The statuses.
    }
    params
    {
        required int id
        optional bool trim_user
        optional bool count
    }
}

// cursored
endpoint Cursored<long> Incoming : Get friendships/incoming
{
    description
    {
        Returns a collection of numeric IDs for every user who has a pending request to follow the authenticating user.
    }
    returns
    {
        The IDs.
    }
    params
    {
        semi-optional long cursor
    }
}

// either
endpoint UserResponse Show : Get users/show
{
    description
    {
        Returns a variety of information about the user specified by the required user_id or screen_name parameter.
        The author's most recent Tweet will be returned inline when possible.
    }
    returns
    {
        The user.
    }
    params
    {
        either long user_id
        either string screen_name
        optional bool include_entities
    }
}

// custombody & raw

endpoint StatusResponse UpdateWithMedia : Get statuses/update_with_media
{
    with
    {
        [Obsolete]=Use Media.Upload and Statuses.Update.
    }
    description
    {
        Updates the authenticating user's current status, uploading an image.
        For each parameters attempt, the parameters text is compared with the authenticating user's recent tweets.
        Any attempt that would result in duplication will be blocked, resulting in a 403 error.
        Therefore, a user cannot submit the same status twice in a row.
        While not rate limited by the API a user is limited in the number of tweets they can create at a time.
        If the number of updates posted by the user reaches the current allowed limit this method will return an HTTP 403 error.
    }
    params
    {
        required string status
        either Stream media
        either IEnumerable<byte> media
        either FileInfo media
        optional bool possibly_sensitive
        optional long in_reply_to_status_id
        optional double lat
        optional double @long
        optional string place_id
        optional bool display_coordinates
        optional bool trim_user
    }
    returns
    {
        The updated status.
    }
    pe
    {
        return this.UpdateWithMediaImpl(InternalUtils.ExpressionsToDictionary(parameters));
    }
    id
    {
        return this.UpdateWithMediaImpl(parameters);
    }
    t
    {
        return this.UpdateWithMediaImpl(InternalUtils.ResolveObject(parameters));
    }
    static
    {
        return this.UpdateWithMediaImpl(parameters);
    }
    asyncpe
    {
        return this.UpdateWithMediaAsyncImpl(InternalUtils.ExpressionsToDictionary(parameters), CancellationToken.None);
    }
    asyncid
    {
        return this.UpdateWithMediaAsyncImpl(parameters, cancellationToken);
    }
    asynct
    {
        return this.UpdateWithMediaAsyncImpl(InternalUtils.ResolveObject(parameters), cancellationToken);
    }
    asyncstatic
    {
        return this.UpdateWithMediaAsyncImpl(parameters, cancellationToken);
    }
}


#raw
#if SYNC
private StatusResponse UpdateWithMediaImpl(IEnumerable<KeyValuePair<string, object>> parameters)
{
    if(parameters == null) throw new ArgumentNullException("parameters");
    var list = parameters.ToList();
    list.Where(kvp => kvp.Key == "media").ToArray().ForEach(kvp =>
    {
        list.Remove(kvp);
        list.Add(new KeyValuePair<string, object>("media[]", kvp.Value));
    });
    return this.Tokens.AccessApiImpl<StatusResponse>(MethodType.Post, "statuses/update_with_media", list, "");
}
#endif
#if ASYNC
private Task<StatusResponse> UpdateWithMediaAsyncImpl(IEnumerable<KeyValuePair<string, object>> parameters, CancellationToken cancellationToken)
{
    if(parameters == null) throw new ArgumentNullException("parameters");
    var list = parameters.ToList();
    list.Where(kvp => kvp.Key == "media").ToArray().ForEach(kvp =>
    {
        list.Remove(kvp);
        list.Add(new KeyValuePair<string, object>("media[]", kvp.Value));
    });
    return this.Tokens.AccessApiAsyncImpl<StatusResponse>(MethodType.Post, "statuses/update_with_media", list, cancellationToken, "");
}
#endif
#endraw

// custom implementation with the above raw

endpoint StatusResponse UpdateWithMedia : Impl
{
    with
    {
        [Obsolete]=Use Media.Upload and Statuses.Update.
    }
    description
    {
        Updates the authenticating user's current status, uploading an image.
        For each parameters attempt, the parameters text is compared with the authenticating user's recent tweets.
        Any attempt that would result in duplication will be blocked, resulting in a 403 error.
        Therefore, a user cannot submit the same status twice in a row.
        While not rate limited by the API a user is limited in the number of tweets they can create at a time.
        If the number of updates posted by the user reaches the current allowed limit this method will return an HTTP 403 error.
    }
    params
    {
        required string status
        either Stream media
        either IEnumerable<byte> media
        either FileInfo media
        optional bool possibly_sensitive
        optional long in_reply_to_status_id
        optional double lat
        optional double @long
        optional string place_id
        optional bool display_coordinates
        optional bool trim_user
    }
    returns
    {
        The updated status.
    }
}

// void

endpoint void UpdateDeliveryService : Post account/update_delivery_service
{
    description
    {
        Sets which device Twitter delivers updates to for the authenticating user.
        Sending none as the device parameter will disable SMS updates.
    }
    params
    {
        required string device
        optional bool include_entities
    }
}

// omit

endpoint UserResponse UpdateProfileBackgroundImage : Post account/update_profile_background_image
{
    with
    {
        OmitExcept=static,asyncstatic
    }
    description
    {
        Updates the authenticating user's profile background image.
        This method can also be used to enable or disable the profile background image.
        Although each parameter is marked as optional, at least one of image, tile or use must be provided when making this request.
    }
    params
    {
        required bool tile
        optional bool include_entities
        optional bool skip_status
        optional bool use
    }
    returns
    {
        The user object.
    }
}

// dictionary

endpoint Dictionary<RateLimit> RateLimitStatus : Get application/rate_limit_status
{
    with
    {
        JsonPath=resources
    }
    description
    {
        Returns the current rate limits for methods belonging to the specified resource families.
    }
}

// grouped

endpoint Relationship Show : Get friendships/show
{
    description
    {
        Returns detailed information about the relationship between two arbitrary users.
        Note: At least one source and one target, whether specified by IDs or screen_names, should be provided to this method.
    }
    params
    {
        either[0] long source_id
        either[0] string source_screen_name
        either[1] long target_id
        either[1] string target_screen_name
    }
    returns
    {
        The relationship.
    }
}