Skip to content

Commit

Permalink
Feat/make request token optional (#258)
Browse files Browse the repository at this point in the history
* Make request token and installation ID optional fields for Onboarding, Login and Payment APIs

* Bump version to 3.3.0

---------

Signed-off-by: Bruno Ferrari <[email protected]>
  • Loading branch information
brunoekferrari authored Jan 30, 2025
1 parent 644880a commit a3fe3fe
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 90 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ And then add the artifact `incognia-api-client` **or** `incognia-api-client-shad
<dependency>
<groupId>com.incognia</groupId>
<artifactId>incognia-api-client</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
</dependency>
```
```xml
<dependency>
<groupId>com.incognia</groupId>
<artifactId>incognia-api-client-shaded</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
</dependency>
```

Expand All @@ -47,13 +47,13 @@ repositories {
And then add the dependency
```gradle
dependencies {
implementation 'com.incognia:incognia-api-client:3.2.0'
implementation 'com.incognia:incognia-api-client:3.3.0'
}
```
OR
```gradle
dependencies {
implementation 'com.incognia:incognia-api-client-shaded:3.2.0'
implementation 'com.incognia:incognia-api-client-shaded:3.3.0'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "com.incognia"
version = "3.2.0"
version = "3.3.0"

task createProjectVersionFile {
def projectVersionDir = "$projectDir/src/main/java/com/incognia/api"
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/com/incognia/api/IncogniaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ public static IncogniaAPI instance() {
*/
public SignupAssessment registerSignup(RegisterSignupRequest request) throws IncogniaException {
Asserts.assertNotNull(request, "register signup request");
Asserts.assertNotEmpty(
Optional.ofNullable(request.getRequestToken()).orElse(request.getInstallationId()),
"request token");
Optional<Address> address = Optional.ofNullable(request.getAddress());
PostSignupRequestBody postSignupRequestBody =
PostSignupRequestBody.builder()
Expand Down Expand Up @@ -190,9 +187,6 @@ public SignupAssessment registerSignup(RegisterSignupRequest request) throws Inc
public TransactionAssessment registerLogin(RegisterLoginRequest request)
throws IncogniaException {
Asserts.assertNotNull(request, "register login request");
Asserts.assertNotEmpty(
Optional.ofNullable(request.getRequestToken()).orElse(request.getInstallationId()),
"request token");
Asserts.assertNotEmpty(request.getAccountId(), "account id");
PostTransactionRequestBody requestBody =
PostTransactionRequestBody.builder()
Expand Down Expand Up @@ -388,9 +382,6 @@ public SignupAssessment registerWebSignup(RegisterWebSignupRequest request)
public TransactionAssessment registerPayment(RegisterPaymentRequest request)
throws IncogniaException {
Asserts.assertNotNull(request, "register payment request");
Asserts.assertNotEmpty(
Optional.ofNullable(request.getRequestToken()).orElse(request.getInstallationId()),
"request token");
Asserts.assertNotEmpty(request.getAccountId(), "account id");
List<TransactionAddress> transactionAddresses =
addressMapToTransactionAddresses(request.getAddresses());
Expand Down
76 changes: 0 additions & 76 deletions src/test/java/com/incognia/api/IncogniaAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,34 +270,6 @@ void testRegisterWebSignup_whenDataIsValid() {
assertThat(webSignupAssessment.getReasons()).containsExactly(expectedReason);
}

@Test
@DisplayName("should throw illegal argument exception with correct message")
@SneakyThrows
void testRegisterSignup_whenEmptyRequestToken() {
assertThatThrownBy(
() ->
client.registerSignup(
RegisterSignupRequest.builder()
.requestToken("")
.address(AddressFixture.ADDRESS_ADDRESS_LINE)
.customProperties(null)
.build()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("'request token' cannot be empty");
}

@Test
@DisplayName("should throw illegal argument exception with correct message")
@SneakyThrows
void testRegisterWebSignup_whenEmptyRequestToken() {
assertThatThrownBy(
() ->
client.registerWebSignup(
RegisterWebSignupRequest.builder().requestToken("").build()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("'request token' cannot be empty");
}

@ParameterizedTest
@ValueSource(booleans = {true})
@NullSource
Expand Down Expand Up @@ -608,54 +580,6 @@ void testRegisterFeedback_whenDataIsValid(boolean dryRun) {
dryRun);
}

@Test
@DisplayName("should throw illegal argument exception with correct message")
@SneakyThrows
void testRegisterPayment_whenRequestTokenIsNotValid() {
assertThatThrownBy(
() ->
client.registerPayment(
RegisterPaymentRequest.builder()
.requestToken("")
.accountId("account id")
.build()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("'request token' cannot be empty");
assertThatThrownBy(
() ->
client.registerPayment(
RegisterPaymentRequest.builder()
.requestToken(null)
.accountId("account id")
.build()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("'request token' cannot be empty");
}

@Test
@DisplayName("should throw illegal argument exception with correct message")
@SneakyThrows
void testRegisterLogin_whenRequestTokenIsNotValid() {
assertThatThrownBy(
() ->
client.registerLogin(
RegisterLoginRequest.builder()
.requestToken("")
.accountId("account id")
.build()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("'request token' cannot be empty");
assertThatThrownBy(
() ->
client.registerLogin(
RegisterLoginRequest.builder()
.requestToken(null)
.accountId("account id")
.build()))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("'request token' cannot be empty");
}

@Test
@DisplayName("should throw illegal argument exception with correct message")
@SneakyThrows
Expand Down

0 comments on commit a3fe3fe

Please sign in to comment.