<commit_before>package org.trello4j;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.zip.GZIPInputStream;

import javax.net.ssl.HttpsURLConnection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.trello4j.model.Action;
import org.trello4j.model.Board;
import org.trello4j.model.Card;
import org.trello4j.model.Member;
import org.trello4j.model.Organization;

import com.google.gson.reflect.TypeToken;

public class TrelloImpl implements Trello {
	
	private static final Logger logger = LoggerFactory.getLogger(TrelloImpl.class);
	private static final String GZIP_ENCODING = "gzip";
	private static final String PATH_PARAM_ARG_PREFIX = "\\{";
	private static final String PATH_PARAM_ARG_SUFFIX = "\\}";
	
	private String apiKey = null;
	private String secret = null;
	
	private String authQueryString = null;
	
	private TrelloObjectFactoryImpl trelloObjFactory = new TrelloObjectFactoryImpl();
	
	public TrelloImpl(String apiKey) {
		this(apiKey, null);
	}

	public TrelloImpl(String apiKey, String secret) {
		this.apiKey = apiKey;
		this.secret = secret;
		
		if(this.apiKey == null) {
			throw new TrelloException("API key must be set, get one here: https://trello.com/1/appKey/generate");
		} 
		
		this.authQueryString = createAuthQueryString();
	}

	@Override
	public Board getBoard(final String boardId) {
		validateObjectId(boardId);
		final String url = buildUrl(TrelloURL.BOARD_URL, boardId);
		return trelloObjFactory.createObject(new TypeToken<Board>(){}, doApiGet(url));
	}
	
	@Override
	public List<Action> getActionsByBoard(String boardId) {
		validateObjectId(boardId);
		final String url = buildUrl(TrelloURL.BOARD_ACTIONS_URL, boardId);
		return trelloObjFactory.createObject(new TypeToken<List<Action>>(){}, doApiGet(url));
	}
	
	@Override
	public Action getAction(String actionId) {
		validateObjectId(actionId);
		final String url = buildUrl(TrelloURL.ACTION_URL, actionId);
		return trelloObjFactory.createObject(new TypeToken<Action>(){}, doApiGet(url));
	}

	@Override
	public Organization getOrganization(String organizationName) {
		final String url = buildUrl(TrelloURL.ORGANIZATION_URL, organizationName);
		return trelloObjFactory.createObject(new TypeToken<Organization>(){}, doApiGet(url));
	}
	
	@Override
	public Member getMember(String username) {
		final String url = buildUrl(TrelloURL.MEMBER_URL, username);
		return trelloObjFactory.createObject(new TypeToken<Member>(){}, doApiGet(url));
	}

	@Override
	public List<Board> getBoardsByOrganization(String organizationName) {
		final String url = buildUrl(TrelloURL.ORGANIZATION_BOARDS_URL, organizationName);
		return trelloObjFactory.createObject(new TypeToken<List<Board>>(){}, doApiGet(url));
	}
	
	@Override
	public Card getCard(String cardId) {
		final String url = buildUrl(TrelloURL.CARD_URL, cardId);
		return trelloObjFactory.createObject(new TypeToken<Card>(){}, doApiGet(url));
	}
	
	@Override
	public org.trello4j.model.List getList(String listId) {
		final String url = buildUrl(TrelloURL.LIST_URL, listId);
		return trelloObjFactory.createObject(new TypeToken<org.trello4j.model.List>(){}, doApiGet(url));
	}
	
	private InputStream doApiGet(String url) {
		try {
			HttpsURLConnection conn = (HttpsURLConnection) new URL(url).openConnection();
			conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
			
			logger.debug("Requesting resource {}...", url);
			
			conn.connect();
			
			logger.debug("api.trello.com answered {} {}", conn.getResponseCode(), conn.getResponseMessage());
			
			// Return null if we get an error response
			if(conn.getResponseCode() > 399) {
				return null;
			} else {
				return getWrappedInputStream(conn.getInputStream(), GZIP_ENCODING.equalsIgnoreCase(conn.getContentEncoding()));
			}
		} catch (IOException e) {
			throw new TrelloException(e.getMessage());
		}
	}
	<commit_msg>added validation to remaining methods<commit_after>package org.trello4j;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.zip.GZIPInputStream;

import javax.net.ssl.HttpsURLConnection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.trello4j.model.Action;
import org.trello4j.model.Board;
import org.trello4j.model.Card;
import org.trello4j.model.Member;
import org.trello4j.model.Organization;

import com.google.gson.reflect.TypeToken;

public class TrelloImpl implements Trello {
	
