diff --git a/addon.xml b/addon.xml index d13d37a..03ff6ae 100644 --- a/addon.xml +++ b/addon.xml @@ -20,7 +20,7 @@ - update m3u_pattern - add initial v5 (wip) - add support for additional methods in queries (PUT/DELETE/POST) -- v5 add communities, update follow/unfollow +- v5 add communities, update follow/unfollow/blocks - add basics for implicit oauth2 - update usher base url diff --git a/changelog.txt b/changelog.txt index a1c2003..47b6e62 100644 --- a/changelog.txt +++ b/changelog.txt @@ -10,6 +10,6 @@ - update m3u_pattern - add initial v5 (wip) - add support for additional methods in queries (PUT/DELETE/POST) -- v5 add communities, update follow/unfollow +- v5 add communities, update follow/unfollow/blocks - add basics for implicit oauth2 - update usher base url diff --git a/resources/lib/twitch/api/v5/blocks.py b/resources/lib/twitch/api/v5/blocks.py index 9fc14f4..c35f861 100644 --- a/resources/lib/twitch/api/v5/blocks.py +++ b/resources/lib/twitch/api/v5/blocks.py @@ -1,22 +1,34 @@ # -*- encoding: utf-8 -*- # https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md +from twitch import keys +from twitch.queries import V5Query as Qry from twitch.queries import query # Needs Authentification @query -def by_name(user): - raise NotImplementedError +def by_id(identification, limit=25, offset=0): + q = Qry('users/{id}/blocks') + q.add_urlkw(keys.ID, identification) + q.add_param(keys.LIMIT, limit, 25) + q.add_param(keys.OFFSET, offset, 0) + return q # Needs Authentification, needs PUT @query -def add_block(user, target): - raise NotImplementedError +def add_block(identification, target): + q = Qry('users/{id}/blocks/{target}', method='PUT') + q.add_urlkw(keys.ID, identification) + q.add_urlkw(keys.TARGET, target) + return q # Needs Authentification, needs DELETE @query -def del_block(user, target): - raise NotImplementedError +def del_block(identification, target): + q = Qry('users/{id}/blocks/{target}', method='DELETE') + q.add_urlkw(keys.ID, identification) + q.add_urlkw(keys.TARGET, target) + return q