Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(source-strings): add "updateOption" field support #266

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Crowdin.Api/SourceStrings/StringUploadResponseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class AttributesData

[JsonProperty("cleanupMode")]
public bool CleanupMode { get; set; }

[JsonProperty("updateOption")]
public UpdateOption UpdateOption { get; set; }
}
}
}
19 changes: 19 additions & 0 deletions src/Crowdin.Api/SourceStrings/UpdateOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

using System.ComponentModel;
using JetBrains.Annotations;

namespace Crowdin.Api.SourceStrings
{
[PublicAPI]
public enum UpdateOption
{
[Description("clear_translations_and_approvals")]
ClearTranslationsAndApprovals,

[Description("keep_translations")]
KeepTranslations,

[Description("keep_translations_and_approvals")]
KeepTranslationsAndApprovals
}
}
3 changes: 3 additions & 0 deletions src/Crowdin.Api/SourceStrings/UploadStringsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ public class UploadStringsRequest

[JsonProperty("importOptions")]
public SpreadsheetFileImportOptions? ImportOptions { get; set; }

[JsonProperty("updateOption")]
public UpdateOption? UpdateOption { get; set; }
}
}
201 changes: 22 additions & 179 deletions tests/Crowdin.Api.Tests/Core/Resources/SourceStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions tests/Crowdin.Api.Tests/Core/Resources/SourceStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@
}
},
"updateStrings": false,
"cleanupMode": false
"cleanupMode": false,
"updateOption": "keep_translations_and_approvals"
},
"createdAt": "2019-09-23T11:26:54+00:00",
"updatedAt": "2019-09-23T11:26:54+00:00",
Expand Down Expand Up @@ -206,7 +207,8 @@
"en": 2,
"de": 3
}
}
},
"updateOption": "keep_translations_and_approvals"
}</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public async Task UploadStrings()
["en"] = 2,
["de"] = 3
}
}
},
UpdateOption = UpdateOption.KeepTranslationsAndApprovals
};

string actualRequestJson = JsonConvert.SerializeObject(request, DefaultSettings);
Expand Down Expand Up @@ -132,6 +133,7 @@ private static void Assert_StringUploadResponseModel(StringUploadResponseModel?
Assert.Equal(new[] { 1, 2 }, attributes.LabelIds);
Assert.False(attributes.UpdateStrings);
Assert.False(attributes.CleanupMode);
Assert.Equal(UpdateOption.KeepTranslationsAndApprovals, attributes.UpdateOption);

SpreadsheetFileImportOptions? importOptions = attributes.ImportOptions;
Assert.NotNull(importOptions);
Expand Down
Loading