All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.minlessika.membership.integration.RestServices Maven / Gradle / Ivy

Go to download

It's a library to help developers to integration membership services to another project.

There is a newer version: 0.3.1
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy