本文整理汇总了Scala中com.google.common.collect.Maps类的典型用法代码示例。如果您正苦于以下问题:Scala Maps类的具体用法?Scala Maps怎么用?Scala Maps使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Maps类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: process
//设置package包名称以及导入依赖的类
package com.clemble.loveit.payment.service
import com.clemble.loveit.payment.model._
import com.clemble.loveit.payment.model.PayoutStatus.PayoutStatus
import com.google.common.collect.{ImmutableMap, Maps}
import play.api.libs.json._
import scala.concurrent.Future
import scala.util.{Failure, Success, Try}
sealed trait EOMPayoutService {
def process(payout: EOMPayout): Future[(PayoutStatus, JsValue)]
}
import com.stripe.model.Transfer
case object StripeEOMPayoutService extends EOMPayoutService {
private def transferStripe(chAcc: StripePayoutAccount, amount: Money): Transfer = {
val transferParams = Maps.newHashMap[String, Object]()
val stripeAmount = (amount.amount * 100).toInt
transferParams.put("amount", stripeAmount.toString)
transferParams.put("currency", "usd")
transferParams.put("destination", chAcc.accountId)
Transfer.create(transferParams)
}
private def doProcess(payout: EOMPayout): (PayoutStatus, JsValue) = {
Try({
transferStripe(payout.destination.asInstanceOf[StripePayoutAccount], payout.amount)
}) match {
case Success(transfer) =>
val details = Json.parse(transfer.toJson())
(PayoutStatus.Success, details)
case Failure(t) =>
(PayoutStatus.Failed, Json.obj("error" -> t.getMessage))
}
}
override def process(payout: EOMPayout): Future[(PayoutStatus, JsValue)] = {
if (payout.destination.isEmpty) {
Future.successful(PayoutStatus.NoBankAccount -> Json.obj())
} else {
Future.successful(doProcess(payout))
}
}
}