cat_2.9.3.0.1.1.source-code.statuses.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hubcat_2.9.3 Show documentation
Show all versions of hubcat_2.9.3 Show documentation
a vvip client of the github enterprises
The newest version!
package hubcat
import dispatch._
import org.json4s.JsonDSL._
import org.json4s.native.Printer.compact
import org.json4s.native.JsonMethods.render
object Status {
sealed trait State {
def value: String
}
object Pending extends State {
val value = "pending"
}
object Success extends State {
val value = "success"
}
object Error extends State {
val value = "error"
}
object Failure extends State {
val value = "failure"
}
}
trait RepoStatuses { self: RepoRequests =>
case class Statuses(ref: String)
extends Client.Completion {
private [this] def base = apiHost / "repos" / user / repo / "statuses" / ref
case class StatusBuilder(
state: Status.State,
_targetUrl: Option[String] = None,
_desc: Option[String] = None)
extends Client.Completion {
def targetUrl(target: String) = copy(_targetUrl = Some(target))
def desc(d: String) = copy(_desc = Some(d))
override def apply[T](handler: Client.Handler[T]) =
request(base.POST << pmap)(handler)
private def pmap =
compact(render(("state" -> state.value) ~
("target_url" -> _targetUrl) ~
("description" -> _desc)))
}
/** http://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref */
override def apply[T](handler: Client.Handler[T]) =
request(base)(handler)
/** http://developer.github.com/v3/repos/statuses/#create-a-status */
def create(state: Status.State) =
StatusBuilder(state)
}
/** http://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref */
def statuses(ref: String) = Statuses(ref)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy