Skip to content

Commit

Permalink
Updated to generate clients with serverUrl and timeout parameters for…
Browse files Browse the repository at this point in the history
… constructors.
  • Loading branch information
KSGRelewise committed Aug 8, 2024
1 parent a515994 commit 44fc285
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Generator/JavaClientWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ public void GenerateClientClass(Type clientType, string[] clientMethodNames)
})
.ToArray();


int timeout = 5;
if (clientType.GetConstructor(new[] { typeof(Guid), typeof(string), typeof(int) }) is { } constructor
&& constructor.GetParameters().Last() is { HasDefaultValue: true } requestTimeoutInSecondsParameter)
{
timeout = (int)requestTimeoutInSecondsParameter.DefaultValue!;
}


writer.WriteLine($"""
package {Constants.Namespace};
Expand All @@ -59,7 +68,8 @@ public void GenerateClientClass(Type clientType, string[] clientMethodNames)
writer.WriteLine($"public class {clientType.Name} extends RelewiseClient");
writer.WriteLine("{");
writer.Indent++;
writer.WriteLine($"public {clientType.Name}(String datasetId, String apiKey) {{ super(datasetId, apiKey); }}");
writer.WriteLine($"public {clientType.Name}(String datasetId, String apiKey, String serverUrl) {{ super(datasetId, apiKey, serverUrl, {timeout}); }}");
writer.WriteLine($"public {clientType.Name}(String datasetId, String apiKey, String serverUrl, int timeout) {{ super(datasetId, apiKey, serverUrl, timeout); }}");

foreach (var method in clientMethods.DistinctBy(method => method.parameterType))
{
Expand Down

0 comments on commit 44fc285

Please sign in to comment.