// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
//     public String token;
//     public long lifetimeInSeconds;
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// }
// 
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
//     public String token;
//     public String description;
//     
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// 
// }


import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Response;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
    @Override
    protected TokenService getInstance(String username, String apiKey) {
        if(sInstance == null) {
            sInstance = new TokenService(username, apiKey);
        }
        return sInstance;
    }

    @Override
    protected boolean isInitialized() {
        return sInstance != null;
    }

    @Override
    protected void initService() {
        String baseUrl = "https://api."+ (isSandbox ? Const.SANDBOX_DOMAIN : Const.PRODUCTION_DOMAIN) + "/";
        service = mRetrofitBuilder
                .baseUrl(baseUrl)
                .build()
                .create(IToken.class);
    }

    @Override
    protected void destroyService() {
        if (sInstance != null) {
            sInstance = null;
        }
    }


// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
//     public String token;
//     public long lifetimeInSeconds;
// 
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// }
// 
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
//     public String token;
//     public String description;
//     
//     @Override
//     public String toString() {
//         return new Gson().toJson(this);
//     }
// 
// }


// Path: libs/token/src/main/java/com/africastalking/TokenService.java
import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Response;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;

    @Override
    protected TokenService getInstance(String username, String apiKey) {
        if(sInstance == null) {
            sInstance = new TokenService(username, apiKey);
        }
        return sInstance;
    }

    @Override
    protected boolean isInitialized() {
        return sInstance != null;
    }

    @Override
    protected void initService() {
        String baseUrl = "https://api."+ (isSandbox ? Const.SANDBOX_DOMAIN : Const.PRODUCTION_DOMAIN) + "/";
        service = mRetrofitBuilder
                .baseUrl(baseUrl)
                .build()
                .create(IToken.class);
    }

    @Override
    protected void destroyService() {
        if (sInstance != null) {
            sInstance = null;
        }
    }


    public CheckoutTokenResponse createCheckoutToken(String phoneNumber) throws IOException {