From 9d7ebee72026f8ee6128285f04ef7edc674781ca Mon Sep 17 00:00:00 2001 From: Dean Perry Date: Fri, 26 Aug 2022 12:43:13 +0100 Subject: [PATCH] charity campaigns --- README.md | 9 +++++++++ lib/twitch.rb | 2 ++ lib/twitch/client.rb | 4 ++++ lib/twitch/objects/charity_campaign.rb | 4 ++++ lib/twitch/resources/charity_campaigns.rb | 12 ++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 lib/twitch/objects/charity_campaign.rb create mode 100644 lib/twitch/resources/charity_campaigns.rb diff --git a/README.md b/README.md index f2b3f60..27fc667 100644 --- a/README.md +++ b/README.md @@ -363,6 +363,15 @@ messages = [{msg_id: "abc1", msg_text: "is this allowed?"}, {msg_id: "abc2", msg @client.blocked_terms.delete broadcaster_id: 123, moderator_id: 321, id: "abc12-12abc" ``` +## Charity Campaigns + +```ruby +# Gets information about the charity campaign that a broadcaster is running +# Required scope: channel:read:charity +# broadcaster_id must match the currently authenticated user +@client.charity_campaigns.list broadcaster_id: 123 +``` + ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/twitchrb/twitchrb. diff --git a/lib/twitch.rb b/lib/twitch.rb index a5c5d43..d3162e3 100644 --- a/lib/twitch.rb +++ b/lib/twitch.rb @@ -42,6 +42,7 @@ module Twitch autoload :WhispersResource, "twitch/resources/whispers" autoload :AutomodResource, "twitch/resources/automod" autoload :BlockedTermsResource, "twitch/resources/blocked_terms" + autoload :CharityCampaignsResource, "twitch/resources/charity_campaigns" autoload :User, "twitch/objects/user" @@ -80,5 +81,6 @@ module Twitch autoload :AutomodStatus, "twitch/objects/automod_status" autoload :AutomodSetting, "twitch/objects/automod_setting" autoload :BlockedTerm, "twitch/objects/blocked_term" + autoload :CHarityCampaign, "twitch/objects/charity_campaign" end diff --git a/lib/twitch/client.rb b/lib/twitch/client.rb index c5204e9..000e799 100644 --- a/lib/twitch/client.rb +++ b/lib/twitch/client.rb @@ -137,6 +137,10 @@ def blocked_terms BlockedTermsResource.new(self) end + def charity_campaigns + CharityCampaignsResource.new(self) + end + def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.request :authorization, :Bearer, access_token diff --git a/lib/twitch/objects/charity_campaign.rb b/lib/twitch/objects/charity_campaign.rb new file mode 100644 index 0000000..5ec1cde --- /dev/null +++ b/lib/twitch/objects/charity_campaign.rb @@ -0,0 +1,4 @@ +module Twitch + class CharityCampaign < Object + end +end diff --git a/lib/twitch/resources/charity_campaigns.rb b/lib/twitch/resources/charity_campaigns.rb new file mode 100644 index 0000000..9b95142 --- /dev/null +++ b/lib/twitch/resources/charity_campaigns.rb @@ -0,0 +1,12 @@ +module Twitch + class CharityCampaignsResource < Resource + + # Required scope: channel:read:charity + # Broadcaster ID must match the user in the OAuth token + def list(broadcaster_id:) + response = get_request("charity/campaigns?broadcaster_id=#{broadcaster_id}") + Collection.from_response(response, type: CharityCampaign) + end + + end +end