Class ClientUtils
Utility functions providing some benefit to API client consumers.
Inherited Members
Namespace: mailslurp.Client
Assembly: mailslurp.dll
Syntax
public static class ClientUtils
Fields
View SourceJsonRegex
Provides a case-insensitive check that a provided content type is a known JSON-like content type.
Declaration
public static readonly Regex JsonRegex
Field Value
Type | Description |
---|---|
Regex |
Methods
View SourceBase64Encode(string)
Encode string in base64 format.
Declaration
public static string Base64Encode(string text)
Parameters
Type | Name | Description |
---|---|---|
string | text | string to be encoded. |
Returns
Type | Description |
---|---|
string | Encoded string. |
IsJsonMime(string)
Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json
Declaration
public static bool IsJsonMime(string mime)
Parameters
Type | Name | Description |
---|---|---|
string | mime | MIME |
Returns
Type | Description |
---|---|
bool | Returns True if MIME type is json. |
ParameterToMultiMap(string, string, object)
Convert params to key/value pairs. Use collectionFormat to properly format lists and collections.
Declaration
public static Multimap<string, string> ParameterToMultiMap(string collectionFormat, string name, object value)
Parameters
Type | Name | Description |
---|---|---|
string | collectionFormat | The swagger-supported collection format, one of: csv, tsv, ssv, pipes, multi |
string | name | Key name. |
object | value | Value object. |
Returns
Type | Description |
---|---|
Multimap<string, string> | A multimap of keys with 1..n associated values. |
ParameterToString(object, IReadableConfiguration)
If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. If parameter is a list, join the list with ",". Otherwise just return the string.
Declaration
public static string ParameterToString(object obj, IReadableConfiguration configuration = null)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The parameter (header, path, query, form). |
IReadableConfiguration | configuration | An optional configuration instance, providing formatting options used in processing. |
Returns
Type | Description |
---|---|
string | Formatted string. |
ReadAsBytes(Stream)
Convert stream to byte array
Declaration
public static byte[] ReadAsBytes(Stream inputStream)
Parameters
Type | Name | Description |
---|---|---|
Stream | inputStream | Input stream to be converted |
Returns
Type | Description |
---|---|
byte[] | Byte array |
SanitizeFilename(string)
Sanitize filename by removing the path
Declaration
public static string SanitizeFilename(string filename)
Parameters
Type | Name | Description |
---|---|---|
string | filename | Filename |
Returns
Type | Description |
---|---|
string | Filename |
SelectHeaderAccept(string[])
Select the Accept header's value from the given accepts array: if JSON exists in the given array, use it; otherwise use all of them (joining into a string)
Declaration
public static string SelectHeaderAccept(string[] accepts)
Parameters
Type | Name | Description |
---|---|---|
string[] | accepts | The accepts array to select from. |
Returns
Type | Description |
---|---|
string | The Accept header to use. |
SelectHeaderContentType(string[])
Select the Content-Type header's value from the given content-type array: if JSON type exists in the given array, use it; otherwise use the first one defined in 'consumes'
Declaration
public static string SelectHeaderContentType(string[] contentTypes)
Parameters
Type | Name | Description |
---|---|---|
string[] | contentTypes | The Content-Type array to select from. |
Returns
Type | Description |
---|---|
string | The Content-Type header to use. |
Serialize(object)
Serializes the given object when not null. Otherwise return null.
Declaration
public static string Serialize(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to serialize. |
Returns
Type | Description |
---|---|
string | Serialized string. |