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

edu.ksu.canvas.impl.RoleImpl Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package edu.ksu.canvas.impl;

import com.google.gson.reflect.TypeToken;

import edu.ksu.canvas.interfaces.*;
import edu.ksu.canvas.model.Role;
import edu.ksu.canvas.net.RestClient;
import edu.ksu.canvas.oauth.OauthToken;
import edu.ksu.canvas.requestOptions.ListRolesOptions;

import org.apache.log4j.Logger;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;

public class RoleImpl extends BaseImpl implements RoleReader, RoleWriter {
    private static final Logger LOG = Logger.getLogger(RoleImpl.class);

    public RoleImpl(String canvasBaseUrl, Integer apiVersion, OauthToken oauthToken, RestClient restClient,
                    int connectTimeout, int readTimeout, Integer paginationPageSize, Boolean serializeNulls) {
        super(canvasBaseUrl, apiVersion, oauthToken, restClient, connectTimeout, readTimeout,
                paginationPageSize, serializeNulls);
    }

    @Override
    public List listRoles(ListRolesOptions options) throws IOException {
        LOG.debug("Retrieving roles for account " + options.getAccountId());
        String url = buildCanvasUrl("accounts/" + options.getAccountId() + "/roles", options.getOptionsMap());
        return getListFromCanvas(url);
    }

    @Override
    protected Type listType() {
        return new TypeToken>(){}.getType();
    }

    @Override
    protected Class objectType() {
        return Role.class;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy