|
| 1 | +package io.imagekit.sdk.config; |
| 2 | + |
| 3 | +/** |
| 4 | + * Configuration class contains sdk configuration |
| 5 | + */ |
| 6 | +public class Configuration { |
| 7 | + private String publicKey; |
| 8 | + private String privateKey; |
| 9 | + private String urlEndpoint; |
| 10 | + |
| 11 | + public Configuration() { |
| 12 | + |
| 13 | + } |
| 14 | + |
| 15 | + public Configuration(String publicKey, String privateKey, String urlEndpoint) { |
| 16 | + this.publicKey = publicKey; |
| 17 | + this.privateKey = privateKey; |
| 18 | + this.urlEndpoint = urlEndpoint; |
| 19 | + } |
| 20 | + |
| 21 | + public String getPublicKey() { |
| 22 | + return publicKey; |
| 23 | + } |
| 24 | + |
| 25 | + public void setPublicKey(String publicKey) { |
| 26 | + this.publicKey = publicKey; |
| 27 | + } |
| 28 | + |
| 29 | + public String getPrivateKey() { |
| 30 | + return privateKey; |
| 31 | + } |
| 32 | + |
| 33 | + public void setPrivateKey(String privateKey) { |
| 34 | + this.privateKey = privateKey; |
| 35 | + } |
| 36 | + |
| 37 | + public String getUrlEndpoint() { |
| 38 | + return urlEndpoint; |
| 39 | + } |
| 40 | + |
| 41 | + public void setUrlEndpoint(String urlEndpoint) { |
| 42 | + this.urlEndpoint = urlEndpoint; |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public String toString() { |
| 47 | + return "Configuration{" + |
| 48 | + "publicKey='" + publicKey + '\'' + |
| 49 | + ", privateKey='" + privateKey + '\'' + |
| 50 | + ", urlEndpoint='" + urlEndpoint + '\'' + |
| 51 | + '}'; |
| 52 | + } |
| 53 | + |
| 54 | + public boolean validate(){ |
| 55 | + if (urlEndpoint==null){ |
| 56 | + throw new RuntimeException("UrlEndpoint not found in config.properties"); |
| 57 | + } |
| 58 | + if (privateKey==null){ |
| 59 | + throw new RuntimeException("PrivateKey not found in config.properties"); |
| 60 | + } |
| 61 | + if (publicKey==null){ |
| 62 | + throw new RuntimeException("PublicKey not found in config.properties"); |
| 63 | + } |
| 64 | + return true; |
| 65 | + } |
| 66 | +} |
0 commit comments