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

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

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

import static java.util.Collections.emptyMap;

import com.google.gson.reflect.TypeToken;

import edu.ksu.canvas.interfaces.*;
import edu.ksu.canvas.model.Login;
import edu.ksu.canvas.net.RestClient;
import edu.ksu.canvas.oauth.OauthToken;

import org.apache.log4j.Logger;

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

public class LoginImpl extends BaseImpl implements LoginReader {
    private static final Logger LOG = Logger.getLogger(LoginImpl.class);

    public LoginImpl(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 getLoginForUser(String userId) throws IOException {
        LOG.debug("Retrieving logins for user id " + userId);
        String url = buildCanvasUrl("users/" + userId + "/logins", emptyMap());

        return getListFromCanvas(url);
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy