refactor: update project to read API key from environment variable an… · okeyximo/PaystackJava@ad26fa3 · GitHub
Skip to content

Commit ad26fa3

Browse files
committed
refactor: update project to read API key from environment variable and update README
1 parent ebef4ca commit ad26fa3

5 files changed

Lines changed: 27 additions & 151 deletions

File tree

‎Keys.json‎

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

‎README.md‎

Lines changed: 1 addition & 14 deletions

‎src/me/iyanuadelekan/paystackjava/core/ApiConnection.java‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.mashape.unirest.http.exceptions.UnirestException;
77
import org.json.JSONObject;
88

9-
import java.io.FileNotFoundException;
109
import java.io.IOException;
1110
import java.security.KeyManagementException;
1211
import java.security.NoSuchAlgorithmException;
@@ -25,24 +24,16 @@
2524
*/
2625
public class ApiConnection {
2726

28-
private String url;
29-
private String apiKey;
27+
private final String url;
28+
private final String apiKey;
3029

3130
/**
3231
* @param url - Paystack API URL
3332
*/
3433
public ApiConnection(String url) {
3534
this.url = url;
36-
Keys keys = new Keys();
37-
38-
try {
39-
keys.initKeys();
40-
} catch (FileNotFoundException e) {
41-
System.out.print("Required Keys.json file could not be found.");
42-
e.printStackTrace();
43-
}
44-
45-
this.apiKey = keys.KEY_IN_USE;
35+
ApiKeyManager apiKeyManager = new ApiKeyManager();
36+
this.apiKey = apiKeyManager.getApiKey();
4637
this.enforceTlsV1point2();
4738
}
4839

Lines changed: 22 additions & 0 deletions

‎src/me/iyanuadelekan/paystackjava/core/Keys.java‎

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

0 commit comments

Comments
 (0)