| 1 | using System.Text.Json; |
| 2 | using System.Text.Json.Serialization; |
| 3 | |
| 4 | namespace IntercomService.Contracts; |
| 5 | |
| 6 | public sealed record SenderDto( |
| 7 | [property: JsonPropertyName("member_id")] string MemberId, |
| 8 | [property: JsonPropertyName("display_name")] string DisplayName, |
| 9 | [property: JsonPropertyName("sender_role")] string SenderRole, |
| 10 | [property: JsonPropertyName("client_kind")] string ClientKind); |
| 11 | |
| 12 | public sealed record TransportEventEnvelopeDto( |
| 13 | [property: JsonPropertyName("schema_version")] int SchemaVersion, |
| 14 | [property: JsonPropertyName("seq")] long Seq, |
| 15 | [property: JsonPropertyName("team_id")] string TeamId, |
| 16 | [property: JsonPropertyName("topic_id")] string TopicId, |
| 17 | [property: JsonPropertyName("client_event_id")] string ClientEventId, |
| 18 | [property: JsonPropertyName("occurred_at_utc")] string OccurredAtUtc, |
| 19 | [property: JsonPropertyName("event_kind")] string EventKind, |
| 20 | [property: JsonPropertyName("sender")] SenderDto Sender, |
| 21 | [property: JsonPropertyName("payload")] JsonElement Payload); |
| 22 | |
| 23 | public sealed record AppendEventRequest( |
| 24 | [property: JsonPropertyName("schema_version")] int SchemaVersion, |
| 25 | [property: JsonPropertyName("client_event_id")] string ClientEventId, |
| 26 | [property: JsonPropertyName("occurred_at_utc")] string? OccurredAtUtc, |
| 27 | [property: JsonPropertyName("event_kind")] string EventKind, |
| 28 | [property: JsonPropertyName("sender")] SenderDto? Sender, |
| 29 | [property: JsonPropertyName("payload")] JsonElement Payload); |
| 30 | |
| 31 | public sealed record CreateTopicRequest( |
| 32 | [property: JsonPropertyName("title")] string Title, |
| 33 | [property: JsonPropertyName("spine_key")] string? SpineKey); |
| 34 | |
| 35 | public sealed record EnsureTopicRequest( |
| 36 | [property: JsonPropertyName("spine_key")] string SpineKey, |
| 37 | [property: JsonPropertyName("title")] string? Title); |
| 38 | |
| 39 | public sealed record TopicDto( |
| 40 | [property: JsonPropertyName("topic_id")] string TopicId, |
| 41 | [property: JsonPropertyName("team_id")] string TeamId, |
| 42 | [property: JsonPropertyName("title")] string Title, |
| 43 | [property: JsonPropertyName("spine_key")] string? SpineKey); |
| 44 | |
| 45 | public sealed record TokenResponse( |
| 46 | [property: JsonPropertyName("access_token")] string AccessToken, |
| 47 | [property: JsonPropertyName("refresh_token")] string RefreshToken, |
| 48 | [property: JsonPropertyName("expires_in")] int ExpiresIn, |
| 49 | [property: JsonPropertyName("token_type")] string TokenType = "Bearer"); |
| 50 | |
| 51 | public sealed record RefreshTokenRequest( |
| 52 | [property: JsonPropertyName("grant_type")] string GrantType, |
| 53 | [property: JsonPropertyName("refresh_token")] string? RefreshToken); |
| 54 | |
| 55 | public sealed record OAuthTokenRequest( |
| 56 | [property: JsonPropertyName("grant_type")] string GrantType, |
| 57 | [property: JsonPropertyName("refresh_token")] string? RefreshToken, |
| 58 | [property: JsonPropertyName("code")] string? Code, |
| 59 | [property: JsonPropertyName("state")] string? State, |
| 60 | [property: JsonPropertyName("code_verifier")] string? CodeVerifier, |
| 61 | [property: JsonPropertyName("redirect_uri")] string? RedirectUri); |
| 62 | |
| 63 | public static class IntercomJson |
| 64 | { |
| 65 | public static readonly JsonSerializerOptions Web = new(JsonSerializerDefaults.Web); |
| 66 | } |
| 67 | |