Skip to content

Commit d93c16d

Browse files
author
Damian Staszewski
authored
Merge pull request #6 from stachu540/dev
Releasing 0.8.0
2 parents 3b53bcc + 6865b35 commit d93c16d

File tree

14 files changed

+619
-528
lines changed

14 files changed

+619
-528
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>pl.stachu540</groupId>
88
<artifactId>HiRezAPI</artifactId>
9-
<version>0.6.0</version>
9+
<version>0.8.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Hi-Rez API</name>
@@ -54,9 +54,9 @@
5454

5555
<dependencies>
5656
<dependency>
57-
<groupId>commons-io</groupId>
58-
<artifactId>commons-io</artifactId>
59-
<version>2.5</version>
57+
<groupId>com.squareup.okhttp3</groupId>
58+
<artifactId>okhttp</artifactId>
59+
<version>3.8.1</version>
6060
</dependency>
6161
<dependency>
6262
<groupId>org.json</groupId>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package pl.stachu540;
2+
3+
import com.sun.istack.internal.NotNull;
4+
import pl.stachu540.hirezstudios.Paladins;
5+
import pl.stachu540.hirezstudios.Smite;
6+
7+
import java.io.*;
8+
import java.nio.file.Paths;
9+
import java.util.Properties;
10+
11+
public class HiRezAPI {
12+
private static final File filesession = Paths.get(System.getProperty("java.io.tmpdir"), ".hirezsessions").toFile();
13+
14+
/**
15+
* Session keys for specific base API url type
16+
*/
17+
public static final Properties sessions = new Properties() {
18+
@Override
19+
public synchronized String setProperty(String key, String value) {
20+
put(key, value);
21+
try {
22+
HiRezAPI.store();
23+
} catch (IOException ex) {
24+
ex.printStackTrace();
25+
}
26+
return value;
27+
}
28+
};
29+
30+
/**
31+
* Developer ID (DevId)
32+
* @see HiRezAPI#HiRezAPI(String, String)
33+
*/
34+
private final String devId;
35+
36+
/**
37+
* Authorization Key (AuthKey)
38+
* @see HiRezAPI#HiRezAPI(String, String)
39+
*/
40+
private final String authKey;
41+
42+
public Smite smite;
43+
public Paladins paladins;
44+
45+
/**
46+
* <p>Initialize Hi-Rez API. All stuff will delivered by Hi-Rez employer via E-Mail.<br />
47+
* Please fill <a href="https://fs12.formsite.com/HiRez/form48/secure_index.html">this form first</a> to using script.<br />
48+
* After acceptation your request, you can proceed to action.</p>
49+
* @param devId Developer ID (DevId)
50+
* @param authKey Authorization Key (AuthKey)
51+
*/
52+
public HiRezAPI(@NotNull String devId, @NotNull String authKey) {
53+
this.devId = devId;
54+
this.authKey = authKey;
55+
try {
56+
initialize();
57+
} catch (Exception ex) {
58+
ex.printStackTrace();
59+
}
60+
}
61+
62+
private static void store() throws IOException {
63+
Writer writer = new FileWriter(filesession);
64+
sessions.store(writer, "");
65+
}
66+
67+
private void initialize() throws IOException {
68+
if (!filesession.exists()) {
69+
filesession.createNewFile();
70+
}
71+
Reader reader = new FileReader(filesession);
72+
sessions.load(reader);
73+
}
74+
75+
/**
76+
* Smite API
77+
* @param platform Platform
78+
* @see Smite
79+
*/
80+
public Smite smite(Smite.Platform platform) {
81+
return new Smite(platform, devId, authKey);
82+
}
83+
84+
/**
85+
* Paladins API
86+
* @param platform Platform
87+
* @see Paladins
88+
*/
89+
public Paladins paladins(Paladins.Platform platform) {
90+
return new Paladins(platform, devId, authKey);
91+
}
92+
93+
}

src/main/java/pl/stachu540/hirezstudios/HiRezAPI.java

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)