Search in sources :

Example 1 with Realm

use of no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm in project L4J8 by stelar7.

the class StaticTest method testRealms.

@Test
public void testRealms() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    DataCall.setLogLevel(LogLevel.DEBUG);
    Realm data = api.getRealm(Platform.EUW1);
}
Also used : FileSystemCacheProvider(no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider) Realm(no.stelar7.api.l4j8.pojo.staticdata.realm.Realm)

Example 2 with Realm

use of no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm in project L4J8 by stelar7.

the class StaticAPI method getRealm.

public Realm getRealm(Platform server) {
    DataCallBuilder builder = new DataCallBuilder().withEndpoint(URLEndpoint.V3_STATIC_REALMS).withURLData(Constants.URL_PARAM_DATA_BY_ID, String.valueOf(true)).withPlatform(server);
    Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_STATIC_REALMS, server);
    if (chl.isPresent()) {
        return (Realm) chl.get();
    }
    try {
        Realm list = (Realm) builder.build();
        DataCall.getCacheProvider().store(URLEndpoint.V3_STATIC_REALMS, list, server);
        return list;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : Realm(no.stelar7.api.l4j8.pojo.staticdata.realm.Realm)

Example 3 with Realm

use of no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm in project L4J8 by stelar7.

the class StaticTest method testRealms.

@Test
public void testRealms() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    Realm data = api.getRealm();
}
Also used : FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider) Realm(no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm)

Example 4 with Realm

use of no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm in project L4J8 by stelar7.

the class ImageAPI method buildImageURL.

private String buildImageURL(@Nullable String version, String path, String file, @Nullable Platform rreg) {
    Platform region = rreg;
    if (region == null) {
        region = Platform.EUW1;
    }
    Realm realm = StaticAPI.getInstance().getRealm(region);
    String cdn = realm.getCDN();
    String versionString = version != null ? version : realm.getV();
    String preReplace = cdn + Constants.SEPARATOR + versionString + Constants.SEPARATOR + path + Constants.SEPARATOR + file;
    return preReplace.replace(" ", "%20");
}
Also used : Realm(no.stelar7.api.l4j8.pojo.staticdata.realm.Realm)

Example 5 with Realm

use of no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm in project L4J8 by stelar7.

the class DDragonAPI method getRealm.

public Realm getRealm(LeagueShard region) {
    DataCallBuilder builder = new DataCallBuilder().withLimiters(false).withProxy(Constants.DDRAGON_PROXY).withURLParameter(Constants.REGION_PLACEHOLDER, region.getRealmValue()).withEndpoint(URLEndpoint.DDRAGON_REALMS);
    Map<String, Object> data = new TreeMap<>();
    data.put("platform", region);
    Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.DDRAGON_REALMS, data);
    if (chl.isPresent()) {
        return (Realm) chl.get();
    }
    try {
        Realm list = (Realm) builder.build();
        data.put("value", list);
        DataCall.getCacheProvider().store(URLEndpoint.DDRAGON_REALMS, data);
        return list;
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : Realm(no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm)

Aggregations

Realm (no.stelar7.api.l4j8.pojo.staticdata.realm.Realm)3 Realm (no.stelar7.api.r4j.pojo.lol.staticdata.realm.Realm)3 FileSystemCacheProvider (no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)1 FileSystemCacheProvider (no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)1