|
1 | 1 | # -*- encoding: utf-8 -*- |
2 | 2 | # https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md |
3 | 3 |
|
| 4 | +from twitch import keys |
| 5 | +from twitch.queries import V5Query as Qry |
4 | 6 | from twitch.queries import query |
5 | 7 |
|
6 | 8 |
|
7 | 9 | # Needs Authentification |
8 | 10 | @query |
9 | | -def by_name(user): |
10 | | - raise NotImplementedError |
| 11 | +def by_id(identification, limit=25, offset=0): |
| 12 | + q = Qry('users/{id}/blocks') |
| 13 | + q.add_urlkw(keys.ID, identification) |
| 14 | + q.add_param(keys.LIMIT, limit, 25) |
| 15 | + q.add_param(keys.OFFSET, offset, 0) |
| 16 | + return q |
11 | 17 |
|
12 | 18 |
|
13 | 19 | # Needs Authentification, needs PUT |
14 | 20 | @query |
15 | | -def add_block(user, target): |
16 | | - raise NotImplementedError |
| 21 | +def add_block(identification, target): |
| 22 | + q = Qry('users/{id}/blocks/{target}', method='PUT') |
| 23 | + q.add_urlkw(keys.ID, identification) |
| 24 | + q.add_urlkw(keys.TARGET, target) |
| 25 | + return q |
17 | 26 |
|
18 | 27 |
|
19 | 28 | # Needs Authentification, needs DELETE |
20 | 29 | @query |
21 | | -def del_block(user, target): |
22 | | - raise NotImplementedError |
| 30 | +def del_block(identification, target): |
| 31 | + q = Qry('users/{id}/blocks/{target}', method='DELETE') |
| 32 | + q.add_urlkw(keys.ID, identification) |
| 33 | + q.add_urlkw(keys.TARGET, target) |
| 34 | + return q |
0 commit comments