// Path: src/main/java/org/dmfs/oauth2/client/OAuth2Scope.java
// public interface OAuth2Scope
// {
//     /**
//      * Returns whether this scope is empty.
//      *
//      * @return <code>true</code> if this scope is empty, <code>false</code> otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this scope contains the given scope token or not.
//      *
//      * @param token
//      *         The scope token to check for.
//      *
//      * @return <code>true</code> if the scope token is contained in this scope, <code>false</code> otherwise.
//      */
//     boolean hasToken(String token);
// 
//     /**
//      * Returns the number of tokens in this {@link OAuth2Scope}.
//      *
//      * @return The number of tokens in this {@link OAuth2Scope}.
//      */
//     int tokenCount();
// 
//     /**
//      * Returns a string version of this scope as described in <a href="https://tools.ietf.org/html/rfc6749#section-3.3">RFC 6749, section 3.3</a>, i.e. a list
//      * of scope tokens separated by spaces.
//      *
//      * @return A String containing a list scope tokens, separated by spaces, or an empty String if {@link #isEmpty()} returns <code>true</code>.
//      */
//     String toString();
// }
// 
// 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/OptionalScopeParam.java
// public final class OptionalScopeParam extends DelegatingOptional<Pair<CharSequence, CharSequence>>
// {
//     public OptionalScopeParam(OAuth2Scope scope)
//     {
//         super(new Mapped<>(
//                 s -> new ValuePair<>("scope", s.toString()),
//                 new Conditional<>(s -> !s.isEmpty(), scope)));
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/RefreshTokenParam.java
// public final class RefreshTokenParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public RefreshTokenParam(CharSequence refreshToken)
//     {
//         super("refresh_token", refreshToken);
//     }
// }


import org.dmfs.httpessentials.client.HttpRequest;
import org.dmfs.httpessentials.entities.XWwwFormUrlEncodedEntity;
import org.dmfs.iterables.elementary.PresentValues;
import org.dmfs.jems.iterable.composite.Joined;
import org.dmfs.jems.iterable.elementary.Seq;
import org.dmfs.oauth2.client.OAuth2Scope;
import org.dmfs.oauth2.client.http.requests.parameters.GrantTypeParam;
import org.dmfs.oauth2.client.http.requests.parameters.OptionalScopeParam;
import org.dmfs.oauth2.client.http.requests.parameters.RefreshTokenParam;
/*
 * 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;



/**
 * An {@link HttpRequest} to refresh an OAuth2 access token.
 *
 * @author Marten Gajda
 */
public final class RefreshTokenRequest extends AbstractAccessTokenRequest
{
    /**
     * Creates an {@link RefreshTokenRequest} using the given refresh token and scopes.
     *
     * @param refreshToken
     *         The refresh token.
     * @param scope
     *         An {@link OAuth2Scope}.
     *
     * @deprecated in favour of {@link #RefreshTokenRequest(OAuth2Scope, CharSequence)}
     */
    @Deprecated
    public RefreshTokenRequest(CharSequence refreshToken, OAuth2Scope scope)
    {
        this(scope, refreshToken);
    }


    /**
     * Creates an {@link RefreshTokenRequest} using the given refresh token and scopes.
     *
     * @param scope
     *         An {@link OAuth2Scope}.
     * @param refreshToken
     *         The refresh token.
     */
// Path: src/main/java/org/dmfs/oauth2/client/OAuth2Scope.java
// public interface OAuth2Scope
// {
//     /**
//      * Returns whether this scope is empty.
//      *
//      * @return <code>true</code> if this scope is empty, <code>false</code> otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this scope contains the given scope token or not.
//      *
//      * @param token
//      *         The scope token to check for.
//      *
//      * @return <code>true</code> if the scope token is contained in this scope, <code>false</code> otherwise.
//      */
//     boolean hasToken(String token);
// 
//     /**
//      * Returns the number of tokens in this {@link OAuth2Scope}.
//      *
//      * @return The number of tokens in this {@link OAuth2Scope}.
//      */
//     int tokenCount();
// 
//     /**
//      * Returns a string version of this scope as described in <a href="https://tools.ietf.org/html/rfc6749#section-3.3">RFC 6749, section 3.3</a>, i.e. a list
//      * of scope tokens separated by spaces.
//      *
//      * @return A String containing a list scope tokens, separated by spaces, or an empty String if {@link #isEmpty()} returns <code>true</code>.
//      */
//     String toString();
// }
// 
// 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/OptionalScopeParam.java
// public final class OptionalScopeParam extends DelegatingOptional<Pair<CharSequence, CharSequence>>
// {
//     public OptionalScopeParam(OAuth2Scope scope)
//     {
//         super(new Mapped<>(
//                 s -> new ValuePair<>("scope", s.toString()),
//                 new Conditional<>(s -> !s.isEmpty(), scope)));
//     }
// }
// 
// Path: src/main/java/org/dmfs/oauth2/client/http/requests/parameters/RefreshTokenParam.java
// public final class RefreshTokenParam extends DelegatingPair<CharSequence, CharSequence>
// {
//     public RefreshTokenParam(CharSequence refreshToken)
//     {
//         super("refresh_token", refreshToken);
//     }
// }


// Path: src/main/java/org/dmfs/oauth2/client/http/requests/RefreshTokenRequest.java
import org.dmfs.httpessentials.client.HttpRequest;
import org.dmfs.httpessentials.entities.XWwwFormUrlEncodedEntity;
import org.dmfs.iterables.elementary.PresentValues;
import org.dmfs.jems.iterable.composite.Joined;
import org.dmfs.jems.iterable.elementary.Seq;
import org.dmfs.oauth2.client.OAuth2Scope;
import org.dmfs.oauth2.client.http.requests.parameters.GrantTypeParam;
import org.dmfs.oauth2.client.http.requests.parameters.OptionalScopeParam;
import org.dmfs.oauth2.client.http.requests.parameters.RefreshTokenParam;

/*
 * 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;



/**
 * An {@link HttpRequest} to refresh an OAuth2 access token.
 *
 * @author Marten Gajda
 */
public final class RefreshTokenRequest extends AbstractAccessTokenRequest
{
    /**
     * Creates an {@link RefreshTokenRequest} using the given refresh token and scopes.
     *
     * @param refreshToken
     *         The refresh token.
     * @param scope
     *         An {@link OAuth2Scope}.
     *
     * @deprecated in favour of {@link #RefreshTokenRequest(OAuth2Scope, CharSequence)}
     */
    @Deprecated
    public RefreshTokenRequest(CharSequence refreshToken, OAuth2Scope scope)
    {
        this(scope, refreshToken);
    }


    /**
     * Creates an {@link RefreshTokenRequest} using the given refresh token and scopes.
     *
     * @param scope
     *         An {@link OAuth2Scope}.
     * @param refreshToken
     *         The refresh token.
     */
    public RefreshTokenRequest(OAuth2Scope scope, CharSequence refreshToken)