// Path: src/main/java/org/dmfs/oauth2/client/OAuth2AuthCodeAuthorization.java
// public interface OAuth2AuthCodeAuthorization
// {
//     /**
//      * Returns the actual authorization code.
//      *
//      * @return
//      */
//     public CharSequence code();
// 
//     /**
//      * Returns the scope that this authorization has been granted for.
//      *
//      * @return
//      */
//     public OAuth2Scope scope();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/AuthCodeParam.java
// public final class AuthCodeParam extends DelegatingPair<CharSequence, CharSequence>
// {
// 
//     public AuthCodeParam(OAuth2AuthCodeAuthorization authorization)
//     {
//         this(authorization.code());
//     }
// 
// 
//     public AuthCodeParam(CharSequence authCode)
//     {
//         super("code", authCode);
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/CodeVerifierParam.java
// public final class CodeVerifierParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public CodeVerifierParam(CharSequence codeVerifier)
//     {
//         super("code_verifier", codeVerifier);
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/GrantTypeParam.java
// public final class GrantTypeParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public GrantTypeParam(CharSequence grantType)
//     {
//         super("grant_type", grantType);
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/RedirectUriParam.java
// public final class RedirectUriParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public RedirectUriParam(Uri redirectUri)
//     {
//         super("redirect_uri", new Text(redirectUri));
//     }
// }


import org.dmfs.httpessentials.entities.XWwwFormUrlEncodedEntity;
import org.dmfs.jems.iterable.elementary.Seq;
import org.dmfs.oauth2.client.OAuth2AuthCodeAuthorization;
import org.dmfs.oauth2.client.http.requests.parameters.AuthCodeParam;
import org.dmfs.oauth2.client.http.requests.parameters.CodeVerifierParam;
import org.dmfs.oauth2.client.http.requests.parameters.GrantTypeParam;
import org.dmfs.oauth2.client.http.requests.parameters.RedirectUriParam;
import org.dmfs.rfc3986.Uri;
/*
 * Copyright 2016 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.oauth2.client.http.requests;



/**
 * Represents the requests to retrieve the token in an Authorization Code Grant.
 *
 * @author Marten Gajda
 */
public final class AuthorizationCodeTokenRequest extends AbstractAccessTokenRequest
{
    /**
     * Creates a token request for an authorization code flow.
     *
     * @param authorization
     *         The authorization code as returned by the authorization endpoint.
     * @param redirectUri
     *         The client's redirect URI.
     * @param codeVerifier
     *         The code verifier that was send with the authorization request.
     */
    public AuthorizationCodeTokenRequest(OAuth2AuthCodeAuthorization authorization, Uri redirectUri, CharSequence codeVerifier)
    {
        super(authorization.scope(),
                new XWwwFormUrlEncodedEntity(
                        new Seq<>(
// Path: src/main/java/org/dmfs/oauth2/client/OAuth2AuthCodeAuthorization.java
// public interface OAuth2AuthCodeAuthorization
// {
//     /**
//      * Returns the actual authorization code.
//      *
//      * @return
//      */
//     public CharSequence code();
// 
//     /**
//      * Returns the scope that this authorization has been granted for.
//      *
//      * @return
//      */
//     public OAuth2Scope scope();
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/AuthCodeParam.java
// public final class AuthCodeParam extends DelegatingPair<CharSequence, CharSequence>
// {
// 
//     public AuthCodeParam(OAuth2AuthCodeAuthorization authorization)
//     {
//         this(authorization.code());
//     }
// 
// 
//     public AuthCodeParam(CharSequence authCode)
//     {
//         super("code", authCode);
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/CodeVerifierParam.java
// public final class CodeVerifierParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public CodeVerifierParam(CharSequence codeVerifier)
//     {
//         super("code_verifier", codeVerifier);
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/GrantTypeParam.java
// public final class GrantTypeParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public GrantTypeParam(CharSequence grantType)
//     {
//         super("grant_type", grantType);
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/RedirectUriParam.java
// public final class RedirectUriParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public RedirectUriParam(Uri redirectUri)
//     {
//         super("redirect_uri", new Text(redirectUri));
//     }
// }


// Path: src/main/java/org/dmfs/oauth2/client/http/requests/AuthorizationCodeTokenRequest.java
import org.dmfs.httpessentials.entities.XWwwFormUrlEncodedEntity;
import org.dmfs.jems.iterable.elementary.Seq;
import org.dmfs.oauth2.client.OAuth2AuthCodeAuthorization;
import org.dmfs.oauth2.client.http.requests.parameters.AuthCodeParam;
import org.dmfs.oauth2.client.http.requests.parameters.CodeVerifierParam;
import org.dmfs.oauth2.client.http.requests.parameters.GrantTypeParam;
import org.dmfs.oauth2.client.http.requests.parameters.RedirectUriParam;
import org.dmfs.rfc3986.Uri;

/*
 * Copyright 2016 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.oauth2.client.http.requests;



/**
 * Represents the requests to retrieve the token in an Authorization Code Grant.
 *
 * @author Marten Gajda
 */
public final class AuthorizationCodeTokenRequest extends AbstractAccessTokenRequest
{
    /**
     * Creates a token request for an authorization code flow.
     *
     * @param authorization
     *         The authorization code as returned by the authorization endpoint.
     * @param redirectUri
     *         The client's redirect URI.
     * @param codeVerifier
     *         The code verifier that was send with the authorization request.
     */
    public AuthorizationCodeTokenRequest(OAuth2AuthCodeAuthorization authorization, Uri redirectUri, CharSequence codeVerifier)
    {
        super(authorization.scope(),
                new XWwwFormUrlEncodedEntity(
                        new Seq<>(
                                new GrantTypeParam("authorization_code"),