twitchrb 1.11.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +97 -0
- data/LICENSE.txt +1 -1
- data/README.md +373 -46
- data/lib/twitch/client.rb +109 -20
- data/lib/twitch/collection.rb +54 -8
- data/lib/twitch/eventsub_webhook.rb +140 -0
- data/lib/twitch/oauth.rb +51 -14
- data/lib/twitch/object.rb +93 -14
- data/lib/twitch/objects/ad_schedule.rb +4 -0
- data/lib/twitch/objects/analytics_report.rb +4 -0
- data/lib/twitch/objects/bits_leaderboard_entry.rb +4 -0
- data/lib/twitch/objects/charity_donation.rb +4 -0
- data/lib/twitch/objects/chat_settings.rb +4 -0
- data/lib/twitch/objects/cheermote.rb +4 -0
- data/lib/twitch/objects/content_classification_label.rb +4 -0
- data/lib/twitch/objects/drops_entitlement.rb +4 -0
- data/lib/twitch/objects/drops_entitlement_update.rb +4 -0
- data/lib/twitch/objects/extension.rb +4 -0
- data/lib/twitch/objects/extension_bits_product.rb +4 -0
- data/lib/twitch/objects/extension_configuration_segment.rb +4 -0
- data/lib/twitch/objects/extension_live_channel.rb +4 -0
- data/lib/twitch/objects/extension_secret.rb +4 -0
- data/lib/twitch/objects/extension_transaction.rb +4 -0
- data/lib/twitch/objects/guest_star_invite.rb +4 -0
- data/lib/twitch/objects/guest_star_session.rb +4 -0
- data/lib/twitch/objects/guest_star_settings.rb +4 -0
- data/lib/twitch/objects/shield_mode_status.rb +4 -0
- data/lib/twitch/objects/{tag.rb → team.rb} +1 -1
- data/lib/twitch/objects/user_active_extensions.rb +4 -0
- data/lib/twitch/objects/user_extension.rb +4 -0
- data/lib/twitch/resource.rb +29 -0
- data/lib/twitch/resources/ads.rb +18 -0
- data/lib/twitch/resources/analytics.rb +19 -0
- data/lib/twitch/resources/announcements.rb +1 -1
- data/lib/twitch/resources/automod.rb +7 -7
- data/lib/twitch/resources/badges.rb +2 -2
- data/lib/twitch/resources/banned_users.rb +3 -3
- data/lib/twitch/resources/bits.rb +16 -0
- data/lib/twitch/resources/blocked_terms.rb +3 -3
- data/lib/twitch/resources/channels.rb +4 -4
- data/lib/twitch/resources/charity_campaigns.rb +8 -0
- data/lib/twitch/resources/chat_settings.rb +20 -0
- data/lib/twitch/resources/chatters.rb +1 -1
- data/lib/twitch/resources/clips.rb +3 -9
- data/lib/twitch/resources/content_classification_labels.rb +8 -0
- data/lib/twitch/resources/custom_power_ups.rb +1 -1
- data/lib/twitch/resources/custom_reward_redemptions.rb +3 -4
- data/lib/twitch/resources/custom_rewards.rb +5 -5
- data/lib/twitch/resources/drops_entitlements.rb +17 -0
- data/lib/twitch/resources/emotes.rb +3 -3
- data/lib/twitch/resources/eventsub_conduits.rb +14 -4
- data/lib/twitch/resources/eventsub_subscriptions.rb +1 -1
- data/lib/twitch/resources/extensions.rb +99 -0
- data/lib/twitch/resources/games.rb +3 -3
- data/lib/twitch/resources/goals.rb +1 -1
- data/lib/twitch/resources/guest_star.rb +102 -0
- data/lib/twitch/resources/moderators.rb +3 -3
- data/lib/twitch/resources/pinned_chat_messages.rb +4 -11
- data/lib/twitch/resources/polls.rb +1 -1
- data/lib/twitch/resources/predictions.rb +1 -1
- data/lib/twitch/resources/raids.rb +2 -3
- data/lib/twitch/resources/search.rb +2 -2
- data/lib/twitch/resources/shield_mode.rb +18 -0
- data/lib/twitch/resources/shoutouts.rb +1 -1
- data/lib/twitch/resources/stream_markers.rb +1 -1
- data/lib/twitch/resources/stream_schedule.rb +4 -5
- data/lib/twitch/resources/streams.rb +2 -2
- data/lib/twitch/resources/subscriptions.rb +13 -2
- data/lib/twitch/resources/suspicious_users.rb +1 -1
- data/lib/twitch/resources/teams.rb +20 -0
- data/lib/twitch/resources/unban_requests.rb +2 -2
- data/lib/twitch/resources/users.rb +30 -34
- data/lib/twitch/resources/videos.rb +2 -2
- data/lib/twitch/resources/vips.rb +2 -2
- data/lib/twitch/resources/warnings.rb +2 -2
- data/lib/twitch/resources/whispers.rb +1 -1
- data/lib/twitch/version.rb +1 -1
- data/lib/twitch.rb +33 -10
- metadata +42 -46
- data/.env.example +0 -3
- data/.github/FUNDING.yml +0 -5
- data/.github/dependabot.yml +0 -11
- data/.github/workflows/ci.yml +0 -39
- data/.gitignore +0 -9
- data/.rubocop.yml +0 -16
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -144
- data/Rakefile +0 -10
- data/bin/console +0 -23
- data/bin/setup +0 -8
- data/bin/smoke +0 -118
- data/lib/twitch/objects/banned_event.rb +0 -4
- data/lib/twitch/objects/followed_user.rb +0 -4
- data/lib/twitch/objects/hype_train_event.rb +0 -4
- data/lib/twitch/objects/moderator_event.rb +0 -4
- data/lib/twitch/resources/banned_events.rb +0 -8
- data/lib/twitch/resources/hype_train_events.rb +0 -10
- data/lib/twitch/resources/moderator_events.rb +0 -9
- data/lib/twitch/resources/tags.rb +0 -18
- data/mise.toml +0 -2
- data/twitchrb.gemspec +0 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8228b593acef6a0efdcdd04dbacf8ce080f810703398f75d641fb0e3a2df560d
|
|
4
|
+
data.tar.gz: 96d303d92f782fd156b30f4a0d4d8219e90511d90d78d16ff1ef289f2d731328
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44755a65de44e98a714c4a762b544059ca70a942c723e741f7570a1a23de6488005e3e22700a5df2262514ac03bd748da225968951481096ebd93f24bc246c1a
|
|
7
|
+
data.tar.gz: 6057bade63a8527544adf8f201c1f71eb794e96d0b50fc29c2755fb54454809d4c4265574b4f7c6985a0f28cd33206b867f0352c47f885d83b0c906cb0d7028b
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,103 @@ All notable changes to `twitchrb` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
Published release notes were sourced from GitHub releases where available. Older tag-only versions and the current unreleased work were reconstructed from local git history.
|
|
6
6
|
|
|
7
|
+
## [2.1.0] - 2026-09-27
|
|
8
|
+
|
|
9
|
+
Completes the 2.0 cleanup: response objects no longer depend on OpenStruct.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Response objects no longer use `OpenStruct`, and the `ostruct` dependency has been removed. `Twitch::Object` now
|
|
14
|
+
stores attributes in a hash and reads them through dot notation or hash access (`object[:id]`). Building objects is
|
|
15
|
+
much faster and uses less memory. Missing attributes still return `nil`.
|
|
16
|
+
- Nested objects are now `Twitch::Object`s rather than `OpenStruct`s, and so are the responses from `Twitch::OAuth`.
|
|
17
|
+
Code that checks for `OpenStruct` or calls `OpenStruct`-only methods needs updating.
|
|
18
|
+
- The packaged gem now only contains `lib/`, the README, LICENSE and CHANGELOG, instead of every file in the repo.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `key?` on response objects, to check whether an attribute is present.
|
|
23
|
+
|
|
24
|
+
## [2.0.0] - 2026-09-23
|
|
25
|
+
|
|
26
|
+
This release adds every remaining Helix endpoint, automatic pagination, automatic token refresh, and EventSub
|
|
27
|
+
webhook verification, and fixes many requests that didn't match the Twitch API reference. It contains breaking
|
|
28
|
+
changes, listed below.
|
|
29
|
+
|
|
30
|
+
### Upgrading from 1.x
|
|
31
|
+
|
|
32
|
+
- **Ruby 3.3 or newer is required.**
|
|
33
|
+
- **Methods for endpoints Twitch has shut down were removed:**
|
|
34
|
+
- `hype_train_events.list` → use `hype_train_status.retrieve(broadcaster_id:)`.
|
|
35
|
+
- `users.follows` and `users.following?` → use `channels.followers(broadcaster_id:, user_id:)` to check whether a
|
|
36
|
+
user follows a channel, or `channels.followed(user_id:)` to list the channels a user follows.
|
|
37
|
+
- `tags.list`, `tags.stream`, and `tags.replace` → channel tags are returned by `channels.retrieve` and set with
|
|
38
|
+
`channels.update(broadcaster_id:, tags: [...])`.
|
|
39
|
+
- `banned_events.list` and `moderator_events.list` → no API replacement; use the `channel.ban`, `channel.unban`,
|
|
40
|
+
and `channel.moderate` EventSub subscriptions.
|
|
41
|
+
- **`oauth.create`, `oauth.refresh`, and `oauth.device` raise errors instead of returning `false`.** Replace checks
|
|
42
|
+
like `if token = oauth.refresh(...)` with a `rescue`:
|
|
43
|
+
|
|
44
|
+
```ruby
|
|
45
|
+
begin
|
|
46
|
+
token = oauth.refresh(refresh_token: refresh_token)
|
|
47
|
+
rescue Twitch::Error => e
|
|
48
|
+
e.twitch_error_message #=> "Invalid refresh token"
|
|
49
|
+
end
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`oauth.validate` and `oauth.revoke` still return `false`.
|
|
53
|
+
- **Missing required arguments raise `ArgumentError`** instead of `RuntimeError`. Update any `rescue RuntimeError`.
|
|
54
|
+
- **`to_h` on response objects now converts nested objects to hashes too.** If you called methods on nested values
|
|
55
|
+
from `to_h` (e.g. `object.to_h[:current].id`), use hash access instead (`object.to_h[:current][:id]`), or call the
|
|
56
|
+
method on the object itself (`object.current.id`).
|
|
57
|
+
|
|
58
|
+
### Changed
|
|
59
|
+
- Missing required arguments (e.g. calling `clips.list` without `broadcaster_id`, `game_id` or `id`) now raise `ArgumentError` instead of `RuntimeError`.
|
|
60
|
+
- **Breaking:** `oauth.create`, `oauth.refresh`, and `oauth.device` now raise errors (e.g. `Twitch::Errors::BadRequestError`, with Twitch's message in `twitch_error_message`) instead of returning `false`. `oauth.validate` and `oauth.revoke` still return `false`.
|
|
61
|
+
- The minimum supported Ruby version is now 3.3 (previously declared as 2.3, though the gem already required 3.1+). This matches the versions tested in CI.
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
- `subscriptions.subscribed?(broadcaster_id:, user_id:)`, which returns `true` or `false` instead of raising when the user isn't subscribed.
|
|
65
|
+
- Automatic token refresh: pass `refresh_token:` (and `client_secret:`, unless your app is a public client) to `Twitch::Client.new`, and requests that fail because the access token expired are retried once with a refreshed token. `on_token_refresh:` is called with the new token so you can store it, and `client.refresh_access_token!` refreshes manually.
|
|
66
|
+
- Automatic pagination: collections from paginated endpoints now have `next_page?`, `next_page`, `each_page`, and `auto_paginate`, which lazily iterates over every item across pages (e.g. `auto_paginate.first(250)` only fetches the pages it needs).
|
|
67
|
+
- `Twitch::EventsubWebhook` to verify and parse EventSub webhook requests. It checks the HMAC signature in constant time, rejects messages older than 10 minutes, and gives access to the message type, challenge, subscription, and event.
|
|
68
|
+
- `oauth.exchange_code(code:, redirect_uri:)` for the authorization code grant flow, and `oauth.device_token(device_code:, scopes:)` to finish the device code grant flow. Previously neither flow could be completed.
|
|
69
|
+
- `oauth.create` sends extra keyword arguments (such as `code` and `redirect_uri`) with the request, and `scope`/`scopes` accept arrays.
|
|
70
|
+
- `Twitch::OAuth.new` no longer requires a `client_secret`, for public clients using the device code flow.
|
|
71
|
+
- `ads.schedule` and `ads.snooze` (Get Ad Schedule, Snooze Next Ad).
|
|
72
|
+
- `analytics.extensions` and `analytics.games`.
|
|
73
|
+
- `bits.leaderboard` and `bits.cheermotes`.
|
|
74
|
+
- `charity_campaigns.donations`.
|
|
75
|
+
- `chat_settings.retrieve` and `chat_settings.update`.
|
|
76
|
+
- `shield_mode.retrieve` and `shield_mode.update`.
|
|
77
|
+
- `content_classification_labels.list`.
|
|
78
|
+
- `teams.retrieve` and `teams.channel`.
|
|
79
|
+
- `drops_entitlements.list` and `drops_entitlements.update`.
|
|
80
|
+
- `users.extensions`, `users.active_extensions`, and `users.update_extensions`.
|
|
81
|
+
- An `extensions` resource covering the Extensions API: `retrieve`, `released`, `live_channels`, `configuration`, `set_configuration`, `set_required_configuration`, `send_pubsub_message`, `send_chat_message`, `secrets`, `create_secret`, `bits_products`, `update_bits_product`, and `transactions`.
|
|
82
|
+
- A `guest_star` resource covering the Guest Star beta API.
|
|
83
|
+
|
|
84
|
+
### Removed
|
|
85
|
+
- Removed methods for endpoints Twitch has shut down, which could only return errors:
|
|
86
|
+
- `hype_train_events.list`, which forwarded to `hype_train_status.retrieve` with a deprecation warning since 1.10.0.
|
|
87
|
+
- `banned_events.list` and `moderator_events.list` (Get Banned Events / Get Moderator Events).
|
|
88
|
+
- `users.follows` and `users.following?` (`GET /users/follows`). Use `channels.followers` or `channels.followed` instead.
|
|
89
|
+
- `tags.list`, `tags.stream`, and `tags.replace` (the old Twitch-defined stream tags). Channel tags are now read with `channels.retrieve` and set with `channels.update(tags: [...])`.
|
|
90
|
+
- Removed the now-unused `Twitch::BannedEvent`, `Twitch::ModeratorEvent`, `Twitch::FollowedUser`, `Twitch::HypeTrainEvent`, and `Twitch::Tag` classes.
|
|
91
|
+
|
|
92
|
+
### Fixed
|
|
93
|
+
- Fixed multi-value query params (e.g. `users.retrieve(ids:)`, `games.retrieve(names:)`, `streams.list(user_id: [...])`, `clips.downloads(clip_ids:)`) being sent as `id[]=1&id[]=2`. They are now sent as repeated keys (`id=1&id=2`), which is the format Helix expects.
|
|
94
|
+
- Fixed write endpoints sending query string parameters in the JSON body instead of the query string, contrary to the Twitch API reference. Affects `channels.update`, `custom_rewards.create`/`update`, `automod.check_status`/`check_status_multiple`/`update_settings`, `banned_users.create`, `blocked_terms.create`, `unban_requests.resolve`, `moderators.create`, `vips.create`, `raids.create`, `whispers.create`, `stream_schedule.update`/`create_segment`/`update_segment`, `users.update`, and `users.block_user` (whose `source_context` and `reason` options were being sent in the body).
|
|
95
|
+
- Fixed `clips.list` and `videos.list` rejecting calls that only pass `id`, which both endpoints accept.
|
|
96
|
+
- Fixed `eventsub_conduits.update_shards` discarding the `errors` Twitch returns for shards that failed to update. They are now available as `result.errors`, and `Collection#errors` is available for any endpoint that reports partial failures.
|
|
97
|
+
- `eventsub_conduits.update_shards` now sends lists of more than 100 shards in batches of 100, the most Twitch accepts per request.
|
|
98
|
+
- Fixed `oauth.device` sending `scope` instead of `scopes`, which Twitch requires.
|
|
99
|
+
- Fixed `to_h` and `to_json` on response objects leaving nested objects as `OpenStruct`s, which serialized as strings like `"#<OpenStruct ...>"`. Nested objects and arrays are now converted to plain hashes, and `as_json` is defined for Rails.
|
|
100
|
+
- `Collection#cursor` now works for endpoints that return `pagination` as a bare string (such as Get Extension Live Channels) instead of raising.
|
|
101
|
+
- `banned_users.create` no longer sends `"duration": null` for permanent bans.
|
|
102
|
+
- Helix and OAuth requests now have default timeouts (30s read, 10s open) instead of waiting indefinitely. Configure with the `timeout:` and `open_timeout:` options on `Twitch::Client.new` and `Twitch::OAuth.new`.
|
|
103
|
+
|
|
7
104
|
## [1.11.0] - 2026-08-11
|
|
8
105
|
|
|
9
106
|
### Fixed
|
data/LICENSE.txt
CHANGED