package wtf.password;

import retrofit.RestAdapter;
import retrofit.http.Field;
import retrofit.http.FormUrlEncoded;
import retrofit.http.POST;

/**
 * @author <a href="mailto:erik.beeson@gmail.com">Erik Beeson</a>
 */
public class ZxcvbnRemote {
	private final ZxcvbnRemoteService service;

	public ZxcvbnRemote() {
		this("https://password.wtf");
	}

	public ZxcvbnRemote(String endpoint) {
		this.service = new RestAdapter.Builder()
							   .setEndpoint(endpoint)
							   .build()
							   .create(ZxcvbnRemoteService.class);
	}

	public PasswordStrength zxcvbn(String password) throws IllegalArgumentException {
		if(password != null && password.length() > 0) {
			return service.zxcvbn(password);
		} else {
			throw new IllegalArgumentException("Invalid password: " + password);
		}
	}

	interface ZxcvbnRemoteService {
		@POST("/zxcvbn")
		@FormUrlEncoded
		PasswordStrength zxcvbn(@Field("password") String password);
	}
}

@@ -289,69 +289,8 @@
 e;%0A%0A
-%09public ZxcvbnRemote() %7B%0A%09%09this(%22https://password.wtf%22);%0A%09%7D%0A%0A
 %09pub

Remove default constructor to ensure that consumers understand this is a remote service