	private static final Logger logger = LoggerFactory.getLogger(TrelloImpl.class);
	private static final String GZIP_ENCODING = "gzip";
	private static final String PATH_PARAM_ARG_PREFIX = "\\{";
	private static final String PATH_PARAM_ARG_SUFFIX = "\\}";
	
	private String apiKey = null;
	private String secret = null;
	
	private String authQueryString = null;
	
	private TrelloObjectFactoryImpl trelloObjFactory = new TrelloObjectFactoryImpl();
	
	public TrelloImpl(String apiKey) {
		this(apiKey, null);
	}

	public TrelloImpl(String apiKey, String secret) {
		this.apiKey = apiKey;
		this.secret = secret;
		
		if(this.apiKey == null) {
			throw new TrelloException("API key must be set, get one here: https://trello.com/1/appKey/generate");
		} 
		
		this.authQueryString = createAuthQueryString();
	}

	@Override
	public Board getBoard(final String boardId) {
		validateObjectId(boardId);
		final String url = buildUrl(TrelloURL.BOARD_URL, boardId);
		return trelloObjFactory.createObject(new TypeToken<Board>(){}, doApiGet(url));
	}
	
	@Override
	public List<Action> getActionsByBoard(final String boardId) {
		validateObjectId(boardId);
		final String url = buildUrl(TrelloURL.BOARD_ACTIONS_URL, boardId);
		return trelloObjFactory.createObject(new TypeToken<List<Action>>(){}, doApiGet(url));
	}
	
	@Override
	public Action getAction(final String actionId) {
		validateObjectId(actionId);
		final String url = buildUrl(TrelloURL.ACTION_URL, actionId);
		return trelloObjFactory.createObject(new TypeToken<Action>(){}, doApiGet(url));
	}

	@Override
	public Organization getOrganization(String organizationName) {
		final String url = buildUrl(TrelloURL.ORGANIZATION_URL, organizationName);
		return trelloObjFactory.createObject(new TypeToken<Organization>(){}, doApiGet(url));
	}
	
	@Override
	public Member getMember(String username) {
		final String url = buildUrl(TrelloURL.MEMBER_URL, username);
		return trelloObjFactory.createObject(new TypeToken<Member>(){}, doApiGet(url));
	}

	@Override
	public List<Board> getBoardsByOrganization(String organizationName) {
		final String url = buildUrl(TrelloURL.ORGANIZATION_BOARDS_URL, organizationName);
		return trelloObjFactory.createObject(new TypeToken<List<Board>>(){}, doApiGet(url));
	}
	
	@Override
	public Card getCard(final String cardId) {
		validateObjectId(cardId);
		final String url = buildUrl(TrelloURL.CARD_URL, cardId);
		return trelloObjFactory.createObject(new TypeToken<Card>(){}, doApiGet(url));
	}
	
	@Override
	public org.trello4j.model.List getList(final String listId) {
		validateObjectId(listId);
		final String url = buildUrl(TrelloURL.LIST_URL, listId);
		return trelloObjFactory.createObject(new TypeToken<org.trello4j.model.List>(){}, doApiGet(url));
	}
	
	private InputStream doApiGet(String url) {
		try {
			HttpsURLConnection conn = (HttpsURLConnection) new URL(url).openConnection();
			conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
			
			logger.debug("Requesting resource {}...", url);
			
			conn.connect();
			
			logger.debug("api.trello.com answered {} {}", conn.getResponseCode(), conn.getResponseMessage());
			
			// Return null if we get an error response
			if(conn.getResponseCode() > 399) {
				return null;
			} else {
				return getWrappedInputStream(conn.getInputStream(), GZIP_ENCODING.equalsIgnoreCase(conn.getContentEncoding()));
			}
		} catch (IOException e) {
			throw new TrelloException(e.getMessage());
		}
	}
	
{'fraction_non_alphanumeric': 0.11366475143642268, 'fraction_numerical': 0.0034973769672745443, 'mean_word_length': 5.4520547945205475, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '401888', 'n_tokens_mistral': 2813, 'n_tokens_neox': 2533, 'n_words': 538}