-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 상품 호출 메소드 (requestProduct) (#6)
* feat: requestProduct 초기 버전 * feat: EasyCodefResponse 파싱 버그 개선 * feat: EasyCodef 파라미터 단일화 * docs: update README.md * docs: update README.md * docs: update README.md * docs: update README.md * docs: update README.md * release: 2.0.0-alpha-003
- Loading branch information
Showing
20 changed files
with
363 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,38 @@ | ||
package io.codef.api; | ||
|
||
import io.codef.api.constants.CodefClientType; | ||
import io.codef.api.dto.EasyCodefRequest; | ||
import io.codef.api.dto.EasyCodefResponse; | ||
import io.codef.api.util.RsaUtil; | ||
|
||
import java.security.PublicKey; | ||
|
||
public class EasyCodef { | ||
private final String publicKey; | ||
private final EasyCodefClientType clientType; | ||
private final PublicKey publicKey; | ||
private final CodefClientType clientType; | ||
private final EasyCodefToken easyCodefToken; | ||
|
||
protected EasyCodef( | ||
EasyCodefBuilder builder, | ||
EasyCodefToken easyCodefToken | ||
) { | ||
this.publicKey = RsaUtil.generatePublicKey(builder.getPublicKey()); | ||
this.clientType = builder.getClientType(); | ||
this.publicKey = builder.getPublicKey(); | ||
this.easyCodefToken = easyCodefToken; | ||
} | ||
|
||
public EasyCodefResponse requestProduct(EasyCodefRequest request) { | ||
final String requestUrl = generateRequestUrl(request); | ||
easyCodefToken.validateAndRefreshToken(); | ||
|
||
return EasyCodefConnector.requestProduct(request, easyCodefToken, requestUrl); | ||
} | ||
|
||
private String generateRequestUrl(EasyCodefRequest request) { | ||
return clientType.getHost() + request.path(); | ||
} | ||
|
||
public PublicKey getPublicKey() { | ||
return publicKey; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.codef.api.constants; | ||
|
||
public enum CodefClientType { | ||
API(CodefHost.CODEF_API), | ||
DEMO(CodefHost.CODEF_API_DEMO); | ||
|
||
private final String host; | ||
|
||
CodefClientType(String host) { | ||
this.host = host; | ||
} | ||
|
||
public String getHost() { | ||
return host; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.codef.api.constants; | ||
|
||
public final class CodefHost { | ||
public static final String CODEF_OAUTH_SERVER = "https://oauth.codef.io"; | ||
public static final String CODEF_API_DEMO = "https://development.codef.io"; | ||
public static final String CODEF_API = "https://api.codef.io"; | ||
} |
4 changes: 2 additions & 2 deletions
4
src/main/java/io/codef/api/CodefUri.java → ...ava/io/codef/api/constants/CodefPath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package io.codef.api; | ||
package io.codef.api.constants; | ||
|
||
final class CodefUri { | ||
public final class CodefPath { | ||
public static final String ISSUE_TOKEN = "/oauth/token?grant_type=client_credentials&scope=read"; | ||
} |
10 changes: 6 additions & 4 deletions
10
...a/io/codef/api/EasyCodefReferenceUrl.java → ...odef/api/constants/CodefReferenceUrl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.codef.api.dto; | ||
|
||
import java.util.HashMap; | ||
|
||
public record EasyCodefRequest( | ||
String path, | ||
HashMap<String, Object> requestParams | ||
) { | ||
} |
Oops, something went wrong.