com.minlessika.membership.integration.RestServices Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of membership-integration Show documentation
Show all versions of membership-integration Show documentation
It's a library to help developers to integration membership services to another project.
package com.minlessika.membership.integration;
import com.google.common.collect.ImmutableMap;
import com.minlessika.http.client.RestClient;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
public final class RestServices implements Services {
private final Organization organization;
private final RestClient client;
public RestServices(final RestClient client, final Organization organization) {
this.organization = organization;
this.client = client;
}
@Override
public Service get(final UUID id) {
return new JsService(
this.client.get(
"/api/organization/service",
ImmutableMap.of(
"org", this.organization.uid().toString(),
"id", id.toString()
)
).asJsonObject()
);
}
@Override
public Iterable iterate() {
final List items = new LinkedList<>();
this.client.get(
"/api/organization/services",
ImmutableMap.of(
"org", this.organization.uid().toString()
)
).asJsonArray().forEach(
json -> items.add(
new JsService(json.asJsonObject())
)
);
return items;
}
}