Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 835d3d6

Browse files
committed
Add gifted subs and sub tiers to the api and tipeeestream
1 parent 73a7582 commit 835d3d6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/scala/org/codeoverflow/chatoverflow/requirement/service/tipeeestream/impl/TipeeestreamEventInputImpl.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import java.util.{Currency, Locale}
66

77
import org.codeoverflow.chatoverflow.WithLogger
88
import org.codeoverflow.chatoverflow.api.io.dto.User
9+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.SubscriptionTier
910
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream._
1011
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream._
1112
import org.codeoverflow.chatoverflow.api.io.input.event.TipeeestreamEventInput
@@ -58,7 +59,15 @@ class TipeeestreamEventInputImpl extends EventInputImpl[TipeeestreamEvent, Tipee
5859
val time = OffsetDateTime.parse(event.getString("created_at"), DATE_FORMATTER)
5960
val resub = parameter.optInt("resub", 0)
6061
val provider = TipeeestreamProvider.parse(event.optString("origin"))
61-
val sub = new TipeeestreamSubscription(user, resub, time, provider)
62+
val gifted = parameter.has("gifter")
63+
val donor = if (gifted) new User(parameter.getString("gifter")) else null
64+
val tier = SubscriptionTier.parse({
65+
if (parameter.optInt("twitch_prime") == 1)
66+
0
67+
else
68+
parameter.optInt("plan", 1000) / 1000
69+
})
70+
val sub = new TipeeestreamSubscription(user, time, resub, tier, gifted, donor, provider)
6271
call(new TipeeestreamSubscriptionEvent(sub))
6372
} catch {
6473
case e: JSONException =>

0 commit comments

Comments
 (0)