Created
March 20, 2011 18:55
-
-
Save ikikko/878552 to your computer and use it in GitHub Desktop.
Backlog APIのGroovyクライアントサンプルです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='org.codehaus.groovy', module='groovy-xmlrpc', version='0.7') | |
@Grab(group='jivesoftware', module='smack', version='3.1.0') | |
import groovy.net.xmlrpc.XMLRPCServerProxy | |
// 設定内容 | |
def SPACE = 'demo' | |
def USER_ID = 'demo' | |
def PASSWORD = 'demo' | |
// Backlog API用Proxy | |
class BacklogProxy extends XMLRPCServerProxy { | |
BacklogProxy(url) { | |
super(url.toString()) | |
} | |
@Override | |
Object invokeMethod(String name, Object args) { | |
if (name == 'setBasicAuth') { | |
super.invokeMethod(name, args) | |
} else { | |
super.invokeMethod("backlog.${name}", args) | |
} | |
} | |
} | |
// クライアントコード | |
def proxy = new BacklogProxy("https://${SPACE}.backlog.jp/XML-RPC") | |
proxy.setBasicAuth(USER_ID, PASSWORD) | |
proxy.getProjects().sort{ it.id }.each{ println it } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment