-
Notifications
You must be signed in to change notification settings - Fork 1
/
IntegrationTeamEvents.kt
131 lines (116 loc) · 5.33 KB
/
IntegrationTeamEvents.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package alo.meetups.infrastructure.adapters.output.pubsub
import alo.meetups.infrastructure.adapters.output.pubsub.IntegrationEvent.AttendantAddedEvent
import alo.meetups.infrastructure.adapters.output.pubsub.IntegrationEvent.GroupCreatedEvent
import alo.meetups.infrastructure.adapters.output.pubsub.IntegrationEvent.MeetupCancelledEvent
import alo.meetups.infrastructure.adapters.output.pubsub.IntegrationEvent.MeetupCreatedEvent
import alo.meetups.infrastructure.adapters.output.pubsub.IntegrationEvent.MeetupFinishedEvent
import alo.meetups.infrastructure.adapters.output.pubsub.IntegrationEvent.MeetupIncludedEvent
import alo.meetups.infrastructure.adapters.output.pubsub.IntegrationEvent.MeetupRatedEvent
import alo.meetups.infrastructure.adapters.output.pubsub.IntegrationEvent.MemberJoinedEvent
import alo.meetups.infrastructure.adapters.output.pubsub.IntegrationEvent.MemberLeftEvent
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import java.math.BigDecimal
import java.time.LocalDateTime
import java.time.ZonedDateTime
import java.util.UUID
/*
Integration event: A committed event that occurred in the past within a bounded context which may be interesting to other
domains, applications or third party services. Usually these definitions are imported from the scheme registry.
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "event_type")
@JsonSubTypes(
JsonSubTypes.Type(value = MeetupCreatedEvent::class, name = "meetup_created_event"),
JsonSubTypes.Type(value = MeetupCancelledEvent::class, name = "meetup_cancelled_event"),
JsonSubTypes.Type(value = AttendantAddedEvent::class, name = "attendant_added_event"),
JsonSubTypes.Type(value = MeetupFinishedEvent::class, name = "meetup_finished_event"),
JsonSubTypes.Type(value = MeetupRatedEvent::class, name = "meetup_rated_event"),
JsonSubTypes.Type(value = GroupCreatedEvent::class, name = "group_created_event"),
JsonSubTypes.Type(value = MeetupIncludedEvent::class, name = "meetup_included_event"),
JsonSubTypes.Type(value = MemberLeftEvent::class, name = "group_left_event"),
JsonSubTypes.Type(value = MemberJoinedEvent::class, name = "group_joined_event"),
)
sealed class IntegrationEvent(
@get:JsonProperty("event_type") val eventType: String,
@get:JsonProperty("aggregate_type") val aggregateType: String,
) {
@get:JsonProperty("occurred_on")
abstract val occurredOn: LocalDateTime
@get:JsonProperty("event_id")
abstract val eventId: UUID
data class MeetupCreatedEvent(
val meetup: MeetupDto,
override val occurredOn: LocalDateTime,
override val eventId: UUID,
) : IntegrationEvent("meetup_created_event", "meetup")
data class MeetupCancelledEvent(
val meetup: MeetupDto,
override val occurredOn: LocalDateTime,
override val eventId: UUID,
) : IntegrationEvent("meetup_cancelled_event", "meetup")
data class AttendantAddedEvent(
val meetup: MeetupDto,
override val occurredOn: LocalDateTime,
override val eventId: UUID,
@get:JsonProperty("attendant_id") val attendantId: UUID,
) : IntegrationEvent("attendant_added_event", "meetup")
data class MeetupFinishedEvent(
val meetup: MeetupDto,
override val occurredOn: LocalDateTime,
override val eventId: UUID,
) : IntegrationEvent("meetup_finished_event", "meetup")
data class MeetupRatedEvent(
val meetup: MeetupDto,
override val occurredOn: LocalDateTime,
override val eventId: UUID,
) : IntegrationEvent("meetup_rated_event", "meetup")
data class GroupCreatedEvent(
val group: GroupDto,
override val occurredOn: LocalDateTime,
override val eventId: UUID,
) : IntegrationEvent("group_created_event", "group")
data class MeetupIncludedEvent(
val group: GroupDto,
override val occurredOn: LocalDateTime,
override val eventId: UUID,
@get:JsonProperty("meetup_id") val meetupId: UUID,
) : IntegrationEvent("meetup_included_event", "group")
data class MemberLeftEvent(
val group: GroupDto,
override val occurredOn: LocalDateTime,
override val eventId: UUID,
@get:JsonProperty("member_id") val memberId: UUID,
) : IntegrationEvent("group_left_event", "group")
data class MemberJoinedEvent(
val group: GroupDto,
override val occurredOn: LocalDateTime,
override val eventId: UUID,
@get:JsonProperty("member_id") val memberId: UUID,
) : IntegrationEvent("group_joined_event", "group")
}
data class MeetupDto(
val id: UUID,
val hostedBy: UUID,
val status: MeetupStatusIntegration,
val cancelledReason: String?,
val ratingStars: BigDecimal?,
val ratingVotes: Int?,
val topic: String,
val details: String,
val on: ZonedDateTime,
val groupId: UUID?,
val type: MeetupTypeIntegration,
val address: String?,
val linkURL: String?,
val linkName: String?,
val attendees: List<UUID>,
) {
enum class MeetupStatusIntegration {
UPCOMING, CANCELLED, FINISHED
}
enum class MeetupTypeIntegration {
ONLINE, IN_PERSON
}
}
data class GroupDto(val id: UUID, val title: String, val members: List<UUID>, val meetups: List<UUID>)