Skip to content

Getting started with Aiuta

To start using Aiuta SDK, you need to create an instance of the Aiuta class. This class serves as the main entry point to the SDK and requires configuration of essential components.

Here's how to set up the Aiuta class:

import com.aiuta.fashionsdk.Aiuta
import com.aiuta.fashionsdk.aiuta

val aiuta: Aiuta = aiuta {
    // Configure authentication strategy
    authenticationStrategy = ... // (1)!

    // Configure platform context
    platformContext = ... // (2)!

    // Configure logger (optional)
    logger = ... // (3)!
}
  1. Required: Defines how the SDK authenticates with the Aiuta backend.
    See Authentication section for details.
  2. Required: Provides platform-specific information and context.
    See Platform context section for details.
  3. Optional: Customizes logging behavior of the SDK. See Logger section for details.

Authentication

The authentication strategy is a required component that defines how the SDK authenticates with the Aiuta backend.

To configure authentication, you need to provide an implementation of the authentication strategy. The SDK provides several built-in strategies:

authenticationStrategy = ApiKeyAuthenticationStrategy(
    apiKey = "your-api-key",
)
authenticationStrategy = JWTAuthenticationStrategy(
    getJWT = { /* Provide new JWT token */ },
    subscriptionId = "your-subscription-id"
)

General configuration

You can find a more detailed description of API keys and JWT authentication in the SDK, as well as instructions on how to obtain them, in the general configuration guide for developers

Platform Context

The platform context is a required component that provides platform-specific information and context to the SDK. For Android, you need to provide the Android Context, while for other platforms, a general singleton default context is used.

import android.content.Context

platformContext = applicationContext
platformContext = AiutaPlatformContext.INSTANCE
Compose helpers

For better usage Aiuta with Jetpack Compose SDK contains LocalAiutaPlatformContext composition local. For Android, it will be alias for LocalContext, for all others platform - static composition local with platform context.

Pay attention, LocalAiutaPlatformContext is part of fashionsdk-compose-core artifact

Logger

The logger is an optional component that allows you to customize the logging behavior of the SDK. By default, the SDK will not use any loggers, but you can provide your own implementation to integrate with your application's logging system.

Usage of default logger

Be careful with using default logger with production build - under the hood it's use simple log to console, therefore some sensetive inforamtion can be leak to console. Don't forget to turn it off on production build!

logger = DefaultAiutaLogger() 
class CustomAiutaLogger : AiutaLogger {
    override fun log(
        priority: AiutaLogger.Level,
        tag: String?,
        throwable: Throwable?,
        message: String,
    ) {
        // Log message
    }
}

logger = CustomAiutaLogger()

The logger supports different log levels and can handle both messages and throwables. You can use it to:

  • Control the verbosity of SDK logs
  • Integrate SDK logs with your application's logging system
  • Filter or transform log messages
  • Add additional context to log messages