Skip to content

Commit 86e1151

Browse files
committed
Fixes for .NET Standard 2.0
1 parent 7e050cd commit 86e1151

2 files changed

Lines changed: 39 additions & 34 deletions

File tree

Deepgram/Common/Helpers.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,34 @@ public static string GetUserAgent()
3737
return $"deepgram/{libraryVersion} dotnet/{languageVersion}";
3838
}
3939

40-
public static string GetParameters(object? parameters)
40+
public static string GetParameters(object parameters = null)
4141
{
42-
var json = JsonConvert.SerializeObject(parameters);
43-
var jObj = (JObject)JsonConvert.DeserializeObject(json);
44-
4542
List<KeyValuePair<string, string>> paramList = new List<KeyValuePair<string, string>>();
4643

47-
foreach (var prop in jObj.Properties())
44+
if (parameters != null)
4845
{
49-
if (prop.HasValues && !String.IsNullOrEmpty(prop.Value.ToString()))
46+
47+
var json = JsonConvert.SerializeObject(parameters);
48+
var jObj = (JObject)JsonConvert.DeserializeObject(json);
49+
50+
foreach (var prop in jObj.Properties())
5051
{
51-
if (prop.Value.Type == JTokenType.Array)
52+
if (prop.HasValues && !String.IsNullOrEmpty(prop.Value.ToString()))
5253
{
53-
foreach (var value in prop.Values())
54+
if (prop.Value.Type == JTokenType.Array)
5455
{
55-
paramList.Add(new KeyValuePair<string, string>(prop.Name, HttpUtility.UrlEncode(value.ToString())));
56+
foreach (var value in prop.Values())
57+
{
58+
paramList.Add(new KeyValuePair<string, string>(prop.Name, HttpUtility.UrlEncode(value.ToString())));
59+
}
60+
}
61+
else
62+
{
63+
paramList.Add(new KeyValuePair<string, string>(prop.Name, HttpUtility.UrlEncode(prop.Value.ToString())));
5664
}
57-
}
58-
else
59-
{
60-
paramList.Add(new KeyValuePair<string, string>(prop.Name, HttpUtility.UrlEncode(prop.Value.ToString())));
6165
}
6266
}
67+
6368
}
6469

6570
return String.Join("&", paramList.Select(s => $"{s.Key}={s.Value.ToString()}")).ToLower();

Deepgram/Usage/GetUsageSummaryOptions.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,126 +9,126 @@ public class GetUsageSummaryOptions
99
/// Start date of the requested date range.
1010
/// </summary>
1111
[JsonProperty("start")]
12-
public DateTime? StartDateTime { get; set; }
12+
public Nullable<DateTime> StartDateTime { get; set; } = null;
1313

1414
/// <summary>
1515
/// End date of the requested date range.
1616
/// </summary>
1717
[JsonProperty("end")]
18-
public DateTime? EndDateTime { get; set; }
18+
public Nullable<DateTime> EndDateTime { get; set; } = null;
1919

2020
/// <summary>
2121
/// Limits results to requests made using the API key corresponding to the given accessor.
2222
/// </summary>
2323
[JsonProperty("accessor")]
24-
public string ApiKeyId { get; set; }
24+
public string ApiKeyId { get; set; } = null;
2525

2626
/// <summary>
2727
/// Limits results to requests associated with the specified tag(s).
2828
/// </summary>
2929
[JsonProperty("tag")]
30-
public string[]? Tag { get; set; }
30+
public string[] Tag { get; set; }
3131

3232
/// <summary>
3333
/// Limits results to requests processed using the specified method.
3434
/// </summary>
3535
[JsonProperty("method")]
36-
public RequestMethod? Method { get; set; }
36+
public Nullable<RequestMethod> Method { get; set; } = null;
3737

3838
/// <summary>
3939
/// Limits results to requests run with the specified model applied.
4040
/// </summary>
4141
[JsonProperty("model")]
42-
public string Model { get; set; }
42+
public string Model { get; set; } = null;
4343

4444
/// <summary>
4545
/// Limits results to requests that include the multichannel feature.
4646
/// </summary>
4747
[JsonProperty("multichannel")]
48-
public bool? MultiChannel { get; set; }
48+
public Nullable<bool> MultiChannel { get; set; } = null;
4949

5050
/// <summary>
5151
/// Limits results to requests that include the interim_results feature.
5252
/// </summary>
5353
[JsonProperty("interim_results")]
54-
public bool? InterimResults { get; set; }
54+
public Nullable<bool> InterimResults { get; set; } = null;
5555

5656
/// <summary>
5757
/// Limits results to requests that include the punctuate feature.
5858
/// </summary>
5959
[JsonProperty("punctuate")]
60-
public bool? Punctuate { get; set; }
60+
public Nullable<bool> Punctuate { get; set; } = null;
6161

6262
/// <summary>
6363
/// Limits results to requests that include the ner feature.
6464
/// </summary>
6565
[JsonProperty("ner")]
66-
public bool? NamedEntityRecognition { get; set; }
66+
public Nullable<bool> NamedEntityRecognition { get; set; } = null;
6767

6868
/// <summary>
6969
/// Limits results to requests that include the utterances feature.
7070
/// </summary>
7171
[JsonProperty("utterances")]
72-
public bool? Utterances { get; set; }
72+
public Nullable<bool> Utterances { get; set; } = null;
7373

7474
/// <summary>
7575
/// Limits results to requests that include the replace feature.
7676
/// </summary>
7777
[JsonProperty("replace")]
78-
public bool? Replace { get; set; }
78+
public Nullable<bool> Replace { get; set; } = null;
7979

8080
/// <summary>
8181
/// Limits results to requests that include the profanity_filter feature.
8282
/// </summary>
8383
[JsonProperty("profanity_filter")]
84-
public bool? ProfanityFilter { get; set; }
84+
public Nullable<bool> ProfanityFilter { get; set; } = null;
8585

8686
/// <summary>
8787
/// Limits results to requests that include the keywords feature.
8888
/// </summary>
8989
[JsonProperty("keywords")]
90-
public bool? Keywords { get; set; }
90+
public Nullable<bool> Keywords { get; set; } = null;
9191

9292
/// <summary>
9393
/// Limits results to requests that include the sentiment feature.
9494
/// </summary>
9595
[JsonProperty("sentiment")]
96-
public bool? Sentiment { get; set; }
96+
public Nullable<bool> Sentiment { get; set; } = null;
9797

9898
/// <summary>
9999
/// Limits results to requests that include the diarize feature.
100100
/// </summary>
101101
[JsonProperty("diarize")]
102-
public bool? Diarization { get; set; }
102+
public Nullable<bool> Diarization { get; set; } = null;
103103

104104
/// <summary>
105105
/// Limits results to requests that include the detect_language feature.
106106
/// </summary>
107107
[JsonProperty("detect_language")]
108-
public bool? DetectLanguage { get; set; }
108+
public Nullable<bool> DetectLanguage { get; set; } = null;
109109

110110
/// <summary>
111111
/// Limits results to requests that include the search feature.
112112
/// </summary>
113113
[JsonProperty("search")]
114-
public bool? Search { get; set; }
114+
public Nullable<bool> Search { get; set; } = null;
115115

116116
/// <summary>
117117
/// Limits results to requests that include the redact feature.
118118
/// </summary>
119119
[JsonProperty("redact")]
120-
public bool? Redaction { get; set; }
120+
public Nullable<bool> Redaction { get; set; } = null;
121121

122122
/// <summary>
123123
/// Limits results to requests that include the alternatives feature.
124124
/// </summary>
125125
[JsonProperty("alternatives")]
126-
public bool? Alternatives { get; set; }
126+
public Nullable<bool> Alternatives { get; set; } = null;
127127

128128
/// <summary>
129129
/// Limits results to requests that include the numerals feature.
130130
/// </summary>
131131
[JsonProperty("numerals")]
132-
public bool? Numerals { get; set; }
132+
public Nullable<bool> Numerals { get; set; } = null;
133133
}
134134
}

0 commit comments

Comments
 (0)