-
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.
* refactor: improve builder pattern (#4) * chore: add CI for build verfication on multiple java versions * refactor: improve builder pattern * 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
26 changed files
with
533 additions
and
200 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build Verification | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
java-version: [17, 21, 23] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK ${{ matrix.java-version }} | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: ${{ matrix.java-version }} | ||
distribution: 'temurin' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with JDK ${{ matrix.java-version }} | ||
run: ./gradlew build |
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 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 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; | ||
|
||
public class EasyCodef { | ||
import java.security.PublicKey; | ||
|
||
private EasyCodefToken easyCodefToken; | ||
private EasyCodefProperty property; | ||
public class EasyCodef { | ||
private final PublicKey publicKey; | ||
private final CodefClientType clientType; | ||
private final EasyCodefToken easyCodefToken; | ||
|
||
protected EasyCodef( | ||
EasyCodefToken easyCodefToken, | ||
EasyCodefProperty property | ||
EasyCodefBuilder builder, | ||
EasyCodefToken easyCodefToken | ||
) { | ||
this.publicKey = RsaUtil.generatePublicKey(builder.getPublicKey()); | ||
this.clientType = builder.getClientType(); | ||
this.easyCodefToken = easyCodefToken; | ||
this.property = property; | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package io.codef.api; | ||
|
||
import io.codef.api.constants.CodefClientType; | ||
import io.codef.api.error.CodefError; | ||
import io.codef.api.error.CodefException; | ||
|
||
import java.util.UUID; | ||
|
||
public class EasyCodefBuilder { | ||
private String publicKey; | ||
private UUID clientId; | ||
private UUID clientSecret; | ||
private CodefClientType clientType; | ||
|
||
public static EasyCodefBuilder builder() { | ||
return new EasyCodefBuilder(); | ||
} | ||
|
||
public EasyCodefBuilder publicKey(String publicKey) { | ||
this.publicKey = CodefValidator.requireNonNullElseThrow(publicKey, CodefError.INVALID_PUBLIC_KEY); | ||
return this; | ||
} | ||
|
||
public EasyCodefBuilder clientId(String clientId) { | ||
this.clientId = parseUUID(clientId, CodefError.INVALID_CLIENT_ID); | ||
return this; | ||
} | ||
|
||
public EasyCodefBuilder clientSecret(String clientSecret) { | ||
this.clientSecret = parseUUID(clientSecret, CodefError.INVALID_CLIENT_SECRET); | ||
return this; | ||
} | ||
|
||
public EasyCodefBuilder clientType(CodefClientType clientType) { | ||
this.clientType = clientType; | ||
return this; | ||
} | ||
|
||
public EasyCodef build() { | ||
validatePropertyArguments(); | ||
EasyCodefToken easyCodefToken = new EasyCodefToken(this); | ||
|
||
return new EasyCodef(this, easyCodefToken); | ||
} | ||
|
||
private void validatePropertyArguments() { | ||
CodefValidator.requireNonNullElseThrow(publicKey, CodefError.NULL_PUBLIC_KEY); | ||
CodefValidator.requireNonNullElseThrow(clientId, CodefError.NULL_CLIENT_ID); | ||
CodefValidator.requireNonNullElseThrow(clientSecret, CodefError.NULL_CLIENT_SECRET); | ||
CodefValidator.requireNonNullElseThrow(clientType, CodefError.NULL_CLIENT_TYPE); | ||
} | ||
|
||
private UUID parseUUID(String value, CodefError error) { | ||
CodefValidator.requireNonNullElseThrow(value, error); | ||
CodefValidator.requireValidUUIDPattern(value, error); | ||
|
||
try { | ||
return UUID.fromString(value); | ||
} catch (Exception exception) { | ||
throw CodefException.of(error, exception); | ||
} | ||
} | ||
|
||
protected String getPublicKey() { | ||
return publicKey; | ||
} | ||
|
||
protected UUID getClientId() { | ||
return clientId; | ||
} | ||
|
||
protected UUID getClientSecret() { | ||
return clientSecret; | ||
} | ||
|
||
protected CodefClientType getClientType() { | ||
return clientType; | ||
} | ||
} |
Oops, something went wrong.