All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gu.zuora.soap.actions.Action.scala Maven / Gradle / Ivy

There is a newer version: 0.605
Show newest version
package com.gu.zuora.soap.actions

import com.gu.zuora.soap.models.Results.Authentication
import com.gu.zuora.soap.models.Result

import scala.xml.{Elem, NodeSeq}

trait Action[T <: Result] { self =>

  protected val body: Elem

  val authRequired = true
  val singleTransaction = false
  val enableLogging: Boolean = true

  def logInfo: Map[String, String] = Map("Action" -> self.getClass.getSimpleName)
  def additionalLogInfo: Map[String, String] = Map.empty

  def prettyLogInfo = (logInfo ++ additionalLogInfo).map { case (k, v) => s"  - $k: $v" } .mkString("\n")

  def xml(authentication: Option[Authentication]) = {
    
      
        {sessionHeader(authentication)}
        {
        if (singleTransaction) {
          
            true
          
        }
        }
      
      {body}
    
  }

  def sanitized = body.toString()

  private def sessionHeader(authOpt: Option[Authentication]):NodeSeq =
    authOpt.fold(NodeSeq.Empty) { auth =>
      
        {auth.token}
      
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy