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

Commit e5afe4b

Browse files
committed
Add Tipeeestream event input (See: codeoverflow-org/chatoverflow#43)
1 parent ebf2ddd commit e5afe4b

30 files changed

+428
-189
lines changed

src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/Event.java

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamDonation.java

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamEvent.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamFollow.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/java/org/codeoverflow/chatoverflow/api/io/dto/event/tipeeestream/TipeeeStreamSubscription.java

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
5+
import java.time.OffsetDateTime;
6+
import java.util.Currency;
7+
8+
/**
9+
* A user donated some money for your stream
10+
*/
11+
public class Donation<T extends User> {
12+
private final T donor;
13+
private final float amount;
14+
private final Currency currency;
15+
private final OffsetDateTime time;
16+
17+
public Donation(T donor, float amount, Currency currency, OffsetDateTime time) {
18+
this.donor = donor;
19+
this.amount = amount;
20+
this.currency = currency;
21+
this.time = time;
22+
}
23+
24+
/**
25+
* Get the user object of the person that donated
26+
*
27+
* @return the donor
28+
*/
29+
public T getDonor() {
30+
return donor;
31+
}
32+
33+
/**
34+
* Get how much the user donated
35+
*
36+
* @return amount of donated money
37+
*/
38+
public float getAmount() {
39+
return amount;
40+
}
41+
42+
/**
43+
* Get the currency used for this transaction
44+
*
45+
* @return currency object
46+
*/
47+
public Currency getCurrency() {
48+
return currency;
49+
}
50+
51+
/**
52+
* Get a formatted string how much the user donated.
53+
* <br>
54+
* <b>Example:</b> {@code € 70.02}
55+
*
56+
* @return formatted donation amount
57+
*/
58+
public String getFormattedAmount() {
59+
return String.format("%s %,.2f", currency.getSymbol(), amount);
60+
}
61+
62+
/**
63+
* Get the time when the donation was made
64+
*
65+
* @return donation time
66+
*/
67+
public OffsetDateTime getTime() {
68+
return time;
69+
}
70+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
5+
import java.time.OffsetDateTime;
6+
7+
/**
8+
* A user started following the stream
9+
*/
10+
public class Follow<T extends User> {
11+
12+
private final T follower;
13+
private final OffsetDateTime time;
14+
15+
public Follow(T follower, OffsetDateTime time) {
16+
this.follower = follower;
17+
this.time = time;
18+
}
19+
20+
/**
21+
* Get the user object of the person that started following
22+
*
23+
* @return the follower
24+
*/
25+
public T getFollower() {
26+
return follower;
27+
}
28+
29+
/**
30+
* Get the time when the user started following
31+
*
32+
* @return follow start time
33+
*/
34+
public OffsetDateTime getTime() {
35+
return time;
36+
}
37+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
5+
import java.time.OffsetDateTime;
6+
7+
public class Subscription<T extends User> {
8+
private final T subscriber;
9+
private final OffsetDateTime time;
10+
private final int resub;
11+
12+
public Subscription(T subscriber, int resub, OffsetDateTime time) {
13+
this.subscriber = subscriber;
14+
this.time = time;
15+
this.resub = resub;
16+
}
17+
18+
/**
19+
* Get the user object of the person that started following
20+
*
21+
* @return the subscriber
22+
*/
23+
public T getSubscriber() {
24+
return subscriber;
25+
}
26+
27+
/**
28+
* Returns how often that user has subscribed
29+
*
30+
* @return how often a user resubbed
31+
*/
32+
public int getResub() {
33+
return resub;
34+
}
35+
36+
/**
37+
* Get the time when the user started following
38+
*
39+
* @return follow start time
40+
*/
41+
public OffsetDateTime getTime() {
42+
return time;
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.Donation;
5+
6+
import java.time.OffsetDateTime;
7+
import java.util.Currency;
8+
9+
public class TipeeestreamDonation extends Donation<User> {
10+
11+
private final String donationMessage;
12+
13+
public TipeeestreamDonation(User donor, float amount, Currency currency, OffsetDateTime time, String donationMessage) {
14+
super(donor, amount, currency, time);
15+
this.donationMessage = donationMessage;
16+
}
17+
18+
/**
19+
* Get the message that a user included in his donation
20+
*
21+
* @return the donation message
22+
*/
23+
public String getDonationMessage() {
24+
return donationMessage;
25+
}
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.Follow;
5+
6+
import java.time.OffsetDateTime;
7+
8+
public class TipeeestreamFollow extends Follow<User> {
9+
10+
private final TipeeestreamProvider provider;
11+
12+
public TipeeestreamFollow(User follower, OffsetDateTime time, TipeeestreamProvider provider) {
13+
super(follower, time);
14+
this.provider = provider;
15+
}
16+
17+
/**
18+
* Get the service over which this follow was made
19+
*
20+
* @return the provider of this follow
21+
*/
22+
public TipeeestreamProvider getProvider() {
23+
return provider;
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream;
2+
3+
import java.util.Arrays;
4+
5+
/**
6+
* A provider service to which tipeeestream is connected (like youtoube or twitch)
7+
*/
8+
public enum TipeeestreamProvider {
9+
TWITCH,
10+
YOUTUBE,
11+
UNKNOWN;
12+
//Currently we have no dataset to test the less popular providers, therefore they are grouped under UNKNOWN
13+
14+
@Override
15+
public String toString() {
16+
return name().toLowerCase();
17+
}
18+
19+
/**
20+
* Parse the provider from a string
21+
* @param provider string with the providers name
22+
* @return the provider for that string or {@link #UNKNOWN}
23+
*/
24+
public static TipeeestreamProvider parse(String provider) {
25+
return Arrays.stream(values()).filter(p -> p.toString().equals(provider.trim().toLowerCase())).findAny().orElse(UNKNOWN);
26+
}
27+
}

0 commit comments

Comments
 (0)