plugins {
  id "org.tenne.rest" version "0.4.2"
}

task getRest(type: org._10ne.gradle.rest.RestTask) {
    httpMethod = 'get'
    uri = 'http://tool.media5corp.com:5984/gradle/test'
    //username = 'user'
    //password = 'password'
    contentType = groovyx.net.http.ContentType.JSON
        responseHandler = {
                println it
        }
}

task postRest(type: org._10ne.gradle.rest.RestTask) {
    httpMethod = 'post'
    uri = 'http://tool.media5corp.com:5984/gradle/'
    //username = 'player'
    //password = 'password'
    requestBody = [battleCry: 'FOR LEEROY JENKINS!']
    contentType = groovyx.net.http.ContentType.JSON
    requestHeaders = [customHeader: 'WoW']
    responseHandler = {
        //Configured content type is JSON and we let the client's handler parse the response for us
        //assert it.message == 'success'
        println it
    }
}

task main
main.dependsOn(getRest)
main.dependsOn(postRest)

