@@ -77,7 +77,7 @@ public ApiClient(Configuration config)
77
77
/// <param name="basePath">The base path.</param>
78
78
public ApiClient ( String basePath = "https://api.sendinblue.com/v3" )
79
79
{
80
- if ( String . IsNullOrEmpty ( basePath ) )
80
+ if ( String . IsNullOrEmpty ( basePath ) )
81
81
throw new ArgumentException ( "basePath cannot be empty" ) ;
82
82
83
83
RestClient = new RestClient ( basePath ) ;
@@ -121,23 +121,23 @@ private RestRequest PrepareRequest(
121
121
request . Serializer = null ;
122
122
123
123
// add path parameter, if any
124
- foreach ( var param in pathParams )
124
+ foreach ( var param in pathParams )
125
125
request . AddParameter ( param . Key , param . Value , ParameterType . UrlSegment ) ;
126
126
127
127
// add header parameter, if any
128
- foreach ( var param in headerParams )
128
+ foreach ( var param in headerParams )
129
129
request . AddHeader ( param . Key , param . Value ) ;
130
130
131
131
// add query parameter, if any
132
- foreach ( var param in queryParams )
132
+ foreach ( var param in queryParams )
133
133
request . AddQueryParameter ( param . Key , param . Value ) ;
134
134
135
135
// add form parameter, if any
136
- foreach ( var param in formParams )
136
+ foreach ( var param in formParams )
137
137
request . AddParameter ( param . Key , param . Value ) ;
138
138
139
139
// add file parameter, if any
140
- foreach ( var param in fileParams )
140
+ foreach ( var param in fileParams )
141
141
{
142
142
request . AddFile ( param . Value ) ;
143
143
}
@@ -175,15 +175,18 @@ public Object CallApi(
175
175
176
176
// set timeout
177
177
RestClient . Timeout = TimeSpan . FromMilliseconds ( Configuration . Timeout ) ;
178
-
178
+
179
179
// set user agent
180
- RestClient . UserAgent = Configuration . UserAgent . Replace ( "v#" , "v3.1.0" ) ;
180
+ if ( ! Configuration . UserAgent . ToLower ( ) . StartsWith ( "sendinblue_" ) )
181
+ Configuration . UserAgent = "sendinblue_clientAPI/v3.1.0/c#" ;
182
+
183
+ RestClient . UserAgent = Configuration . UserAgent ;
181
184
182
185
InterceptRequest ( request ) ;
183
186
var response = RestClient . Execute ( request ) . Result ;
184
187
InterceptResponse ( request , response ) ;
185
188
186
- return ( Object ) response ;
189
+ return ( Object ) response ;
187
190
}
188
191
/// <summary>
189
192
/// Makes the asynchronous HTTP request.
@@ -251,13 +254,13 @@ public string ParameterToString(object obj)
251
254
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
252
255
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
253
256
// For example: 2009-06-15T13:45:30.0000000
254
- return ( ( DateTime ) obj ) . ToString ( Configuration . DateTimeFormat ) ;
257
+ return ( ( DateTime ) obj ) . ToString ( Configuration . DateTimeFormat ) ;
255
258
else if ( obj is DateTimeOffset )
256
259
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
257
260
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
258
261
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
259
262
// For example: 2009-06-15T13:45:30.0000000
260
- return ( ( DateTimeOffset ) obj ) . ToString ( Configuration . DateTimeFormat ) ;
263
+ return ( ( DateTimeOffset ) obj ) . ToString ( Configuration . DateTimeFormat ) ;
261
264
else if ( obj is IList )
262
265
{
263
266
var flattenedString = new StringBuilder ( ) ;
@@ -272,7 +275,7 @@ public string ParameterToString(object obj)
272
275
else if ( obj is bool )
273
276
return ( ( bool ) obj ) . ToString ( ) . ToLower ( ) ;
274
277
else
275
- return Convert . ToString ( obj ) ;
278
+ return Convert . ToString ( obj ) ;
276
279
}
277
280
278
281
/// <summary>
@@ -315,7 +318,7 @@ public object Deserialize(IRestResponse response, Type type)
315
318
316
319
if ( type . Name . StartsWith ( "System.Nullable`1[[System.DateTime" ) ) // return a datetime object
317
320
{
318
- return DateTime . Parse ( response . Content , null , System . Globalization . DateTimeStyles . RoundtripKind ) ;
321
+ return DateTime . Parse ( response . Content , null , System . Globalization . DateTimeStyles . RoundtripKind ) ;
319
322
}
320
323
321
324
if ( type == typeof ( String ) || type . Name . StartsWith ( "System.Nullable" ) ) // return primitive type
@@ -434,7 +437,7 @@ public static dynamic ConvertType(dynamic fromObject, Type toObject)
434
437
/// <returns>Byte array</returns>
435
438
public static byte [ ] ReadAsBytes ( Stream inputStream )
436
439
{
437
- byte [ ] buf = new byte [ 16 * 1024 ] ;
440
+ byte [ ] buf = new byte [ 16 * 1024 ] ;
438
441
using ( MemoryStream ms = new MemoryStream ( ) )
439
442
{
440
443
int count ;
0 commit comments