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

com.codacy.client.bitbucket.v2.service.IssueServices.scala Maven / Gradle / Ivy

There is a newer version: 19.0.7
Show newest version
package com.codacy.client.bitbucket.v2.service

import java.net.URLEncoder
import com.codacy.client.bitbucket.client.DefaultBodyWritables._
import com.codacy.client.bitbucket.client.{BitbucketClient, RequestResponse}
import com.codacy.client.bitbucket.v2.Issue
import play.api.libs.json._

class IssueServices(client: BitbucketClient) {

  def createIssue(author: String, repo: String, title: String, body: String): RequestResponse[Issue] = {
    val encodedAuthor = URLEncoder.encode(author, "UTF-8")
    val encodedRepo = URLEncoder.encode(repo, "UTF-8")
    val url = s"${client.repositoriesBaseUrl}/$encodedAuthor/$encodedRepo/issues"

    val values = Json.obj("title" -> JsString(title), "content" -> Json.obj("raw" -> JsString(body)))

    client.postForm[JsObject, Issue](url, values)
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy