Skip to content

Commit 4aefdda

Browse files
feat(events): add events (#82)
* feat(events): add list events * refactor: remove webhook events
1 parent 7740c06 commit 4aefdda

File tree

111 files changed

+2098
-1550
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+2098
-1550
lines changed

src/directory_sync/types/directory.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use derive_more::{Deref, Display, From};
22
use serde::{Deserialize, Serialize};
33

44
use crate::directory_sync::DirectoryType;
5-
use crate::organizations::OrganizationId;
5+
use crate::organizations::{OrganizationDomainId, OrganizationId};
66
use crate::{KnownOrUnknown, Timestamps};
77

88
/// The ID of a [`Directory`].
@@ -35,7 +35,7 @@ pub enum DirectoryState {
3535
}
3636

3737
/// [WorkOS Docs: Directory](https://workos.com/docs/reference/directory-sync/directory)
38-
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
38+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3939
pub struct Directory {
4040
/// The ID of the directory.
4141
pub id: DirectoryId,
@@ -60,6 +60,42 @@ pub struct Directory {
6060
pub timestamps: Timestamps,
6161
}
6262

63+
/// An organization domain of a [`DirectoryEvent`].
64+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
65+
pub struct DirectoryEventDomain {
66+
/// Unique identifier of the organization domain.
67+
pub id: OrganizationDomainId,
68+
69+
/// Domain for the organization domain.
70+
pub domain: String,
71+
}
72+
73+
/// [WorkOS Docs: Directory Sync events](https://workos.com/docs/events/directory-sync)
74+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
75+
pub struct DirectoryEvent {
76+
/// The ID of the directory.
77+
pub id: DirectoryId,
78+
79+
/// The ID of the associated [`Organization`](crate::organizations::Organization) for this directory.
80+
pub organization_id: Option<OrganizationId>,
81+
82+
/// The type of the directory.
83+
pub r#type: KnownOrUnknown<DirectoryType, String>,
84+
85+
/// The state of the directory.
86+
pub state: KnownOrUnknown<DirectoryState, String>,
87+
88+
/// The name of the directory.
89+
pub name: String,
90+
91+
/// The domains of the directory.
92+
pub domains: Vec<DirectoryEventDomain>,
93+
94+
/// The timestamps for the Directory.
95+
#[serde(flatten)]
96+
pub timestamps: Timestamps,
97+
}
98+
6399
#[cfg(test)]
64100
mod test {
65101
use serde_json::json;

src/events.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//! A module for interacting with the WorkOS Events API.
2+
//!
3+
//! [WorkOS Docs: Events Guide](https://workos.com/docs/events/guide)
4+
5+
mod operations;
6+
mod types;
7+
8+
pub use operations::*;
9+
pub use types::*;
10+
11+
use crate::WorkOs;
12+
13+
/// Events.
14+
///
15+
/// [WorkOS Docs: Events Guide](https://workos.com/docs/events/guide)
16+
pub struct Events<'a> {
17+
workos: &'a WorkOs,
18+
}
19+
20+
impl<'a> Events<'a> {
21+
/// Returns a new [`Events`] instance for the provided WorkOS client.
22+
pub fn new(workos: &'a WorkOs) -> Self {
23+
Self { workos }
24+
}
25+
}

src/events/operations.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mod list_events;
2+
3+
pub use list_events::*;

0 commit comments

Comments
 (0)