# Java Vyou server sdk

This SDK is suitable to make server to server calls from client's backend to Vyou backend.

Here is an example:


fun getCustomer() {
  val clientId = "eworitum2345ufw34589vwune4to8iwuertviwehrt"
  val clientSecret = "dsfuafj9evt9w34j5vq0439vj5qoeiruveonitvuqwnoiuvq34095vuq34095v8"
  val backendUrl = "https://vyou.vyou-dev.com:6120"

  Sdk.init(clientId, clientSecret, backendUrl)

  val accessToken = "eysoifqmwoeirumqw4095vq8340v598mq34059w59tomirtwiertu(...)"
  val result = CustomerService.get(accessToken)
}

# Getting started

  • Add implementation("com.vyou:server-java:0.0.16") in build.gradle.ks file
  • Initialize Sdk with Sdk.initmethod, providing clientId, clientSecretand backendUrl (this is the Vyou backend url).

# Customer

  • Customer.get(accessToken) : retrieve customer information associated to accessToken

  • Customer.create(newCustomer): creates a new customer.

    • newCustomer is of type NewCustomer whose properties are:
    data class NewCustomer(
      val email: String,
      val privacyAccepted: Boolean,
      val termsAndConditionsAccepted: Boolean,
      val infoAccepted: Boolean
    )
    
  • Customer.update(accessToken, fieldsToUpdate): update a customer.

    • fieldsToUpdate is of type Fields. Here is an example of how to build this structure:
    Fields.Builder.put("name", "Juan").put("age", 33).build()
    

    # Token Verifiers

    These verifiers can check if vyou accessToken or idToken are valid.

    • IdTokenVerifier.verify(idToken): id token verification method.
      • If idToken is ok, it returns IdTokenData:
      data class IdTokenData(
        val userId: String,
        val email: String
      )
      
    • GatewayIdTokenVerifier.verify(idToken): X-Vyou-Token verification method.
      • If X-Vyou-Token is ok, it returns GatewayIdTokenData:
      data class GatewayIdTokenData(
        val userId: String,
        val email: String,
        val accessToken: String
      )
      
    • AccessTokenVerifier.verify(accessToken): access token verification method.
      • If accessToken is ok, it returns AccessTokenData:
      data class AccessTokenData(
        val userId: String,
        val email: String,
        val roles: List<String>
      )
      

    # Payments

    • PaymentService.requestStripePayment(amount, metaData, accessToken): creates a payment intent, it returns StripePaymentSecret:
      data class StripePaymentSecret(val secret: String)