Skip to content

Commit

Permalink
Combine OM events.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgd committed Apr 26, 2024
1 parent dc1c65c commit b29dc1e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 54 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.workos.webhooks.models
import com.workos.usermanagement.models.OrganizationMembership

/**
* Webhook Event for `organization_membership.created`.
* Webhook Event for `organization_membership.*` events.
*/
class OrganizationMembershipCreatedEvent(
class OrganizationMembershipEvent(
@JvmField
override val id: String,

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class WebhookJsonDeserializer : JsonDeserializer<WebhookEvent>() {
EventType.DirectoryGroupDeleted -> DirectoryGroupDeletedEvent(id, eventType, deserializeData(data, Group::class.java), createdAt)
EventType.DirectoryGroupUserAdded -> DirectoryGroupUserAddedEvent(id, eventType, deserializeData(data, DirectoryGroupUserEvent::class.java), createdAt)
EventType.DirectoryGroupUserRemoved -> DirectoryGroupUserRemovedEvent(id, eventType, deserializeData(data, DirectoryGroupUserEvent::class.java), createdAt)
EventType.OrganizationMembershipCreated -> OrganizationMembershipCreatedEvent(id, eventType, deserializeData(data, OrganizationMembership::class.java), createdAt)
EventType.OrganizationMembershipDeleted -> OrganizationMembershipDeletedEvent(id, eventType, deserializeData(data, OrganizationMembership::class.java), createdAt)
EventType.OrganizationMembershipUpdated -> OrganizationMembershipUpdatedEvent(id, eventType, deserializeData(data, OrganizationMembership::class.java), createdAt)
EventType.OrganizationMembershipCreated -> OrganizationMembershipEvent(id, eventType, deserializeData(data, OrganizationMembership::class.java), createdAt)
EventType.OrganizationMembershipDeleted -> OrganizationMembershipEvent(id, eventType, deserializeData(data, OrganizationMembership::class.java), createdAt)
EventType.OrganizationMembershipUpdated -> OrganizationMembershipEvent(id, eventType, deserializeData(data, OrganizationMembership::class.java), createdAt)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.workos.test.webhooks

import com.workos.test.TestBase
import com.workos.webhooks.models.EventType
import com.workos.webhooks.models.OrganizationMembershipCreatedEvent
import com.workos.webhooks.models.OrganizationMembershipDeletedEvent
import com.workos.webhooks.models.OrganizationMembershipUpdatedEvent
import com.workos.webhooks.models.OrganizationMembershipEvent
import org.junit.Test
import org.junit.jupiter.api.Assertions.assertTrue
import kotlin.test.assertEquals
Expand Down Expand Up @@ -45,9 +43,9 @@ class OrganizationMembershipWebhookTests : TestBase() {
testData["secret"] as String
)

assertTrue(webhook is OrganizationMembershipCreatedEvent)
assertTrue(webhook is OrganizationMembershipEvent)
assertEquals(webhook.id, webhookId)
assertEquals((webhook as OrganizationMembershipCreatedEvent).data.id, organizationMembershipId)
assertEquals((webhook as OrganizationMembershipEvent).data.id, organizationMembershipId)
}

@Test
Expand All @@ -62,9 +60,9 @@ class OrganizationMembershipWebhookTests : TestBase() {
testData["secret"] as String
)

assertTrue(webhook is OrganizationMembershipDeletedEvent)
assertTrue(webhook is OrganizationMembershipEvent)
assertEquals(webhook.id, webhookId)
assertEquals((webhook as OrganizationMembershipDeletedEvent).data.id, organizationMembershipId)
assertEquals((webhook as OrganizationMembershipEvent).data.id, organizationMembershipId)
}

@Test
Expand All @@ -79,8 +77,8 @@ class OrganizationMembershipWebhookTests : TestBase() {
testData["secret"] as String
)

assertTrue(webhook is OrganizationMembershipUpdatedEvent)
assertTrue(webhook is OrganizationMembershipEvent)
assertEquals(webhook.id, webhookId)
assertEquals((webhook as OrganizationMembershipUpdatedEvent).data.id, organizationMembershipId)
assertEquals((webhook as OrganizationMembershipEvent).data.id, organizationMembershipId)
}
}

0 comments on commit b29dc1e

Please sign in to comment.