From 7446e9892b20262fb510234bc96becf2cc1cbc73 Mon Sep 17 00:00:00 2001 From: anxdpanic Date: Wed, 13 Sep 2017 12:07:35 -0400 Subject: [PATCH] [v5] [channels] deprecated notations for community endpoints, add new community endpoints --- resources/lib/twitch/api/v5/channels.py | 20 ++++++++++++++++++++ resources/lib/twitch/keys.py | 1 + 2 files changed, 21 insertions(+) diff --git a/resources/lib/twitch/api/v5/channels.py b/resources/lib/twitch/api/v5/channels.py index 62e435d..caaf103 100644 --- a/resources/lib/twitch/api/v5/channels.py +++ b/resources/lib/twitch/api/v5/channels.py @@ -123,6 +123,7 @@ def reset_stream_key(channel_id): # required scope: channel_editor +# deprecated @query def get_community(channel_id): q = Qry('channels/{channel_id}/community') @@ -130,7 +131,16 @@ def get_community(channel_id): return q +# required scope: none +@query +def get_communities(channel_id): + q = Qry('channels/{channel_id}/communities', use_token=False) + q.add_urlkw(keys.CHANNEL_ID, channel_id) + return q + + # required scope: channel_editor +# deprecated @query def set_community(channel_id, community_id): q = Qry('channels/{channel_id}/community/{community_id}', method=methods.PUT) @@ -141,6 +151,16 @@ def set_community(channel_id, community_id): # required scope: channel_editor @query +def set_communities(channel_id, community_ids): + q = Qry('channels/{channel_id}/communities', method=methods.PUT) + q.add_urlkw(keys.CHANNEL_ID, channel_id) + q.add_data(keys.COMMUNITY_IDS, community_ids) + return q + + +# required scope: channel_editor +# deprecated action: act on single community, new action: act on all communities +@query def delete_from_community(channel_id): q = Qry('channels/{channel_id}/community', method=methods.DELETE) q.add_urlkw(keys.CHANNEL_ID, channel_id) diff --git a/resources/lib/twitch/keys.py b/resources/lib/twitch/keys.py index e59759d..94c9da9 100644 --- a/resources/lib/twitch/keys.py +++ b/resources/lib/twitch/keys.py @@ -21,6 +21,7 @@ COMMENTS = 'comments' COMMUNITIES = 'communities' COMMUNITY_ID = 'community_id' +COMMUNITY_IDS = 'community_ids' CONTAINING_ITEM = 'containing_item' CONTENT = 'content' COVER_IMAGE = 'cover_image'