Skip to content
dimanitm edited this page Oct 22, 2018 · 1 revision

All interaction with TokenD-based system relies on ...Api instances. API class serves as "umbrella" and instantiates others Apis in a lazy manner.

"Umbrella" class can be initialized like this:

let tokenDApi = TokenDSDK.API(
    configuration: apiConfiguration,
    callbacks: callbacks,
    keyDataProvider: keyDataProvider
)

Each parameter is described in details below.

ApiConfiguration

API configuration can be initialized like this:

let userAgent: String = ...

let apiConfiguration = ApiConfiguration(
    urlString: "https://api.testnet.tokend.org",
    userAgent: ...
)

It consists of API URL string and user agent. User agent is a client identifier string that usually consists of app name, system version, device name, etc.

ApiCallbacks

Callbacks can be initialized like this:

let callbacks = ApiCallbacks(onTFARequired: { (tfaInput, cancel) in 
    // handle TFA...
})

ApiCallbacks used to notify when there is a special event occurs. Currently, it serves to notify when 2Factor authentication required.

2Factor authentication

In theory, any API request may require 2Factor authentication of the user if it is set. For example, sign in may require a code from Google Authenticator.

Key data provider

The key data provider is required to give access to the private key and perform request signing. API requests that interact with sensitive data require signing by user's Account i.e. the keypair. The key data provider should conform to RequestSignKeyDataProviderProtocol.

You can get more info about requests signing in our Knowledge base or in API documentation

Clone this wiki locally