Skip to content

Commit 6a779f3

Browse files
committed
fix deserialization/serialization of the API requests/responses + Replace types used in InternalDTOs with InternalDTO + use dedicated Json converter for sructs that act as enums + add missing models for the state layer to keep state & LLC layers models separated
1 parent 9cfae3a commit 6a779f3

65 files changed

Lines changed: 331 additions & 265 deletions

File tree

Some content is hidden

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

Assets/Plugins/StreamChat/Core/Helpers/ISavableToExt.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace StreamChat.Core.Helpers
88
internal static class ISavableToExt
99
{
1010
public static TDto TrySaveToDto<TDto>(this ISavableTo<TDto> source)
11-
where TDto : class
12-
=> source?.SaveToDto();
11+
=> source != default ? source.SaveToDto() : default;
1312
}
1413
}

Assets/Plugins/StreamChat/Core/InternalDTO/Models/AutomodBehaviourType.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Assets/Plugins/StreamChat/Core/InternalDTO/Models/AutomodType.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Assets/Plugins/StreamChat/Core/InternalDTO/Models/BlockListOptionsInternalDTO.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace StreamChat.Core.InternalDTO.Models
1717
internal partial class BlockListOptionsInternalDTO
1818
{
1919
[Newtonsoft.Json.JsonProperty("behavior", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
20-
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
21-
public BlockListOptionsBehavior Behavior { get; set; }
20+
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<BlockListOptionsBehaviorInternalDTO>))]
21+
public BlockListOptionsBehaviorInternalDTO Behavior { get; set; }
2222

2323
[Newtonsoft.Json.JsonProperty("blocklist", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2424
public string Blocklist { get; set; }

Assets/Plugins/StreamChat/Core/InternalDTO/Models/ChannelConfigInternalDTO.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ internal partial class ChannelConfigInternalDTO
2020
public System.Collections.Generic.List<string> AllowedFlagReasons { get; set; }
2121

2222
[Newtonsoft.Json.JsonProperty("automod", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
23-
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
24-
public AutomodType Automod { get; set; }
23+
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<AutomodTypeInternalDTO>))]
24+
public AutomodTypeInternalDTO Automod { get; set; }
2525

2626
[Newtonsoft.Json.JsonProperty("automod_behavior", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
27-
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
28-
public AutomodBehaviourType AutomodBehavior { get; set; }
27+
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<AutomodBehaviourTypeInternalDTO>))]
28+
public AutomodBehaviourTypeInternalDTO AutomodBehavior { get; set; }
2929

