Skip to content

Commit 3b6fdba

Browse files
committed
Added: userData in IndexSettings
Fix #601
1 parent f041caa commit 3b6fdba

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Algolia.Search.Test/EndToEnd/Index/SettingsTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,15 @@ public async Task TestSettings()
129129
{"de", new List<string> {"attribute1", "attribute2"}},
130130
{"fi", new List<string> {"attribute3"}}
131131
},
132-
KeepDiacriticsOnCharacters = "øé"
132+
KeepDiacriticsOnCharacters = "øé",
133+
UserData = "User data"
133134
};
134135

135136
var saveSettingsResponse = await _index.SetSettingsAsync(settings);
136137
saveSettingsResponse.Wait();
137138

138139
var getSettingsResponse = await _index.GetSettingsAsync();
139-
var spceficPropertiesCheck = new List<string> { "AlternativesAsExact", "DecompoundedAttributes", "CustomSettings" };
140+
var spceficPropertiesCheck = new List<string> { "AlternativesAsExact", "DecompoundedAttributes", "CustomSettings", "UserData" };
140141
Assert.True(TestHelper.AreObjectsEqual(settings, getSettingsResponse, spceficPropertiesCheck.ToArray()));
141142

142143
// Check specific properties (couldn't be done by the helper)
@@ -145,6 +146,7 @@ public async Task TestSettings()
145146
Assert.True(getSettingsResponse.DecompoundedAttributes["de"].Contains("attribute2"));
146147
Assert.True(getSettingsResponse.DecompoundedAttributes.ContainsKey("fi"));
147148
Assert.True(getSettingsResponse.DecompoundedAttributes["fi"].Contains("attribute3"));
149+
Assert.AreEqual(getSettingsResponse.UserData.ToString(), settings.UserData.ToString());
148150

149151
// Set new values
150152
settings.TypoTolerance = "min";

src/Algolia.Search/Models/Settings/IndexSettings.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
using Algolia.Search.Serializer;
2525
using Newtonsoft.Json;
26-
using Newtonsoft.Json.Linq;
2726
using System.Collections.Generic;
2827

2928
namespace Algolia.Search.Models.Settings
@@ -337,5 +336,11 @@ public class IndexSettings
337336
/// </summary>
338337
[JsonExtensionData]
339338
public IDictionary<string, object> CustomSettings { get; set; }
339+
340+
/// <summary>
341+
/// Custom userData that could be added to the IndexSettings
342+
/// </summary>
343+
[JsonConverter(typeof(MultiTypeObjectConverter))]
344+
public object UserData { get; set; }
340345
}
341346
}

0 commit comments

Comments
 (0)