<commit_before>package at.junction.api.rest

import java.util.Date
import at.junction.api.fields.PlayerIdentifier
import java.util
import scala.collection.JavaConversions._
import at.junction.api.BanStatus


/**
 * User: HansiHE
 * Date: 3/2/14
 * Time: 3:14 AM
 */
class BansApi(api: RestApi) extends ApiModule(api) {

  case class Ban(id: Integer, issuer: PlayerIdentifier, target: PlayerIdentifier, reason: String,
              server: String, time: Date = null, active: Boolean, remove_time: Date = null, remove_user: String,
              source: String)

  case class Note(id: Integer, issuer: PlayerIdentifier, target: PlayerIdentifier, server: String,
              time: Date = null, active: Boolean, note: String)


  def getBans(target: PlayerIdentifier, active: BanStatus = BanStatus.Active): util.List[Ban] = {
    val request = GET("/anathema/bans")
    .param("uuid", target.mojangUUID)
    .param("scope", "local")
    .param("active", active match {
      case BanStatus.Both => "none"
      case BanStatus.Active => "true"
      case BanStatus.Inactive => "false"
    })

    val json = parseApiResponse(request.asString)

    (json \ "bans").extract[List[Ban]]
  }

  def getNotes(target: PlayerIdentifier, active: BanStatus): util.List[Note] = {
    val request = GET("/anathema/notes")
      .param("uuid", target.mojangUUID)
      .param("scope", "local")
      .param("active", active match {
      case BanStatus.Both => "none"
      case BanStatus.Active => "true"
      case BanStatus.Inactive => "false"
    })

    val json = parseApiResponse(request.asString)

    (json \ "notes").extract[List[Note]]
  }

  def addNote(target: PlayerIdentifier, issuer: PlayerIdentifier, message: String) = {
    val request = POST("/anathema/notes", asPlayer = issuer)
      .param("server", api.getServer)
      .param("uuid", target.mojangUUID)
      .param("note", message)

    val json = parseApiResponse(request.asString)
  }

  def addBan(target: PlayerIdentifier, issuer: PlayerIdentifier, reason: String) = {
    val request = POST("/anathema/bans", asPlayer = issuer)
      .param("server", api.getServer)
      .param("uuid", target.mojangUUID)
      .param("reason", reason)

    val json = parseApiResponse(request.asString)
  }

  def delNote(id: Integer, issuer: PlayerIdentifier) = {
    val request = DELETE("/anathema/notes", asPlayer = issuer)
      .param("id", id.toString)

    val json = parseApiResponse(request.asString)
  }

  def delBan(target: PlayerIdentifier, issuer: PlayerIdentifier) = {
    val request = DELETE("/anathema/bans", asPlayer = issuer)
      .param("uuid", target.mojangUUID)

    val json = parseApiResponse(request.asString)
  }

}
<commit_msg>add some debug code<commit_after>package at.junction.api.rest

import java.util.Date
import at.junction.api.fields.PlayerIdentifier
import java.util
import scala.collection.JavaConversions._
import at.junction.api.BanStatus


/**
 * User: HansiHE
 * Date: 3/2/14
 * Time: 3:14 AM
 */
class BansApi(api: RestApi) extends ApiModule(api) {

  case class Ban(id: Integer, issuer: PlayerIdentifier, target: PlayerIdentifier, reason: String,
              server: String, time: Date = null, active: Boolean, remove_time: Date = null, remove_user: String,
              source: String)

  case class Note(id: Integer, issuer: PlayerIdentifier, target: PlayerIdentifier, server: String,
              time: Date = null, active: Boolean, note: String)


  def getBans(target: PlayerIdentifier, active: BanStatus = BanStatus.Active): util.List[Ban] = {
    val request = GET("/anathema/bans")
    .param("uuid", target.mojangUUID)
    .param("scope", "local")
    .param("active", active match {
      case BanStatus.Both => "none"
      case BanStatus.Active => "true"
      case BanStatus.Inactive => "false"
    })

    val res = request.asString
    println("RES: " + res)
    val json = parseApiResponse(res)

    (json \ "bans").extract[List[Ban]]
  }

  def getNotes(target: PlayerIdentifier, active: BanStatus): util.List[Note] = {
    val request = GET("/anathema/notes")
      .param("uuid", target.mojangUUID)
      .param("scope", "local")
      .param("active", active match {
      case BanStatus.Both => "none"
      case BanStatus.Active => "true"
      case BanStatus.Inactive => "false"
    })

    val res = request.asString
    println("RES: " + res)
    val json = parseApiResponse(res)

    (json \ "notes").extract[List[Note]]
  }

  def addNote(target: PlayerIdentifier, issuer: PlayerIdentifier, message: String) = {
    val request = POST("/anathema/notes", asPlayer = issuer)
      .param("server", api.getServer)
      .param("uuid", target.mojangUUID)
      .param("note", message)

    val json = parseApiResponse(request.asString)
  }

  def addBan(target: PlayerIdentifier, issuer: PlayerIdentifier, reason: String) = {
    val request = POST("/anathema/bans", asPlayer = issuer)
      .param("server", api.getServer)
      .param("uuid", target.mojangUUID)
      .param("reason", reason)

    val json = parseApiResponse(request.asString)
  }

  def delNote(id: Integer, issuer: PlayerIdentifier) = {
    val request = DELETE("/anathema/notes", asPlayer = issuer)
      .param("id", id.toString)

    val json = parseApiResponse(request.asString)
  }

  def delBan(target: PlayerIdentifier, issuer: PlayerIdentifier) = {
    val request = DELETE("/anathema/bans", asPlayer = issuer)
      .param("uuid", target.mojangUUID)

    val json = parseApiResponse(request.asString)
  }

}

{'fraction_non_alphanumeric': 0.13497822931785197, 'fraction_numerical': 0.0025399129172714078, 'mean_word_length': 3.4531502423263327, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '669583', 'n_tokens_mistral': 1774, 'n_tokens_neox': 1701, 'n_words': 409}