package br.com.parrot.github.uri;

import java.net.URI;
import java.net.URISyntaxException;

import org.apache.http.client.utils.URIBuilder;

import br.com.caelum.vraptor.ioc.Component;

@Component
public class GitHubUri {
	private static final String PROTOCOL = "https"; // https
	private static final String EVENTS_PATH = "/users/{username}/events/public";
	private static final String FOLLOWING_PATH = "/users/{username}/following";
	private static final String HOST = "api.github.com"; // api.github.com
	private static final int PORT = 403; // 403

	public URI publicEvents(String user) throws URISyntaxException {
		String path = EVENTS_PATH.replace("{username}", user);
		return uriWithPath(path);
	}
	
	public URI following(String user) throws URISyntaxException {
		String path = FOLLOWING_PATH.replace("{username}", user);
		return uriWithPath(path);
	}

	private URI uriWithPath(String path) throws URISyntaxException {
		return getUriBuilder()
				.setPath(path)
				.build();
	}

	private URIBuilder getUriBuilder() {
		URIBuilder builder = new URIBuilder();
		builder.setScheme(PROTOCOL)
			.setHost(HOST);
			//.setPort(PORT);
		return builder;
	}

	
}

@@ -261,17 +261,16 @@
  = %22http
-s
 %22; // ht
@@ -465,30 +465,25 @@
 HOST = %22
-api.github.com
+localhost
 %22; // ap
@@ -528,19 +528,20 @@
  PORT = 
-403
+8081
 ; // 403
@@ -1111,15 +1111,12 @@
 OST)
-;
 %0A%09%09%09
-//
 .set

Acerto do GitHubUri subido por engano. #fail