Skip to content

Usage Example

Aditya Gupta edited this page Mar 29, 2025 · 1 revision

Quickstart Setup

Installation

Add dependency in the build.gradle.

  • Kts

      dependencies {
          implementation("com.github.openMF:fineract-client-kmp-sdk:$sdk_Version")
      }
  • Groovy

      dependencies {
          implementation 'com.github.openMF:fineract-client-kmp-sdk:$sdk_Version'
      }

Add this in your root settings.gradle.

  • Kts

      dependencyResolutionManagement {
          repositories {
              maven {
                  setUrl("https://jitpack.io")
              }
          }
      }
  • Groovy

      allprojects {
          repositories {
              maven { url 'https://jitpack.io' }
          }
      }

Initialization

  • Initialize the BaseApiManager and create a service to initialize the KtorFit client.

        val baseUrl = PROTOCOL_HTTPS + API_ENDPOINT + API_PATH
        val tenant = "default"
        val username = "mifos"
        val password = "password"
        val baseApiManager = BaseApiManager.getInstance()
        baseApiManager.createService(username, password, baseUrl, tenant, false)

Authentication

  • Example code to use the Authentication API:

        val req = PostAuthenticationRequest(username = username, password = password)
    
        lifecycleScope.launch(Dispatchers.IO) {
            val response = baseApiManager.getAuthApi().authenticate(req, true)
            Log.d("Auth Response",response.toString())    
        }

Usage Example

  • To get Client Details with clientId 1:

        private fun getClient() {
            lifecycleScope.launch(Dispatchers.IO) {
                val response = baseApiManager.getClientsApi().retrieveOne11(1, false)
                Log.d("Client Details Response",response.toString())
            }
        }