[LIB-10] WorldSnooker URL utils
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / SnookerURLUtils.java
index c345d78..33e978c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2019. Developed by Hedgecode.
+ * Copyright (c) 2017-2020. Developed by Hedgecode.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,6 +51,10 @@ public final class SnookerURLUtils {
     private static final String TWITTER_URL = "https://twitter.com/";
     private static final String TWITTER_HASHTAG = "hashtag/";
 
+    private static final String WORLDSNOOKER_URL = "http://livescores.worldsnookerdata.com/";
+    private static final String WORLDSNOOKER_EVENT_MATCHES = "Matches/Index/";
+    private static final String WORLDSNOOKER_MATCH_RESULT = "Matches/Result/";
+
     public static List<SnookerURL> parseUrls(Map<String, String> htmlStrings) throws APIException {
         List<SnookerURL> result = new ArrayList<>();
         htmlStrings.forEach( (name, htmlString) -> {
@@ -147,4 +151,16 @@ public final class SnookerURLUtils {
                 : null;
     }
 
+    public static String worldSnookerEventUrl(int wsEventId) {
+        return wsEventId > 0
+                ? String.format("%s%s%d", WORLDSNOOKER_URL, WORLDSNOOKER_EVENT_MATCHES, wsEventId)
+                : null;
+    }
+
+    public static String worldSnookerMatchUrl(int wsEventId, int wsMatchId) {
+        return wsEventId > 0 && wsMatchId > 0
+                ? String.format("%s%s%d/%d", WORLDSNOOKER_URL, WORLDSNOOKER_MATCH_RESULT, wsEventId, wsMatchId)
+                : null;
+    }
+
 }