| 1 | using System.Text.Json; |
| 2 | using System.Text.Json.Serialization; |
| 3 | |
| 4 | namespace IntercomService.Services; |
| 5 | |
| 6 | public sealed class JoinPolicyConfig |
| 7 | { |
| 8 | [JsonPropertyName("github_orgs")] |
| 9 | public List<string> GitHubOrgs { get; set; } = []; |
| 10 | |
| 11 | [JsonPropertyName("github_repos")] |
| 12 | public List<string> GitHubRepos { get; set; } = []; |
| 13 | |
| 14 | public static JoinPolicyConfig Parse(string? json) |
| 15 | { |
| 16 | if (string.IsNullOrWhiteSpace(json)) |
| 17 | return new JoinPolicyConfig(); |
| 18 | |
| 19 | try |
| 20 | { |
| 21 | return JsonSerializer.Deserialize<JoinPolicyConfig>(json, IntercomService.Contracts.IntercomJson.Web) |
| 22 | ?? new JoinPolicyConfig(); |
| 23 | } |
| 24 | catch (JsonException) |
| 25 | { |
| 26 | return new JoinPolicyConfig(); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | public string ToJson() => |
| 31 | JsonSerializer.Serialize(this, IntercomService.Contracts.IntercomJson.Web); |
| 32 | } |
| 33 | |
View only · write via MCP/CIDE