EP / me2day-scala

me2day API for scala

Clone this repository (size: 251.3 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/EP/me2day-scala/
commit 18: 3c558a989105
parent 17: 7aa74a91f284
branch: default
Add get_settings.
Eung-ju PARK
12 months ago

Changed (Δ756 bytes):

Up to file-list src/main/scala/net/me2day/scala/GetSettings.scala:

1
package net.me2day.scala
2
3
class GetSettings(me2day : Me2Day, userId : String) {
4
    def execute() : Settings = {
5
        val invocation = me2day.prepareInvocation("get_settings/" + userId, "GET")
6
        invocation.resultParser.settings(invocation.execute())
7
    }
8
}

Up to file-list src/main/scala/net/me2day/scala/Me2Day.scala:

@@ -73,6 +73,10 @@ class Me2Day(val user : User, val applic
73
73
        new GetFriends(this, userId)
74
74
    }
75
75
76
    def getSettings(userId : String) = {
77
        new GetSettings(this, userId)
78
    }
79
76
80
    def url(name : String) : String = baseUrl + "/" + name + ".xml"
77
81
    
78
82
    def basicAuthorization() : String = {

Up to file-list src/main/scala/net/me2day/scala/Settings.scala:

1
package net.me2day.scala
2
3
case class Settings(val mytags : List[String], val groups : List[String])

Up to file-list src/main/scala/net/me2day/scala/XmlResultParser.scala:

@@ -185,6 +185,18 @@ class XmlResultParser {
185
185
        (node \ "person").toList.map((x : xml.Node) => person(x))
186
186
    }
187
187
188
    def settings(node : xml.Node) = {
189
        Settings(mytags(node \ "mytags"), groups(node \ "groups"))
190
    }
191
192
    def mytags(node : xml.NodeSeq) = {
193
        node.text.split("\\s").toList
194
    }
195
196
    def groups(node : xml.NodeSeq) = {
197
        node.text.split("\\s").toList
198
    }
199
188
200
    private def url(node : xml.NodeSeq) : URL = if (node.isEmpty || node.text.isEmpty) null else new URL(node.text)
189
201
    
190
202
    private def date(node : xml.Node) : Date = {