twitchrb 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9eee2d6f7cc0434ccb49cb42e12020ac4581f3c7d51c2e58696b0a0fe22db68b
4
- data.tar.gz: 0060beeceb9c3ca2062ac56457d00f18cb3a406cd4c6d7149406b3a53861e962
3
+ metadata.gz: ff8784f24098b67e4c0da539cc288fa99b3e22a306795bd351ad8dbd259ccfac
4
+ data.tar.gz: ec48ec81f9b0c0e9f83462f5d7604140ac68e6162979112e1426a8849c1c8748
5
5
  SHA512:
6
- metadata.gz: 85c8d5fa26d7c37e13061bb45e071fc7eb02fdf68ba9bcb5e76e2c3964f6451916aa95f2b8584f9171954a34b4dc8a35303ff9629c19fa1a6c1a043d41a87913
7
- data.tar.gz: 739d84bacdff4c31a2f63b7ccae655e1cc8661ca3346ab620db70792082777ab05da834c8d09874494654bb816f393b52b4cd445db424d693b6c07159e43712c
6
+ metadata.gz: d499ace0ef8e6c84f50027e4e8e630ce9a837a27f58e57638213acbcebc999efaee756e762e728a902d66f7083f0b1d45b16c29a2855a83670e69ae9f8da22a0
7
+ data.tar.gz: 7568b5b681ddf0f08c0394d809d9fd217bd7e4ee3c111a4e7612233f5227ec4c22ec60b2acafac805c8dd588a1e96051852dd2683a53f6361d847e39a4fa4582
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- twitchrb (0.2.0)
4
+ twitchrb (0.2.1)
5
5
  faraday (~> 1.7)
6
6
  faraday_middleware (~> 1.1)
7
7
 
@@ -19,55 +19,14 @@ module Twitch
19
19
  Collection.from_response(response, type: Subscription)
20
20
  end
21
21
 
22
- # Calculate the number of Subscribers & Subscriber Points a broadcaster has
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 calculate(broadcaster_id:, remove_count: 0, remove_points: 0)
26
- calculate_subs(broadcaster_id: broadcaster_id, remove_count: remove_count, remove_points: remove_points)
27
- end
28
-
29
- private
25
+ def counts(broadcaster_id:)
26
+ response = get_request("subscriptions", params: {broadcaster_id: broadcaster_id})
30
27
 
31
- def get_subscriptions(broadcaster_id:)
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
@@ -1,3 +1,3 @@
1
1
  module Twitch
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-09-26 00:00:00.000000000 Z
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
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.1
6
- before_install: gem install bundler -v 2.1.4