Skip to content

Commit 33dbfe5

Browse files
committed
Added additional language parameter.
1 parent 150a18d commit 33dbfe5

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

Optimizely.Graph.Source.Sdk/Optimizely.Graph.Source.Sdk.Sample/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
}
193193
};
194194

195-
await client.SaveContentAsync(generateId: (x) => $"{x.Name}_{x.Address.City}", exampleDataInstance1, exampleDataInstance2, exampleDataInstance3);
195+
await client.SaveContentAsync(generateId: (x) => $"{x.Name}_{x.Address.City}", "en", exampleDataInstance1, exampleDataInstance2, exampleDataInstance3);
196196
#endregion
197197

198198
#region ExampleTypes

Optimizely.Graph.Source.Sdk/Optimizely.Graph.Source.Sdk.Tests/RepositoryTests/GraphSourceRepositoryTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public async Task SaveContentAsync_SerializesData_AndCallsGraphClient()
206206
mockRestClient.Setup(c => c.HandleResponse(response));
207207

208208
// Act
209-
await repository.SaveContentAsync(generateId: (x) => x.ToString(), exampleData);
209+
await repository.SaveContentAsync(generateId: (x) => x.ToString(), "en", exampleData);
210210

211211
// Assert
212212
mockRestClient.Verify(c => c.SendAsync(It.Is<HttpRequestMessage>(x => Compare(request, x))), Times.Once);
@@ -316,7 +316,7 @@ public async Task SaveContentAsync_WithMultipleTypes_ShouldGenerateJsonForConten
316316
mockRestClient.Setup(c => c.HandleResponse(response));
317317

318318
// Act
319-
await repository.SaveContentAsync<object>(generateId, locationStockholm, locationLondon, event1, event2, event3);
319+
await repository.SaveContentAsync<object>(generateId, "en", locationStockholm, locationLondon, event1, event2, event3);
320320

321321
// Assert
322322
Assert.AreEqual(expectedJsonString, jsonString);
@@ -353,7 +353,7 @@ public async Task CreateContent_ShouldContainTwoNewLines()
353353
};
354354

355355
// Act
356-
var createdContent = repository.CreateContent(generateId: (x) => x.ToString(), exampleData);
356+
var createdContent = repository.CreateContent(generateId: (x) => x.ToString(), "en", exampleData);
357357
var result = createdContent.ReadAsStringAsync().Result;
358358

359359
// Assert
@@ -387,7 +387,7 @@ public async Task CreateContent_ShouldProduceMinifiedContent()
387387
};
388388

389389
// Act
390-
var createdContent = repository.CreateContent(generateId: (x) => x.ToString(), exampleData);
390+
var createdContent = repository.CreateContent(generateId: (x) => x.ToString(), "en", exampleData);
391391
var result = createdContent.ReadAsStringAsync().Result;
392392

393393
// Assert

Optimizely.Graph.Source.Sdk/Optimizely.Graph.Source.Sdk/GraphSourceClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ public async Task<string> SaveTypesAsync()
8989
/// <param name="generateId">Id associated with content.</param>
9090
/// <param name="data">Dynamic data being saved to Content Graph.</param>
9191
/// <returns></returns>
92-
public async Task<string> SaveContentAsync<T>(Func<T, string> generateId, params T[] data)
92+
public async Task<string> SaveContentAsync<T>(Func<T, string> generateId, string language, params T[] data)
9393
where T : class, new()
9494
{
95-
return await repository.SaveContentAsync(generateId, data);
95+
return await repository.SaveContentAsync(generateId, language, data);
9696
}
9797

9898
/// <summary>

Optimizely.Graph.Source.Sdk/Optimizely.Graph.Source.Sdk/Repositories/GraphSourceRepository.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public async Task<string> SaveTypesAsync()
8080
}
8181

8282
/// <inheritdoc/>
83-
public async Task<string> SaveContentAsync<T>(Func<T, string> generateId, params T[] data)
83+
public async Task<string> SaveContentAsync<T>(Func<T, string> generateId, string language, params T[] data)
8484
where T : class, new()
8585
{
86-
var content = CreateContent(generateId, data);
86+
var content = CreateContent(generateId, language, data);
8787

8888
using (var requestMessage = new HttpRequestMessage(HttpMethod.Post, $"{DataUrl}?id={source}"))
8989
{
@@ -96,7 +96,7 @@ public async Task<string> SaveContentAsync<T>(Func<T, string> generateId, params
9696
return string.Empty;
9797
}
9898

99-
public StringContent CreateContent<T>(Func<T, string> generateId, params T[] data)
99+
public StringContent CreateContent<T>(Func<T, string> generateId, string language, params T[] data)
100100
{
101101
var serializeOptions = new JsonSerializerOptions
102102
{
@@ -111,7 +111,6 @@ public StringContent CreateContent<T>(Func<T, string> generateId, params T[] dat
111111
foreach (var item in data)
112112
{
113113
var id = generateId(item);
114-
var language = "en";
115114

116115
itemJson += $"{{\"index\":{{\"_id\":\"{id}\",\"language_routing\":\"{language}\"}}}}";
117116
itemJson += Environment.NewLine;

Optimizely.Graph.Source.Sdk/Optimizely.Graph.Source.Sdk/Repositories/IGraphSourceRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public interface IGraphSourceRepository
4040
/// <param name="generateId">Id associated with content.</param>
4141
/// <param name="data">Dynamic data being saved to Content Graph.</param>
4242
/// <returns></returns>
43-
Task<string> SaveContentAsync<T>(Func<T, string> generateId, params T[] data) where T : class, new();
43+
Task<string> SaveContentAsync<T>(Func<T, string> generateId, string language, params T[] data) where T : class, new();
4444

4545
/// <summary>
4646
/// Removes content previously stored by source.

0 commit comments

Comments
 (0)