Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add appVersion and deviceOs to request body for mobile Login/SignUp/Payment risk assessments #257

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1.0</version>
<version>3.2.0</version>
</dependency>
```
```xml
<dependency>
<groupId>com.incognia</groupId>
<artifactId>incognia-api-client-shaded</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</dependency>
```

Expand All @@ -47,13 +47,13 @@ repositories {
And then add the dependency
```gradle
dependencies {
implementation 'com.incognia:incognia-api-client:3.1.0'
implementation 'com.incognia:incognia-api-client:3.2.0'
}
```
OR
```gradle
dependencies {
implementation 'com.incognia:incognia-api-client-shaded:3.1.0'
implementation 'com.incognia:incognia-api-client-shaded:3.2.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.1.0"
version = "3.2.0"

task createProjectVersionFile {
def projectVersionDir = "$projectDir/src/main/java/com/incognia/api"
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/incognia/api/IncogniaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public SignupAssessment registerSignup(RegisterSignupRequest request) throws Inc
PostSignupRequestBody.builder()
.installationId(request.getInstallationId())
.requestToken(request.getRequestToken())
.appVersion(request.getAppVersion())
.deviceOs(
Optional.ofNullable(request.getDeviceOs()).map(String::toLowerCase).orElse(null))
.addressLine(address.map(Address::getAddressLine).orElse(null))
.structuredAddress(address.map(Address::getStructuredAddress).orElse(null))
.addressCoordinates(address.map(Address::getCoordinates).orElse(null))
Expand Down Expand Up @@ -195,6 +198,9 @@ public TransactionAssessment registerLogin(RegisterLoginRequest request)
PostTransactionRequestBody.builder()
.installationId(request.getInstallationId())
.requestToken(request.getRequestToken())
.appVersion(request.getAppVersion())
.deviceOs(
Optional.ofNullable(request.getDeviceOs()).map(String::toLowerCase).orElse(null))
.accountId(request.getAccountId())
.externalId(request.getExternalId())
.policyId(request.getPolicyId())
Expand Down Expand Up @@ -392,6 +398,9 @@ public TransactionAssessment registerPayment(RegisterPaymentRequest request)
PostTransactionRequestBody.builder()
.installationId(request.getInstallationId())
.requestToken(request.getRequestToken())
.appVersion(request.getAppVersion())
.deviceOs(
Optional.ofNullable(request.getDeviceOs()).map(String::toLowerCase).orElse(null))
.accountId(request.getAccountId())
.externalId(request.getExternalId())
.policyId(request.getPolicyId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class PostSignupRequestBody {
String sessionToken;
String requestToken;
String addressLine;
String appVersion;
String deviceOs;
StructuredAddress structuredAddress;
Coordinates addressCoordinates;
String externalId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
public class RegisterSignupRequest {
String installationId;
String requestToken;
String appVersion;
String deviceOs;
@Nullable Address address;
String externalId;
String policyId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
public class PostTransactionRequestBody {
String installationId;
String requestToken;
String appVersion;
String deviceOs;
String accountId;
String sessionToken;
String policyId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class RegisterLoginRequest {
String accountId;
String externalId;
String policyId;
String appVersion;
String deviceOs;
Map<String, Object> customProperties;

@Getter(AccessLevel.NONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
public class RegisterPaymentRequest {
String installationId;
String requestToken;
String appVersion;
String deviceOs;
String accountId;
String externalId;
String policyId;
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/com/incognia/api/IncogniaAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,17 @@ void testRegisterSignup_withEmptyAddress() {
String accountId = "my-account";
String policyId = UUID.randomUUID().toString();
String externalId = "external-id";
String appVersion = "1.4.3";
String deviceOs = "iOS";

TokenAwareDispatcher dispatcher = new TokenAwareDispatcher(token, CLIENT_ID, CLIENT_SECRET);
dispatcher.setExpectedAddressLine(null);
dispatcher.setExpectedRequestToken(requestToken);
dispatcher.setExpectedExternalId(externalId);
dispatcher.setExpectedPolicyId(policyId);
dispatcher.setExpectedAccountId(accountId);
dispatcher.setExpectedAppVersion(appVersion);
dispatcher.setExpectedDeviceOs(deviceOs.toLowerCase());
dispatcher.setExpectedCustomProperties(null);
mockServer.setDispatcher(dispatcher);
RegisterSignupRequest registerSignupRequest =
Expand All @@ -169,6 +173,8 @@ void testRegisterSignup_withEmptyAddress() {
.accountId(accountId)
.policyId(policyId)
.externalId(externalId)
.appVersion(appVersion)
.deviceOs(deviceOs)
.customProperties(null)
.build();
SignupAssessment signupAssessment = client.registerSignup(registerSignupRequest);
Expand Down Expand Up @@ -301,6 +307,8 @@ void testRegisterLogin_whenDataIsValid(Boolean eval) {
String token = TokenCreationFixture.createToken();
String requestToken = "request-token";
String accountId = "account-id";
String appVersion = "1.4.3";
String deviceOs = "Android";
String externalId = "external-id";
String policyId = "policy-id";
Map<String, Object> map = new HashMap<>();
Expand All @@ -311,6 +319,8 @@ void testRegisterLogin_whenDataIsValid(Boolean eval) {
PostTransactionRequestBody.builder()
.requestToken(requestToken)
.externalId(externalId)
.appVersion(appVersion)
.deviceOs(deviceOs.toLowerCase())
.accountId(accountId)
.type("login")
.addresses(null)
Expand All @@ -323,6 +333,8 @@ void testRegisterLogin_whenDataIsValid(Boolean eval) {
RegisterLoginRequest.builder()
.requestToken(requestToken)
.accountId(accountId)
.appVersion(appVersion)
.deviceOs(deviceOs)
.externalId(externalId)
.evaluateTransaction(eval)
.policyId(policyId)
Expand Down Expand Up @@ -413,6 +425,8 @@ void testRegisterPayment_whenDataIsValid(Boolean eval) {
String token = TokenCreationFixture.createToken();
String requestToken = "request-token";
String accountId = "account-id";
String appVersion = "appVersion";
String deviceOs = "iOS";
String externalId = "external-id";
String policyId = "policy-id";
Address address =
Expand Down Expand Up @@ -456,6 +470,8 @@ void testRegisterPayment_whenDataIsValid(Boolean eval) {
RegisterPaymentRequest.builder()
.requestToken(requestToken)
.accountId(accountId)
.appVersion(appVersion)
.deviceOs(deviceOs)
.externalId(externalId)
.policyId(policyId)
.addresses(Collections.singletonMap(AddressType.SHIPPING, address))
Expand All @@ -469,6 +485,8 @@ void testRegisterPayment_whenDataIsValid(Boolean eval) {
.externalId(externalId)
.policyId(policyId)
.accountId(accountId)
.appVersion(appVersion)
.deviceOs(deviceOs.toLowerCase())
.type("payment")
.addresses(transactionAddresses)
.paymentValue(paymentValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class TokenAwareDispatcher extends Dispatcher {
@Setter private String expectedInstallationId;
@Setter private String expectedExternalId;
@Setter private String expectedAccountId;
@Setter private String expectedAppVersion;
@Setter private String expectedDeviceOs;
@Setter private String expectedPolicyId;
@Setter private String expectedAddressLine;
@Setter private Map<String, Object> expectedCustomProperties;
Expand Down Expand Up @@ -138,6 +140,8 @@ private MockResponse handlePostSignup(@NotNull RecordedRequest request)
assertThat(postSignupRequestBody.getInstallationId()).isEqualTo(expectedInstallationId);
assertThat(postSignupRequestBody.getRequestToken()).isEqualTo(expectedRequestToken);
assertThat(postSignupRequestBody.getAccountId()).isEqualTo(expectedAccountId);
assertThat(postSignupRequestBody.getAppVersion()).isEqualTo(expectedAppVersion);
assertThat(postSignupRequestBody.getDeviceOs()).isEqualTo(expectedDeviceOs);
assertThat(postSignupRequestBody.getExternalId()).isEqualTo(expectedExternalId);
assertThat(postSignupRequestBody.getPolicyId()).isEqualTo(expectedPolicyId);
assertThat(postSignupRequestBody.getAddressLine()).isEqualTo(expectedAddressLine);
Expand Down
Loading