added convenience methods for the builder api

This commit is contained in:
Pablo Fernandez committed 2011-04-19 22:32:32 -03:00
1 parent 193dcd2e25
commit 8abdde928a
4 files changed
+35 -3

No files matched your search

@@ -20,6 +20,7 @@ public class ServiceBuilder
private String callback;
private Api api;
private String scope;
private SignatureType signatureType;
/**
* Default constructor
@@ -122,6 +123,19 @@ public class ServiceBuilder
this.scope = scope;
return this;
}
/**
* Configures the signature type, choose between header, querystring, etc. Defaults to Header
*
* @param scope The OAuth scope
* @return the {@link ServiceBuilder} instance for method chaining
*/
public ServiceBuilder signatureType(SignatureType type)
{
Preconditions.checkNotNull(type, "Signature type can't be null");
this.signatureType = type;
return this;
}
/**
* Returns the fully configured {@link OAuthService}
@@ -133,6 +147,6 @@ public class ServiceBuilder
Preconditions.checkNotNull(api, "You must specify a valid api through the provider() method");
Preconditions.checkEmptyString(apiKey, "You must provide an api key");
Preconditions.checkEmptyString(apiSecret, "You must provide an api secret");
return api.createService(new OAuthConfig(apiKey, apiSecret, callback), scope);
return api.createService(new OAuthConfig(apiKey, apiSecret, callback, signatureType), scope);
}
}
@@ -16,12 +16,19 @@ public class OAuthConfig
{
this(key,secret,null);
}
//Kept for backwards compatibility
public OAuthConfig(String key, String secret, String callback)
{
this(key,secret,callback,null);
}
public OAuthConfig(String key, String secret, String callback, SignatureType type)
{
this.apiKey = key;
this.apiSecret = secret;
this.callback = callback;
this.signatureType = type;
}
public String getApiKey()