in src/main/scala/ZuoraService.scala [260:278]
def clearDefaultPaymentMethod(accountId: String): String \/ Unit = {
logInfo(accountId, s"attempting to clear default payment method")
val json = Json.obj(
"objects" -> Json.arr(
Json.obj(
"fieldsToNull" -> Json.arr("DefaultPaymentMethodId"),
"Id" -> accountId
)
),
"type" -> "Account"
)
val body = RequestBody.create(MediaType.parse("application/json"), json.toString)
val request = buildRequest(config, s"action/update").put(body).build()
val call = restClient.newCall(request)
val response = call.execute
convertResponseToCaseClass[List[UpdateResult]](accountId, response).map(_.head) match {
case \/-(result) => if (result.success) { \/-(()) } else { -\/("Zuora result indicated a failure when attempting to clear the default payment method") }
case -\/(error) => -\/(error)
}