3030
[Newtonsoft.Json.JsonProperty("automod_thresholds", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3131
public ThresholdsInternalDTO AutomodThresholds { get; set; }
@@ -34,8 +34,8 @@ internal partial class ChannelConfigInternalDTO
3434
public string Blocklist { get; set; }
3535

3636
[Newtonsoft.Json.JsonProperty("blocklist_behavior", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
37-
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
38-
public AutomodBehaviourType? BlocklistBehavior { get; set; }
37+
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<AutomodBehaviourTypeInternalDTO>))]
38+
public AutomodBehaviourTypeInternalDTO BlocklistBehavior { get; set; }
3939

4040
[Newtonsoft.Json.JsonProperty("blocklists", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
4141
public System.Collections.Generic.List<BlockListOptionsInternalDTO> Blocklists { get; set; }

Assets/Plugins/StreamChat/Core/InternalDTO/Models/ChannelConfigWithInfoInternalDTO.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ internal partial class ChannelConfigWithInfoInternalDTO
2020
public System.Collections.Generic.List<string> AllowedFlagReasons { get; set; }
2121

2222
[Newtonsoft.Json.JsonProperty("automod", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
23-
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
24-
public AutomodType Automod { get; set; }
23+
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<AutomodTypeInternalDTO>))]
24+
public AutomodTypeInternalDTO Automod { get; set; }
2525

2626
[Newtonsoft.Json.JsonProperty("automod_behavior", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
27-
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
28-
public AutomodBehaviourType AutomodBehavior { get; set; }
27+
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<AutomodBehaviourTypeInternalDTO>))]
28+
public AutomodBehaviourTypeInternalDTO AutomodBehavior { get; set; }
2929

3030
[Newtonsoft.Json.JsonProperty("automod_thresholds", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3131
public ThresholdsInternalDTO AutomodThresholds { get; set; }
@@ -34,8 +34,8 @@ internal partial class ChannelConfigWithInfoInternalDTO
3434
public string Blocklist { get; set; }
3535

3636
[Newtonsoft.Json.JsonProperty("blocklist_behavior", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
37-
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
38-
public AutomodBehaviourType? BlocklistBehavior { get; set; }
37+
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<AutomodBehaviourTypeInternalDTO>))]
38+
public AutomodBehaviourTypeInternalDTO BlocklistBehavior { get; set; }
3939

4040
[Newtonsoft.Json.JsonProperty("blocklists", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
4141
public System.Collections.Generic.List<BlockListOptionsInternalDTO> Blocklists { get; set; }

Assets/Plugins/StreamChat/Core/InternalDTO/Models/DeviceFieldsInternalDTO.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,13 @@ namespace StreamChat.Core.InternalDTO.Models
1616
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
1717
internal partial class DeviceFieldsInternalDTO
1818
{
19-
/// <summary>
20-
/// Device ID
21-
/// </summary>
2219
[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2320
public string Id { get; set; }
2421

2522
[Newtonsoft.Json.JsonProperty("push_provider", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
26-
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
27-
public PushProviderType PushProvider { get; set; }
23+
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<PushProviderTypeInternalDTO>))]
24+
public PushProviderTypeInternalDTO PushProvider { get; set; }
2825

29-
/// <summary>
30-
/// Name of the push provider configuration
31-
/// </summary>
3226
[Newtonsoft.Json.JsonProperty("push_provider_name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3327
public string PushProviderName { get; set; }
3428

Assets/Plugins/StreamChat/Core/InternalDTO/Models/DeviceInternalDTO.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,13 @@ internal partial class DeviceInternalDTO
2525
[Newtonsoft.Json.JsonProperty("disabled_reason", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
2626
public string DisabledReason { get; set; }
2727

28-
/// <summary>
29-
/// Device ID
30-
/// </summary>
3128
[Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
3229
public string Id { get; set; }
3330

3431
[Newtonsoft.Json.JsonProperty("push_provider", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
35-
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
36-
public PushProviderType PushProvider { get; set; }
32+
[Newtonsoft.Json.JsonConverter(typeof(StreamChat.Core.Serialization.EnumeratedStructConverter<PushProviderTypeInternalDTO>))]
33+
public PushProviderTypeInternalDTO PushProvider { get; set; }
3734

38-
/// <summary>
39-
/// Name of the push provider configuration
40-
/// </summary>
4135
[Newtonsoft.Json.JsonProperty("push_provider_name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
4236
public string PushProviderName { get; set; }
4337

Assets/Plugins/StreamChat/Core/InternalDTO/Models/ImageCropType.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1-
//----------------------
2-
// <auto-generated>
3-
// Generated using the NSwag toolchain v14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
4-
// </auto-generated>
5-
//----------------------
6-
7-
8-
using StreamChat.Core.InternalDTO.Responses;
9-
using StreamChat.Core.InternalDTO.Requests;
10-
using StreamChat.Core.InternalDTO.Events;
1+
using StreamChat.Core.LowLevelClient;
112

123
namespace StreamChat.Core.InternalDTO.Models
134
{
14-
using System = global::System;
15-
16-
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
17-
18-
public struct ImageCropType : System.IEquatable<ImageCropType>
5+
public readonly struct ImageCropType : System.IEquatable<ImageCropType>, ILoadableFrom<ImageCropTypeInternalDTO, ImageCropType>, ISavableTo<ImageCropTypeInternalDTO>
196
{
207
public ImageCropType(string value)
218
{
@@ -44,6 +31,11 @@ public ImageCropType(string value)
4431

4532
public static implicit operator string(ImageCropType type) => type._value;
4633

34+
ImageCropType ILoadableFrom<ImageCropTypeInternalDTO, ImageCropType>.LoadFromDto(ImageCropTypeInternalDTO dto)
35+
=> new ImageCropType(dto.Value);
36+
37+
ImageCropTypeInternalDTO ISavableTo<ImageCropTypeInternalDTO>.SaveToDto() => new ImageCropTypeInternalDTO(_value);
38+
4739
private readonly string _value;
4840
}
4941
}

Assets/Plugins/StreamChat/Core/InternalDTO/Models/ImageResizeType.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)