Skip to content

Commit 474de82

Browse files
author
stlc-bot
committed
Build SDK
Stainless-Generated-From: 342e264
1 parent a53cb3d commit 474de82

4 files changed

Lines changed: 28 additions & 71 deletions

File tree

‎src/Imagekit.Tests/Models/Webhooks/FolderUpdateEventTest.cs‎

Lines changed: 14 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void FieldRoundtrip_Works()
3131
Type = FolderType.Folder,
3232
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
3333
},
34-
Previous = new() { FolderPath = "folderPath" },
34+
Previous = new("folderPath"),
3535
};
3636

3737
string expectedID = "id";
@@ -51,7 +51,7 @@ public void FieldRoundtrip_Works()
5151
Type = FolderType.Folder,
5252
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
5353
};
54-
Previous expectedPrevious = new() { FolderPath = "folderPath" };
54+
Previous expectedPrevious = new("folderPath");
5555

5656
Assert.Equal(expectedID, model.ID);
5757
Assert.Equal(expectedType, model.Type);
@@ -82,7 +82,7 @@ public void SerializationRoundtrip_Works()
8282
Type = FolderType.Folder,
8383
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
8484
},
85-
Previous = new() { FolderPath = "folderPath" },
85+
Previous = new("folderPath"),
8686
};
8787

8888
string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions);
@@ -116,7 +116,7 @@ public void FieldRoundtripThroughSerialization_Works()
116116
Type = FolderType.Folder,
117117
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
118118
},
119-
Previous = new() { FolderPath = "folderPath" },
119+
Previous = new("folderPath"),
120120
};
121121

122122
string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions);
@@ -143,7 +143,7 @@ public void FieldRoundtripThroughSerialization_Works()
143143
Type = FolderType.Folder,
144144
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
145145
};
146-
Previous expectedPrevious = new() { FolderPath = "folderPath" };
146+
Previous expectedPrevious = new("folderPath");
147147

148148
Assert.Equal(expectedID, deserialized.ID);
149149
Assert.Equal(expectedType, deserialized.Type);
@@ -174,7 +174,7 @@ public void Validation_Works()
174174
Type = FolderType.Folder,
175175
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
176176
},
177-
Previous = new() { FolderPath = "folderPath" },
177+
Previous = new("folderPath"),
178178
};
179179

180180
model.Validate();
@@ -318,7 +318,7 @@ public void CopyConstructor_Works()
318318
Type = FolderType.Folder,
319319
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
320320
},
321-
Previous = new() { FolderPath = "folderPath" },
321+
Previous = new("folderPath"),
322322
};
323323

324324
FolderUpdateEvent copied = new(model);
@@ -349,7 +349,7 @@ public void FieldRoundtrip_Works()
349349
Type = FolderType.Folder,
350350
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
351351
},
352-
Previous = new() { FolderPath = "folderPath" },
352+
Previous = new("folderPath"),
353353
};
354354

355355
DateTimeOffset expectedCreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z");
@@ -368,7 +368,7 @@ public void FieldRoundtrip_Works()
368368
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
369369
};
370370
JsonElement expectedType = JsonSerializer.SerializeToElement("folder.updated");
371-
Previous expectedPrevious = new() { FolderPath = "folderPath" };
371+
Previous expectedPrevious = new("folderPath");
372372

373373
Assert.Equal(expectedCreatedAt, model.CreatedAt);
374374
Assert.Equal(expectedData, model.Data);
@@ -396,7 +396,7 @@ public void SerializationRoundtrip_Works()
396396
Type = FolderType.Folder,
397397
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
398398
},
399-
Previous = new() { FolderPath = "folderPath" },
399+
Previous = new("folderPath"),
400400
};
401401

402402
string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions);
@@ -428,7 +428,7 @@ public void FieldRoundtripThroughSerialization_Works()
428428
Type = FolderType.Folder,
429429
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
430430
},
431-
Previous = new() { FolderPath = "folderPath" },
431+
Previous = new("folderPath"),
432432
};
433433

434434
string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions);
@@ -454,7 +454,7 @@ public void FieldRoundtripThroughSerialization_Works()
454454
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
455455
};
456456
JsonElement expectedType = JsonSerializer.SerializeToElement("folder.updated");
457-
Previous expectedPrevious = new() { FolderPath = "folderPath" };
457+
Previous expectedPrevious = new("folderPath");
458458

459459
Assert.Equal(expectedCreatedAt, deserialized.CreatedAt);
460460
Assert.Equal(expectedData, deserialized.Data);
@@ -482,7 +482,7 @@ public void Validation_Works()
482482
Type = FolderType.Folder,
483483
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
484484
},
485-
Previous = new() { FolderPath = "folderPath" },
485+
Previous = new("folderPath"),
486486
};
487487

