Skip to content

Commit

Permalink
charity campaigns
Browse files Browse the repository at this point in the history
  • Loading branch information
deanpcmad committed Aug 26, 2022
1 parent bf7b8ba commit 9d7ebee
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions lib/twitch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions lib/twitch/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/twitch/objects/charity_campaign.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Twitch
class CharityCampaign < Object
end
end
12 changes: 12 additions & 0 deletions lib/twitch/resources/charity_campaigns.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9d7ebee

Please sign in to comment.