3131import java .util .Map ;
3232
3333/**
34- * Builder class for Auth API parameters.
34+ * Builder for Auth0 Authentication API parameters
35+ *
36+ * You can build your parameters like this
37+ * <pre><code>
38+ * Map<String, Object> parameters = ParameterBuilder.newBuilder()
39+ * .setClientId("{CLIENT_ID}")
40+ * .setConnection("{CONNECTION}")
41+ * .set("{PARAMETER_NAME}", "{PARAMETER_VALUE}")
42+ * .asDictionary();
43+ * </code></pre>
44+ *
45+ * @see ParameterBuilder#newBuilder()
46+ * @see ParameterBuilder#newAuthenticationBuilder()
3547 */
3648public class ParameterBuilder {
3749
3850 public static final String GRANT_TYPE_PASSWORD = "password" ;
3951 public static final String GRANT_TYPE_JWT = "urn:ietf:params:oauth:grant-type:jwt-bearer" ;
52+
4053 public static final String SCOPE_OPENID = "openid" ;
4154 public static final String SCOPE_OFFLINE_ACCESS = "openid offline_access" ;
55+
4256 public static final String ID_TOKEN_KEY = "id_token" ;
4357 public static final String SCOPE_KEY = "scope" ;
4458 public static final String REFRESH_TOKEN_KEY = "refresh_token" ;
@@ -51,11 +65,6 @@ public class ParameterBuilder {
5165
5266 private Map <String , Object > parameters ;
5367
54- /**
55- * Creates a new builder with default parameters
56- *
57- * @param parameters default parameters
58- */
5968 private ParameterBuilder (Map <String , Object > parameters ) {
6069 CheckHelper .checkArgument (parameters != null , "Must provide non-null parameters" );
6170 this .parameters = new HashMap <>(parameters );
@@ -128,17 +137,7 @@ public ParameterBuilder setAccessToken(String accessToken) {
128137 * @return itself
129138 */
130139 public ParameterBuilder setSend (PasswordlessType passwordlessType ) {
131- switch (passwordlessType ) {
132- default :
133- case CODE :
134- return set (SEND_KEY , "code" );
135- case LINK :
136- return set (SEND_KEY , "link" );
137- case LINK_ANDROID :
138- return set (SEND_KEY , "link_android" );
139- case LINK_IOS :
140- return set (SEND_KEY , "link_ios" );
141- }
140+ return set (SEND_KEY , passwordlessType .getValue ());
142141 }
143142
144143 /**
@@ -179,14 +178,14 @@ public ParameterBuilder clearAll() {
179178 /**
180179 * Create a {@link Map} with all the parameters
181180 *
182- * @return an unmodifiable map with the parameters
181+ * @return all parameters added previously as a {@link Map}
183182 */
184183 public Map <String , Object > asDictionary () {
185184 return Collections .unmodifiableMap (new HashMap <>(this .parameters ));
186185 }
187186
188187 /**
189- * Creates a new instance of the builder with default values
188+ * Creates a new instance of the builder using default values for login request, e.g. 'openid' for scope.
190189 *
191190 * @return a new builder
192191 */
@@ -196,7 +195,8 @@ public static ParameterBuilder newAuthenticationBuilder() {
196195 }
197196
198197 /**
199- * Creates a new instance of the builder without any default values
198+ * Creates a new instance of the builder.
199+ * This builder wont have any default values
200200 *
201201 * @return a new builder
202202 */
@@ -205,9 +205,9 @@ public static ParameterBuilder newBuilder() {
205205 }
206206
207207 /**
208- * Creates a new instance of the builder with parameters.
208+ * Creates a new instance of the builder from some initial parameters.
209209 *
210- * @param parameters default parameters
210+ * @param parameters initial parameters
211211 * @return a new builder
212212 */
213213 public static ParameterBuilder newBuilder (Map <String , Object > parameters ) {
0 commit comments