488488
model.Validate();
@@ -616,7 +616,7 @@ public void CopyConstructor_Works()
616616
Type = FolderType.Folder,
617617
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
618618
},
619-
Previous = new() { FolderPath = "folderPath" },
619+
Previous = new("folderPath"),
620620
};
621621

622622
FolderUpdateEventFolderUpdateEvent copied = new(model);
@@ -673,48 +673,6 @@ public void Validation_Works()
673673
model.Validate();
674674
}
675675

676-
[Fact]
677-
public void OptionalNonNullablePropertiesUnsetAreNotSet_Works()
678-
{
679-
var model = new Previous { };
680-
681-
Assert.Null(model.FolderPath);
682-
Assert.False(model.RawData.ContainsKey("folderPath"));
683-
}
684-
685-
[Fact]
686-
public void OptionalNonNullablePropertiesUnsetValidation_Works()
687-
{
688-
var model = new Previous { };
689-
690-
model.Validate();
691-
}
692-
693-
[Fact]
694-
public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works()
695-
{
696-
var model = new Previous
697-
{
698-
// Null should be interpreted as omitted for these properties
699-
FolderPath = null,
700-
};
701-
702-
Assert.Null(model.FolderPath);
703-
Assert.False(model.RawData.ContainsKey("folderPath"));
704-
}
705-
706-
[Fact]
707-
public void OptionalNonNullablePropertiesSetToNullValidation_Works()
708-
{
709-
var model = new Previous
710-
{
711-
// Null should be interpreted as omitted for these properties
712-
FolderPath = null,
713-
};
714-
715-
model.Validate();
716-
}
717-
718676
[Fact]
719677
public void CopyConstructor_Works()
720678
{

‎src/Imagekit.Tests/Models/Webhooks/UnsafeUnwrapWebhookEventTest.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ public void FolderUpdateValidationWorks()
732732
Type = Files::FolderType.Folder,
733733
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
734734
},
735-
Previous = new() { FolderPath = "folderPath" },
735+
Previous = new("folderPath"),
736736
};
737737
value.Validate();
738738
}
@@ -1550,7 +1550,7 @@ public void FolderUpdateSerializationRoundtripWorks()
15501550
Type = Files::FolderType.Folder,
15511551
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
15521552
},
1553-
Previous = new() { FolderPath = "folderPath" },
1553+
Previous = new("folderPath"),
15541554
};
15551555
string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions);
15561556
var deserialized = JsonSerializer.Deserialize<Webhooks::UnsafeUnwrapWebhookEvent>(

‎src/Imagekit.Tests/Models/Webhooks/UnwrapWebhookEventTest.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ public void FolderUpdateValidationWorks()
732732
Type = Files::FolderType.Folder,
733733
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
734734
},
735-
Previous = new() { FolderPath = "folderPath" },
735+
Previous = new("folderPath"),
736736
};
737737
value.Validate();
738738
}
@@ -1550,7 +1550,7 @@ public void FolderUpdateSerializationRoundtripWorks()
15501550
Type = Files::FolderType.Folder,
15511551
UpdatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
15521552
},
1553-
Previous = new() { FolderPath = "folderPath" },
1553+
Previous = new("folderPath"),
15541554
};
15551555
string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions);
15561556
var deserialized = JsonSerializer.Deserialize<Webhooks::UnwrapWebhookEvent>(

‎src/Imagekit/Models/Webhooks/FolderUpdateEvent.cs‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,22 +279,14 @@ public sealed record class Previous : JsonModel
279279
/// <summary>
280280
/// Path of the folder before it was renamed.
281281
/// </summary>
282-
public string? FolderPath
282+
public required string FolderPath
283283
{
284284
get
285285
{
286286
this._rawData.Freeze();
287-
return this._rawData.GetNullableClass<string>("folderPath");
288-
}
289-
init
290-
{
291-
if (value == null)
292-
{
293-
return;
294-
}
295-
296-
this._rawData.Set("folderPath", value);
287+
return this._rawData.GetNotNullClass<string>("folderPath");
297288
}
289+
init { this._rawData.Set("folderPath", value); }
298290
}
299291

300292
/// <inheritdoc/>
@@ -329,6 +321,13 @@ public static Previous FromRawUnchecked(IReadOnlyDictionary<string, JsonElement>
329321
{
330322
return new(FrozenDictionary.ToFrozenDictionary(rawData));
331323
}
324+
325+
[SetsRequiredMembers]
326+
public Previous(string folderPath)
327+
: this()
328+
{
329+
this.FolderPath = folderPath;
330+
}
332331
}
333332

334333
class PreviousFromRaw : IFromRawJson<Previous>

0 commit comments

Comments
 (0)