http-service: move several hardcoded urls to config
Also make an OkHttpClient bean and use it everywhere
This commit is contained in:
@@ -68,7 +68,7 @@ import org.sql2o.quirks.NoQuirks;
|
|||||||
public class SpringBootWebApplication extends SpringBootServletInitializer
|
public class SpringBootWebApplication extends SpringBootServletInitializer
|
||||||
{
|
{
|
||||||
@Bean
|
@Bean
|
||||||
protected ServletContextListener listener()
|
protected ServletContextListener listener(OkHttpClient client)
|
||||||
{
|
{
|
||||||
return new ServletContextListener()
|
return new ServletContextListener()
|
||||||
{
|
{
|
||||||
@@ -82,7 +82,6 @@ public class SpringBootWebApplication extends SpringBootServletInitializer
|
|||||||
public void contextDestroyed(ServletContextEvent sce)
|
public void contextDestroyed(ServletContextEvent sce)
|
||||||
{
|
{
|
||||||
// Destroy okhttp client
|
// Destroy okhttp client
|
||||||
OkHttpClient client = RuneLiteAPI.CLIENT;
|
|
||||||
client.dispatcher().executorService().shutdown();
|
client.dispatcher().executorService().shutdown();
|
||||||
client.connectionPool().evictAll();
|
client.connectionPool().evictAll();
|
||||||
try
|
try
|
||||||
@@ -200,6 +199,12 @@ public class SpringBootWebApplication extends SpringBootServletInitializer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public OkHttpClient okHttpClient()
|
||||||
|
{
|
||||||
|
return RuneLiteAPI.CLIENT;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
SpringApplication.run(SpringBootWebApplication.class, args);
|
SpringApplication.run(SpringBootWebApplication.class, args);
|
||||||
|
|||||||
@@ -25,29 +25,11 @@
|
|||||||
package net.runelite.http.service.account;
|
package net.runelite.http.service.account;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class State
|
public class State
|
||||||
{
|
{
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private String apiVersion;
|
private String apiVersion;
|
||||||
|
|
||||||
public UUID getUuid()
|
|
||||||
{
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUuid(UUID uuid)
|
|
||||||
{
|
|
||||||
this.uuid = uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getApiVersion()
|
|
||||||
{
|
|
||||||
return apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiVersion(String apiVersion)
|
|
||||||
{
|
|
||||||
this.apiVersion = apiVersion;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,13 +33,15 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import net.runelite.http.api.feed.FeedItem;
|
import net.runelite.http.api.feed.FeedItem;
|
||||||
import net.runelite.http.api.feed.FeedItemType;
|
import net.runelite.http.api.feed.FeedItemType;
|
||||||
import net.runelite.http.service.util.exception.InternalServerErrorException;
|
import net.runelite.http.service.util.exception.InternalServerErrorException;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
@@ -50,16 +52,28 @@ import org.xml.sax.SAXException;
|
|||||||
@Service
|
@Service
|
||||||
public class BlogService
|
public class BlogService
|
||||||
{
|
{
|
||||||
private static final HttpUrl RSS_URL = HttpUrl.parse("https://runelite.net/atom.xml");
|
|
||||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
|
||||||
|
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
|
private final HttpUrl rssUrl;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public BlogService(
|
||||||
|
OkHttpClient okHttpClient,
|
||||||
|
@Value("${runelite.feed.rssUrl}") String rssUrl
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
|
this.rssUrl = HttpUrl.get(rssUrl);
|
||||||
|
}
|
||||||
|
|
||||||
public List<FeedItem> getBlogPosts() throws IOException
|
public List<FeedItem> getBlogPosts() throws IOException
|
||||||
{
|
{
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(RSS_URL)
|
.url(rssUrl)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,13 +33,15 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import net.runelite.http.api.feed.FeedItem;
|
import net.runelite.http.api.feed.FeedItem;
|
||||||
import net.runelite.http.api.feed.FeedItemType;
|
import net.runelite.http.api.feed.FeedItemType;
|
||||||
import net.runelite.http.service.util.exception.InternalServerErrorException;
|
import net.runelite.http.service.util.exception.InternalServerErrorException;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
@@ -50,16 +52,28 @@ import org.xml.sax.SAXException;
|
|||||||
@Service
|
@Service
|
||||||
public class OSRSNewsService
|
public class OSRSNewsService
|
||||||
{
|
{
|
||||||
private static final HttpUrl RSS_URL = HttpUrl.parse("https://services.runescape.com/m=news/latest_news.rss?oldschool=true");
|
|
||||||
private static final SimpleDateFormat PUB_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy '00:00:00 GMT'", Locale.US);
|
private static final SimpleDateFormat PUB_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy '00:00:00 GMT'", Locale.US);
|
||||||
|
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
|
private final HttpUrl rssUrl;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public OSRSNewsService(
|
||||||
|
OkHttpClient okHttpClient,
|
||||||
|
@Value("${runelite.osrsnews.rssUrl}") String rssUrl
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
|
this.rssUrl = HttpUrl.get(rssUrl);
|
||||||
|
}
|
||||||
|
|
||||||
public List<FeedItem> getNews() throws IOException
|
public List<FeedItem> getNews() throws IOException
|
||||||
{
|
{
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(RSS_URL)
|
.url(rssUrl)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import net.runelite.http.api.feed.FeedItemType;
|
|||||||
import net.runelite.http.service.util.exception.InternalServerErrorException;
|
import net.runelite.http.service.util.exception.InternalServerErrorException;
|
||||||
import okhttp3.FormBody;
|
import okhttp3.FormBody;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -54,6 +55,7 @@ public class TwitterService
|
|||||||
|
|
||||||
private final String credentials;
|
private final String credentials;
|
||||||
private final String listId;
|
private final String listId;
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
@@ -61,11 +63,13 @@ public class TwitterService
|
|||||||
public TwitterService(
|
public TwitterService(
|
||||||
@Value("${runelite.twitter.consumerkey}") String consumerKey,
|
@Value("${runelite.twitter.consumerkey}") String consumerKey,
|
||||||
@Value("${runelite.twitter.secretkey}") String consumerSecret,
|
@Value("${runelite.twitter.secretkey}") String consumerSecret,
|
||||||
@Value("${runelite.twitter.listid}") String listId
|
@Value("${runelite.twitter.listid}") String listId,
|
||||||
|
OkHttpClient okHttpClient
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.credentials = consumerKey + ":" + consumerSecret;
|
this.credentials = consumerKey + ":" + consumerSecret;
|
||||||
this.listId = listId;
|
this.listId = listId;
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FeedItem> getTweets() throws IOException
|
public List<FeedItem> getTweets() throws IOException
|
||||||
@@ -91,7 +95,7 @@ public class TwitterService
|
|||||||
.header("Authorization", "Bearer " + token)
|
.header("Authorization", "Bearer " + token)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
@@ -143,7 +147,7 @@ public class TwitterService
|
|||||||
.post(new FormBody.Builder().add("grant_type", "client_credentials").build())
|
.post(new FormBody.Builder().add("grant_type", "client_credentials").build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,10 +39,12 @@ import net.runelite.http.api.RuneLiteAPI;
|
|||||||
import net.runelite.http.api.item.ItemType;
|
import net.runelite.http.api.item.ItemType;
|
||||||
import net.runelite.http.service.cache.CacheService;
|
import net.runelite.http.service.cache.CacheService;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.sql2o.Connection;
|
import org.sql2o.Connection;
|
||||||
@@ -53,10 +55,6 @@ import org.sql2o.Sql2o;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ItemService
|
public class ItemService
|
||||||
{
|
{
|
||||||
private static final String BASE = "https://services.runescape.com/m=itemdb_oldschool";
|
|
||||||
private static final HttpUrl RS_ITEM_URL = HttpUrl.parse(BASE + "/api/catalogue/detail.json");
|
|
||||||
private static final HttpUrl RS_PRICE_URL = HttpUrl.parse(BASE + "/api/graph");
|
|
||||||
|
|
||||||
private static final String CREATE_ITEMS = "CREATE TABLE IF NOT EXISTS `items` (\n"
|
private static final String CREATE_ITEMS = "CREATE TABLE IF NOT EXISTS `items` (\n"
|
||||||
+ " `id` int(11) NOT NULL,\n"
|
+ " `id` int(11) NOT NULL,\n"
|
||||||
+ " `name` tinytext NOT NULL,\n"
|
+ " `name` tinytext NOT NULL,\n"
|
||||||
@@ -77,16 +75,27 @@ public class ItemService
|
|||||||
|
|
||||||
private final Sql2o sql2o;
|
private final Sql2o sql2o;
|
||||||
private final CacheService cacheService;
|
private final CacheService cacheService;
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
|
private final HttpUrl itemUrl;
|
||||||
|
private final HttpUrl priceUrl;
|
||||||
|
|
||||||
private int[] tradeableItems;
|
private int[] tradeableItems;
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ItemService(@Qualifier("Runelite SQL2O") Sql2o sql2o,
|
public ItemService(
|
||||||
CacheService cacheService)
|
@Qualifier("Runelite SQL2O") Sql2o sql2o,
|
||||||
|
CacheService cacheService,
|
||||||
|
OkHttpClient okHttpClient,
|
||||||
|
@Value("${runelite.item.itemUrl}") String itemUrl,
|
||||||
|
@Value("${runelite.item.priceUrl}") String priceUrl
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.sql2o = sql2o;
|
this.sql2o = sql2o;
|
||||||
this.cacheService = cacheService;
|
this.cacheService = cacheService;
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
|
this.itemUrl = HttpUrl.get(itemUrl);
|
||||||
|
this.priceUrl = HttpUrl.get(priceUrl);
|
||||||
|
|
||||||
try (Connection con = sql2o.open())
|
try (Connection con = sql2o.open())
|
||||||
{
|
{
|
||||||
@@ -195,7 +204,7 @@ public class ItemService
|
|||||||
|
|
||||||
private RSItem fetchRSItem(int itemId) throws IOException
|
private RSItem fetchRSItem(int itemId) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl itemUrl = RS_ITEM_URL
|
HttpUrl itemUrl = this.itemUrl
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.addQueryParameter("item", "" + itemId)
|
.addQueryParameter("item", "" + itemId)
|
||||||
.build();
|
.build();
|
||||||
@@ -211,7 +220,7 @@ public class ItemService
|
|||||||
|
|
||||||
private RSPrices fetchRSPrices(int itemId) throws IOException
|
private RSPrices fetchRSPrices(int itemId) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl priceUrl = RS_PRICE_URL
|
HttpUrl priceUrl = this.priceUrl
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.addPathSegment(itemId + ".json")
|
.addPathSegment(itemId + ".json")
|
||||||
.build();
|
.build();
|
||||||
@@ -223,9 +232,9 @@ public class ItemService
|
|||||||
return fetchJson(request, RSPrices.class);
|
return fetchJson(request, RSPrices.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T fetchJson(Request request, Class<T> clazz) throws IOException
|
private <T> T fetchJson(Request request, Class<T> clazz) throws IOException
|
||||||
{
|
{
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response response = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!response.isSuccessful())
|
if (!response.isSuccessful())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.util.Map;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -57,14 +58,19 @@ public class WikiPriceService
|
|||||||
") ENGINE=InnoDB;";
|
") ENGINE=InnoDB;";
|
||||||
|
|
||||||
private final Sql2o sql2o;
|
private final Sql2o sql2o;
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
@Value("${runelite.wiki.url}")
|
private final HttpUrl wikiUrl;
|
||||||
private String url;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public WikiPriceService(@Qualifier("Runelite SQL2O") Sql2o sql2o)
|
public WikiPriceService(
|
||||||
|
@Qualifier("Runelite SQL2O") Sql2o sql2o,
|
||||||
|
OkHttpClient okHttpClient,
|
||||||
|
@Value("${runelite.wiki.url}") String url
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.sql2o = sql2o;
|
this.sql2o = sql2o;
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
|
this.wikiUrl = HttpUrl.get(url);
|
||||||
|
|
||||||
try (Connection con = sql2o.open())
|
try (Connection con = sql2o.open())
|
||||||
{
|
{
|
||||||
@@ -112,13 +118,12 @@ public class WikiPriceService
|
|||||||
|
|
||||||
private PriceResult getPrices() throws IOException
|
private PriceResult getPrices() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl httpUrl = HttpUrl.parse(url);
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(httpUrl)
|
.url(wikiUrl)
|
||||||
.header("User-Agent", "RuneLite")
|
.header("User-Agent", "RuneLite")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response responseOk = RuneLiteAPI.CLIENT.newCall(request).execute())
|
try (Response responseOk = okHttpClient.newCall(request).execute())
|
||||||
{
|
{
|
||||||
if (!responseOk.isSuccessful())
|
if (!responseOk.isSuccessful())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,21 +29,32 @@ import java.nio.ByteBuffer;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import net.runelite.http.api.worlds.World;
|
import net.runelite.http.api.worlds.World;
|
||||||
import net.runelite.http.api.worlds.WorldResult;
|
import net.runelite.http.api.worlds.WorldResult;
|
||||||
import net.runelite.http.api.worlds.WorldType;
|
import net.runelite.http.api.worlds.WorldType;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class WorldsService
|
public class WorldsService
|
||||||
{
|
{
|
||||||
private static final HttpUrl WORLD_URL = HttpUrl.parse("http://www.runescape.com/g=oldscape/slr.ws?order=LPWM");
|
private final OkHttpClient okHttpClient;
|
||||||
|
private final HttpUrl url;
|
||||||
|
|
||||||
private HttpUrl url = WORLD_URL;
|
@Autowired
|
||||||
|
public WorldsService(
|
||||||
|
OkHttpClient okHttpClient,
|
||||||
|
@Value("${runelite.worlds.url}") String url
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.okHttpClient = okHttpClient;
|
||||||
|
this.url = HttpUrl.get(url);
|
||||||
|
}
|
||||||
|
|
||||||
public WorldResult getWorlds() throws IOException
|
public WorldResult getWorlds() throws IOException
|
||||||
{
|
{
|
||||||
@@ -53,7 +64,7 @@ public class WorldsService
|
|||||||
|
|
||||||
byte[] b;
|
byte[] b;
|
||||||
|
|
||||||
try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute())
|
try (Response okresponse = okHttpClient.newCall(okrequest).execute())
|
||||||
{
|
{
|
||||||
b = okresponse.body().bytes();
|
b = okresponse.body().bytes();
|
||||||
}
|
}
|
||||||
@@ -118,14 +129,4 @@ public class WorldsService
|
|||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpUrl getUrl()
|
|
||||||
{
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(HttpUrl url)
|
|
||||||
{
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,3 +47,12 @@ runelite:
|
|||||||
url: https://prices.runescape.wiki/api/v1/osrs/latest
|
url: https://prices.runescape.wiki/api/v1/osrs/latest
|
||||||
price:
|
price:
|
||||||
cache: 30 # minutes
|
cache: 30 # minutes
|
||||||
|
feed:
|
||||||
|
rssUrl: https://runelite.net/atom.xml
|
||||||
|
worlds:
|
||||||
|
url: http://www.runescape.com/g=oldscape/slr.ws?order=LPWM
|
||||||
|
osrsnews:
|
||||||
|
rssUrl: https://services.runescape.com/m=news/latest_news.rss?oldschool=true
|
||||||
|
item:
|
||||||
|
itemUrl: https://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json
|
||||||
|
priceUrl: https://services.runescape.com/m=itemdb_oldschool/api/graph
|
||||||
@@ -29,6 +29,7 @@ import java.io.InputStream;
|
|||||||
import net.runelite.http.api.worlds.World;
|
import net.runelite.http.api.worlds.World;
|
||||||
import net.runelite.http.api.worlds.WorldResult;
|
import net.runelite.http.api.worlds.WorldResult;
|
||||||
import net.runelite.http.api.worlds.WorldType;
|
import net.runelite.http.api.worlds.WorldType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.mockwebserver.MockResponse;
|
import okhttp3.mockwebserver.MockResponse;
|
||||||
import okhttp3.mockwebserver.MockWebServer;
|
import okhttp3.mockwebserver.MockWebServer;
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
@@ -60,8 +61,7 @@ public class WorldsServiceTest
|
|||||||
@Test
|
@Test
|
||||||
public void testListWorlds() throws Exception
|
public void testListWorlds() throws Exception
|
||||||
{
|
{
|
||||||
WorldsService worlds = new WorldsService();
|
WorldsService worlds = new WorldsService(new OkHttpClient(), server.url("/").toString());
|
||||||
worlds.setUrl(server.url("/"));
|
|
||||||
|
|
||||||
WorldResult worldResult = worlds.getWorlds();
|
WorldResult worldResult = worlds.getWorlds();
|
||||||
assertEquals(82, worldResult.getWorlds().size());
|
assertEquals(82, worldResult.getWorlds().size());
|
||||||
|
|||||||
Reference in New Issue
Block a user