Show / Hide Table of Contents

    Class ApiClient

    API client is mainly responsible for making the HTTP call to the API backend.

    Inheritance
    System.Object
    ApiClient
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Algorand.Client
    Assembly: Algorand.dll
    Syntax
    public class ApiClient

    Constructors

    | Improve this Doc View Source

    ApiClient()

    Initializes a new instance of the ApiClient class with default configuration.

    Declaration
    public ApiClient()
    | Improve this Doc View Source

    ApiClient(Configuration)

    Initializes a new instance of the ApiClient class with default base path (http://localhost).

    Declaration
    public ApiClient(Configuration config)
    Parameters
    Type Name Description
    Configuration config

    An instance of Configuration.

    | Improve this Doc View Source

    ApiClient(String)

    Initializes a new instance of the ApiClient class with default configuration.

    Declaration
    public ApiClient(string basePath = "http://localhost")
    Parameters
    Type Name Description
    System.String basePath

    The base path.

    Fields

    | Improve this Doc View Source

    Default

    Gets or sets the default API client for making HTTP calls.

    Declaration
    [Obsolete("ApiClient.Default is deprecated, please use 'Configuration.Default.ApiClient' instead.")]
    public static ApiClient Default
    Field Value
    Type Description
    ApiClient

    The default API client.

    Properties

    | Improve this Doc View Source

    Configuration

    Gets or sets an instance of the IReadableConfiguration.

    Declaration
    public IReadableConfiguration Configuration { get; set; }
    Property Value
    Type Description
    IReadableConfiguration

    An instance of the IReadableConfiguration.

    Remarks

    IReadableConfiguration helps us to avoid modifying possibly global configuration values from within a given client. It does not guarantee thread-safety of the Configuration instance in any way.

    | Improve this Doc View Source

    RestClient

    Gets or sets the RestClient.

    Declaration
    public RestClient RestClient { get; set; }
    Property Value
    Type Description
    RestSharp.RestClient

    An instance of the RestClient

    Methods

    | Improve this Doc View Source

    Base64Encode(String)

    Encode string in base64 format.

    Declaration
    public static string Base64Encode(string text)
    Parameters
    Type Name Description
    System.String text

    String to be encoded.

    Returns
    Type Description
    System.String

    Encoded string.

    | Improve this Doc View Source

    CallApi(String, Method, List<KeyValuePair<String, String>>, Object, Dictionary<String, String>, Dictionary<String, String>, Dictionary<String, FileParameter>, Dictionary<String, String>, String)

    Makes the HTTP request (Sync).

    Declaration
    public object CallApi(string path, Method method, List<KeyValuePair<string, string>> queryParams, object postBody, Dictionary<string, string> headerParams, Dictionary<string, string> formParams, Dictionary<string, FileParameter> fileParams, Dictionary<string, string> pathParams, string contentType)
    Parameters
    Type Name Description
    System.String path

    URL path.

    RestSharp.Method method

    HTTP method.

    System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.String, System.String>> queryParams

    Query parameters.

    System.Object postBody

    HTTP body (POST request).

    System.Collections.Generic.Dictionary<System.String, System.String> headerParams

    Header parameters.

    System.Collections.Generic.Dictionary<System.String, System.String> formParams

    Form parameters.

    System.Collections.Generic.Dictionary<System.String, RestSharp.FileParameter> fileParams

    File parameters.

    System.Collections.Generic.Dictionary<System.String, System.String> pathParams

    Path parameters.

    System.String contentType

    Content Type of the request

    Returns
    Type Description
    System.Object

    Object

    | Improve this Doc View Source

    CallApiAsync(String, Method, List<KeyValuePair<String, String>>, Object, Dictionary<String, String>, Dictionary<String, String>, Dictionary<String, FileParameter>, Dictionary<String, String>, String)

    Makes the asynchronous HTTP request.

    Declaration
    public Task<object> CallApiAsync(string path, Method method, List<KeyValuePair<string, string>> queryParams, object postBody, Dictionary<string, string> headerParams, Dictionary<string, string> formParams, Dictionary<string, FileParameter> fileParams, Dictionary<string, string> pathParams, string contentType)
    Parameters
    Type Name Description
    System.String path

    URL path.

    RestSharp.Method method

    HTTP method.

    System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.String, System.String>> queryParams

    Query parameters.

    System.Object postBody

    HTTP body (POST request).

    System.Collections.Generic.Dictionary<System.String, System.String> headerParams

    Header parameters.

    System.Collections.Generic.Dictionary<System.String, System.String> formParams

    Form parameters.

    System.Collections.Generic.Dictionary<System.String, RestSharp.FileParameter> fileParams

    File parameters.

    System.Collections.Generic.Dictionary<System.String, System.String> pathParams

    Path parameters.

    System.String contentType

    Content type.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Object>

    The Task instance.

    | Improve this Doc View Source

    ConvertType(Object, Type)

    Dynamically cast the object into target type.

    Declaration
    public static dynamic ConvertType(dynamic fromObject, Type toObject)
    Parameters
    Type Name Description
    System.Object fromObject

    Object to be casted

    System.Type toObject

    Target type

    Returns
    Type Description
    System.Object

    Casted object

    | Improve this Doc View Source

    Deserialize(IRestResponse, Type)

    Deserialize the JSON string into a proper object.

    Declaration
    public object Deserialize(IRestResponse response, Type type)
    Parameters
    Type Name Description
    RestSharp.IRestResponse response

    The HTTP response.

    System.Type type

    Object type.

    Returns
    Type Description
    System.Object

    Object representation of the JSON string.

    | Improve this Doc View Source

    EscapeString(String)

    Escape string (url-encoded).

    Declaration
    public string EscapeString(string str)
    Parameters
    Type Name Description
    System.String str

    String to be escaped.

    Returns
    Type Description
    System.String

    Escaped string.

    | Improve this Doc View Source

    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 bool IsJsonMime(string mime)
    Parameters
    Type Name Description
    System.String mime

    MIME

    Returns
    Type Description
    System.Boolean

    Returns True if MIME type is json.

    | Improve this Doc View Source

    ParameterToFile(String, Stream)

    Create FileParameter based on Stream.

    Declaration
    public FileParameter ParameterToFile(string name, Stream stream)
    Parameters
    Type Name Description
    System.String name

    Parameter name.

    System.IO.Stream stream

    Input stream.

    Returns
    Type Description
    RestSharp.FileParameter

    FileParameter.

    | Improve this Doc View Source

    ParameterToKeyValuePairs(String, String, Object)

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

    Declaration
    public IEnumerable<KeyValuePair<string, string>> ParameterToKeyValuePairs(string collectionFormat, string name, object value)
    Parameters
    Type Name Description
    System.String collectionFormat
    System.String name

    Key name.

    System.Object value

    Value object.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.String>>

    A list of KeyValuePairs

    | Improve this Doc View Source

    ParameterToString(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 string ParameterToString(object obj)
    Parameters
    Type Name Description
    System.Object obj

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

    Returns
    Type Description
    System.String

    Formatted string.

    | Improve this Doc View Source

    ReadAsBytes(Stream)

    Convert stream to byte array

    Declaration
    public static byte[] ReadAsBytes(Stream inputStream)
    Parameters
    Type Name Description
    System.IO.Stream inputStream

    Input stream to be converted

    Returns
    Type Description
    System.Byte[]

    Byte array

    | Improve this Doc View Source

    SanitizeFilename(String)

    Sanitize filename by removing the path

    Declaration
    public static string SanitizeFilename(string filename)
    Parameters
    Type Name Description
    System.String filename

    Filename

    Returns
    Type Description
    System.String

    Filename

    | Improve this Doc View Source

    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 string SelectHeaderAccept(string[] accepts)
    Parameters
    Type Name Description
    System.String[] accepts

    The accepts array to select from.

    Returns
    Type Description
    System.String

    The Accept header to use.

    | Improve this Doc View Source

    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 string SelectHeaderContentType(string[] contentTypes)
    Parameters
    Type Name Description
    System.String[] contentTypes

    The Content-Type array to select from.

    Returns
    Type Description
    System.String

    The Content-Type header to use.

    | Improve this Doc View Source

    Serialize(Object)

    Serialize an input (model) into JSON string

    Declaration
    public string Serialize(object obj)
    Parameters
    Type Name Description
    System.Object obj

    Object.

    Returns
    Type Description
    System.String

    JSON string.

    | Improve this Doc View Source

    UrlEncode(String)

    URL encode a string Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50

    Declaration
    public static string UrlEncode(string input)
    Parameters
    Type Name Description
    System.String input

    String to be URL encoded

    Returns
    Type Description
    System.String

    Byte array

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX