Skip to content

Commit 0b149b3

Browse files
committed
API Updates: Glossaries: add new fields support
1 parent dc265c9 commit 0b149b3

File tree

11 files changed

+179
-5
lines changed

11 files changed

+179
-5
lines changed

src/Crowdin.Api/Glossaries/AddTermRequest.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
using System;
23
using JetBrains.Annotations;
34
using Newtonsoft.Json;
45

@@ -25,6 +26,25 @@ public class AddTermRequest
2526
[JsonProperty("partOfSpeech")]
2627
public PartOfSpeech? PartOfSpeech { get; set; }
2728

29+
[JsonProperty("status")]
30+
public TermStatus? Status { get; set; }
31+
32+
[JsonProperty("type")]
33+
public TermType? Type { get; set; }
34+
35+
[JsonProperty("gender")]
36+
public TermGender? Gender { get; set; }
37+
38+
[JsonProperty("note")]
39+
public string? Note { get; set; }
40+
41+
[JsonProperty("url")]
42+
public string? Url { get; set; }
43+
44+
[JsonProperty("conceptId")]
45+
public int? ConceptId { get; set; }
46+
47+
[Obsolete]
2848
[JsonProperty("translationOfTermId")]
2949
public int? TranslationOfTermId { get; set; }
3050
}

src/Crowdin.Api/Glossaries/ExportGlossaryRequest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
using System.Collections.Generic;
23
using JetBrains.Annotations;
34
using Newtonsoft.Json;
45

@@ -9,5 +10,8 @@ public class ExportGlossaryRequest
910
{
1011
[JsonProperty("format")]
1112
public GlossaryFormat Format { get; set; }
13+
14+
[JsonProperty("exportFields")]
15+
public ICollection<GlossaryExportFieldId> ExportFields { get; set; }
1216
}
1317
}

src/Crowdin.Api/Glossaries/GlossariesApiExecutor.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ public async Task<GlossaryImportStatus> CheckGlossaryImportStatus(int glossaryId
190190
[PublicAPI]
191191
public Task<ResponseList<Term>> ListTerms(
192192
int glossaryId, int? userId = null, string? languageId = null,
193-
int? translationOfTermId = null, int limit = 25, int offset = 0)
193+
int? translationOfTermId = null, int? conceptId = null, int limit = 25, int offset = 0)
194194
{
195195
return ListTerms(glossaryId,
196-
new TermsListParams(limit, offset, userId, languageId, translationOfTermId));
196+
new TermsListParams(limit, offset, userId, languageId, translationOfTermId, conceptId));
197197
}
198198

199199
/// <summary>
@@ -228,12 +228,15 @@ public async Task<Term> AddTerm(int glossaryId, AddTermRequest request)
228228
/// <a href="https://support.crowdin.com/enterprise/api/#operation/api.glossaries.terms.deleteMany">Crowdin Enterprise API</a>
229229
/// </summary>
230230
[PublicAPI]
231-
public async Task ClearGlossary(int glossaryId, string? languageId = null, int? translationOfTermId = null)
231+
public async Task ClearGlossary(
232+
int glossaryId, string? languageId = null,
233+
int? conceptId = null, int? translationOfTermId = null)
232234
{
233235
string url = FormUrl_Terms(glossaryId);
234236

235237
var queryParams = new Dictionary<string, string>();
236238
queryParams.AddParamIfPresent("languageId", languageId);
239+
queryParams.AddParamIfPresent("conceptId", conceptId);
237240
queryParams.AddParamIfPresent("translationOfTermId", translationOfTermId);
238241

239242
HttpStatusCode statusCode = await _apiClient.SendDeleteRequest(url, queryParams);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+

2+
using System.ComponentModel;
3+
using JetBrains.Annotations;
4+
5+
namespace Crowdin.Api.Glossaries
6+
{
7+
[PublicAPI]
8+
public enum GlossaryExportFieldId
9+
{
10+
[Description("term")]
11+
Term,
12+
13+
[Description("description")]
14+
Description,
15+
16+
[Description("partOfSpeech")]
17+
PartOfSpeech,
18+
19+
[Description("type")]
20+
Type,
21+
22+
[Description("status")]
23+
Status,
24+
25+
[Description("gender")]
26+
Gender,
27+
28+
[Description("note")]
29+
Note,
30+
31+
[Description("url")]
32+
Url
33+
}
34+
}

src/Crowdin.Api/Glossaries/GlossaryFormat.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public enum GlossaryFormat
1010
[Description("tbx")]
1111
Tbx,
1212

13+
[Description("tbx_v3")]
14+
TbxV3,
15+
1316
[Description("csv")]
1417
Csv,
1518

src/Crowdin.Api/Glossaries/Term.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ public class Term
2929
[JsonProperty("partOfSpeech")]
3030
public PartOfSpeech PartOfSpeech { get; set; }
3131

32+
[JsonProperty("status")]
33+
public TermStatus Status { get; set; }
34+
35+
[JsonProperty("type")]
36+
public TermType Type { get; set; }
37+
38+
[JsonProperty("gender")]
39+
public TermGender Gender { get; set; }
40+
41+
[JsonProperty("note")]
42+
public string Note { get; set; }
43+
44+
[JsonProperty("url")]
45+
public string Url { get; set; }
46+
47+
[JsonProperty("conceptId")]
48+
public int? ConceptId { get; set; }
49+
3250
[JsonProperty("lemma")]
3351
public string Lemma { get; set; }
3452

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+

2+
using System.ComponentModel;
3+
using JetBrains.Annotations;
4+
5+
namespace Crowdin.Api.Glossaries
6+
{
7+
[PublicAPI]
8+
public enum TermGender
9+
{
10+
[Description("masculine")]
11+
Masculine,
12+
13+
[Description("feminine")]
14+
Feminine,
15+
16+
[Description("neuter")]
17+
Neuter,
18+
19+
[Description("other")]
20+
Other
21+
}
22+
}

src/Crowdin.Api/Glossaries/TermPatch.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ public enum TermPatchPath
2222
Description,
2323

2424
[Description("/partOfSpeech")]
25-
PartOfSpeech
25+
PartOfSpeech,
26+
27+
[Description("/status")]
28+
Status,
29+
30+
[Description("/type")]
31+
Type,
32+
33+
[Description("/gender")]
34+
Gender,
35+
36+
[Description("/url")]
37+
Url,
38+
39+
[Description("/note")]
40+
Note
2641
}
2742
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+

2+
using System.ComponentModel;
3+
using JetBrains.Annotations;
4+
5+
namespace Crowdin.Api.Glossaries
6+
{
7+
[PublicAPI]
8+
public enum TermStatus
9+
{
10+
[Description("preferred")]
11+
Preferred,
12+
13+
[Description("admitted")]
14+
Admitted,
15+
16+
[Description("not recommended")]
17+
NotRecommended,
18+
19+
[Description("obsolete")]
20+
Obsolete
21+
}
22+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+

2+
using System.ComponentModel;
3+
using JetBrains.Annotations;
4+
5+
namespace Crowdin.Api.Glossaries
6+
{
7+
[PublicAPI]
8+
public enum TermType
9+
{
10+
[Description("full form")]
11+
FullForm,
12+
13+
[Description("acronym")]
14+
Acronym,
15+
16+
[Description("abbreviation")]
17+
Abbreviation,
18+
19+
[Description("short form")]
20+
ShortForm,
21+
22+
[Description("phrase")]
23+
Phrase,
24+
25+
[Description("variant")]
26+
Variant
27+
}
28+
}

0 commit comments

Comments
 (0)