3 ms·
Once you write a client, and its pretty simple, you don't have to worry about that step at all. And since the initial document rarely changes, and it can be cac
by psadauskas 17y ago
Once you write a client, and its pretty simple, you don't have to worry about that step at all. And since the initial document rarely changes, and it can be cached, you usually only have to get it once. Here's some code in ruby that uses a service like this to find a user by their login:
def find_user(login)
users.select {
|u| u["login"] == login
}.first
end
def users
users_href = services.select {
|s| s["name"] == "AllUsers"
}.first["resource_href"]
JSON.parse(
@http.resource(users_href).get(:accept => SSJ).body
)["items"]
end
def services
JSON.parse(
@http.resource(@services_uri).get(:accept => SSJ).body
)["items"]
end
@http is a handle to an HTTP library, and @services_uri is the well-known URI. So its not nearly as complicated as it might seem at first, and the benefits are tremendous.