Android Open Source - klarna-on-demand-android Url Helper






From Project

Back to project page klarna-on-demand-android.

License

The source code is released under:

Apache License

If you think the Android project klarna-on-demand-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.klarna.ondemand;
//w  w w.ja va  2s .co m
import java.util.Locale;

final class UrlHelper {

    private static final String KlarnaPlaygroundUrl = "https://inapp.playground.klarna.com";
    private static final String KlarnaProductionUrl = "https://inapp.klarna.com";

    static String baseUrl() {
        if(Context.getApiKey().startsWith("test_")) {
            return KlarnaPlaygroundUrl;
        }
        return KlarnaProductionUrl;
    }

    static String registrationUrl() {
        return String.format("%s/registration/new?api_key=%s&locale=%s", baseUrl(), Context.getApiKey(), defaultLocale());
    }

    static String preferencesUrl(String token) {
        return String.format("%s/users/%s/preferences?api_key=%s&locale=%s", baseUrl(), token, Context.getApiKey(), defaultLocale());
    }

    static String defaultLocale() {
        return Locale.getDefault().getLanguage();
    }
}




Java Source Code List

com.klarna.example.ApplicationTest.java
com.klarna.example.MainActivity.java
com.klarna.ondemand.ContextTest.java
com.klarna.ondemand.Context.java
com.klarna.ondemand.RegistrationActivity.java
com.klarna.ondemand.UrlHelperTest.java
com.klarna.ondemand.UrlHelper.java
com.klarna.ondemand.WebViewActivity.java
com.klarna.ondemand.package-info.java