docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ApiUtils

    Utility functions providing some benefit to API client consumers.

    Inheritance
    object
    ApiUtils
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Unity.Services.Apis.Shared
    Assembly: solution.dll
    Syntax
    public class ApiUtils

    Fields

    JsonRegex

    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

    Base64Encode(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(IApiConfiguration, string, string, object)

    Convert params to key/value pairs. Use collectionFormat to properly format lists and collections.

    Declaration
    public static Multimap<string, string> ParameterToMultiMap(IApiConfiguration configuration, string collectionFormat, string name, object value)
    Parameters
    Type Name Description
    IApiConfiguration configuration

    The api configuration.

    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(IApiConfiguration, object)

    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(IApiConfiguration configuration, object obj)
    Parameters
    Type Name Description
    IApiConfiguration configuration

    The api configuration.

    object obj

    The parameter (header, path, query, form).

    Returns
    Type Description
    string

    Formatted string.

    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.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)