twitchrb 0.2.0 → 0.2.1
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/Gemfile.lock +1 -1
- data/lib/twitch/resources/subscriptions.rb +4 -45
- data/lib/twitch/version.rb +1 -1
- metadata +2 -3
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff8784f24098b67e4c0da539cc288fa99b3e22a306795bd351ad8dbd259ccfac
|
|
4
|
+
data.tar.gz: ec48ec81f9b0c0e9f83462f5d7604140ac68e6162979112e1426a8849c1c8748
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d499ace0ef8e6c84f50027e4e8e630ce9a837a27f58e57638213acbcebc999efaee756e762e728a902d66f7083f0b1d45b16c29a2855a83670e69ae9f8da22a0
|
|
7
|
+
data.tar.gz: 7568b5b681ddf0f08c0394d809d9fd217bd7e4ee3c111a4e7612233f5227ec4c22ec60b2acafac805c8dd588a1e96051852dd2683a53f6361d847e39a4fa4582
|
data/Gemfile.lock
CHANGED
|
@@ -19,55 +19,14 @@ module Twitch
|
|
|
19
19
|
Collection.from_response(response, type: Subscription)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
#
|
|
22
|
+
# Grabs the number of Subscribers and Subscriber Points a broadcaster has
|
|
23
23
|
# Broadcaster ID must match the user in the OAuth token
|
|
24
24
|
# Required scope: channel:read:subscriptions
|
|
25
|
-
def
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
25
|
+
def counts(broadcaster_id:)
|
|
26
|
+
response = get_request("subscriptions", params: {broadcaster_id: broadcaster_id})
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
subs = []
|
|
33
|
-
cursor = nil
|
|
34
|
-
count = 1
|
|
35
|
-
|
|
36
|
-
while count > 0
|
|
37
|
-
sub_response = list(broadcaster_id: broadcaster_id, first: 100, after: cursor)
|
|
38
|
-
|
|
39
|
-
subs += sub_response.data
|
|
40
|
-
|
|
41
|
-
cursor = sub_response.cursor
|
|
42
|
-
count = sub_response.total
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
return subs
|
|
28
|
+
SubscriptionCount.new(count: response.body["total"], points: response.body["points"])
|
|
46
29
|
end
|
|
47
|
-
|
|
48
|
-
def calculate_subs(broadcaster_id:, remove_count:, remove_points:)
|
|
49
|
-
subs = get_subscriptions(broadcaster_id: broadcaster_id)
|
|
50
|
-
|
|
51
|
-
count = 0
|
|
52
|
-
points = 0
|
|
53
|
-
|
|
54
|
-
if !subs.empty? && subs.count >= 1
|
|
55
|
-
subs.each do |sub|
|
|
56
|
-
# We don't want to add the broadcaster into the count
|
|
57
|
-
next if sub.user_id.to_s == broadcaster_id.to_s
|
|
58
|
-
|
|
59
|
-
count += 1
|
|
60
|
-
points += 1 if sub.tier == "1000"
|
|
61
|
-
points += 2 if sub.tier == "2000"
|
|
62
|
-
points += 6 if sub.tier == "3000"
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
count = (count - remove_count)
|
|
66
|
-
points = (points - remove_points)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
SubscriptionCount.new(count: count, points: points)
|
|
70
|
-
end
|
|
71
30
|
|
|
72
31
|
end
|
|
73
32
|
end
|
data/lib/twitch/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: twitchrb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dean Perry
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-10-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -48,7 +48,6 @@ files:
|
|
|
48
48
|
- ".env.example"
|
|
49
49
|
- ".github/FUNDING.yml"
|
|
50
50
|
- ".gitignore"
|
|
51
|
-
- ".travis.yml"
|
|
52
51
|
- Gemfile
|
|
53
52
|
- Gemfile.lock
|
|
54
53
|
- LICENSE.txt
|