Skip to content

Commit 2a42d43

Browse files
authored
Remove get signup method (#232)
1 parent 319804b commit 2a42d43

9 files changed

+0
-218
lines changed

README.md

-32
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,6 @@ try {
134134
}
135135
```
136136

137-
#### Getting a Signup
138-
139-
This method allows you to query the latest assessment for a given signup event, returning a `SignupAssessment`, containing the risk assessment and supporting evidence:
140-
141-
```java
142-
IncogniaAPI api = new IncogniaAPI("client-id", "client-secret");
143-
try {
144-
UUID signupId = UUID.fromString("c9ac2803-c868-4b7a-8323-8a6b96298ebe");
145-
SignupAssessment assessment = api.getSignupAssessment(signupId);
146-
} catch (IncogniaAPIException e) {
147-
//Some api error happened (invalid data, invalid credentials)
148-
} catch (IncogniaException e) {
149-
//Something unexpected happened
150-
}
151-
```
152-
153137
#### Registering Web Signup
154138

155139
This method registers a new web signup for the given session token, returning a `SignupAssessment`, containing the risk assessment and supporting evidence:
@@ -344,16 +328,6 @@ along with the `getPayload` method, which returns the api response payload, whic
344328

345329
If you have found a bug or if you have a feature request, please report them at this repository issues section.
346330

347-
### Publishing a new version
348-
349-
We use the [Gradle Nexus publish plugin](https://github.com/gradle-nexus/publish-plugin/) to publish artifacts to maven central.
350-
351-
To publish a new version to a staging repository, run:
352-
```bash
353-
./gradlew publishToSonatype closeSonatypeStagingRepository
354-
```
355-
If the version ends with `-SNAPSHOT`, it is published to the Sonatype snapshots repository.
356-
357331
## What is Incognia?
358332

359333
Incognia is a location identity platform for mobile apps that enables:
@@ -362,12 +336,6 @@ Incognia is a location identity platform for mobile apps that enables:
362336
- Frictionless authentication
363337
- Real-time transaction verification
364338

365-
## Create a Free Incognia Account
366-
367-
1. Go to [Incognia](https://www.incognia.com/) and click on "Sign Up For Free"
368-
2. Create an Account
369-
3. You're ready to integrate [Incognia SDK](https://docs.incognia.com/sdk/getting-started) and use [Incognia APIs](https://dash.incognia.com/api-reference)
370-
371339
## License
372340

373341
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

src/main/java/com/incognia/api/IncogniaAPI.java

-29
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.List;
2525
import java.util.Map;
2626
import java.util.Optional;
27-
import java.util.UUID;
2827
import java.util.stream.Collectors;
2928
import okhttp3.OkHttpClient;
3029
import org.jetbrains.annotations.NotNull;
@@ -123,34 +122,6 @@ public SignupAssessment registerSignup(RegisterSignupRequest request) throws Inc
123122
"api/v2/onboarding/signups", postSignupRequestBody, SignupAssessment.class);
124123
}
125124

126-
/**
127-
* Gets the latest assessment for a given signup. Check <a
128-
* href="https://dash.incognia.com/api-reference#operation/signup-get">the docs</a><br>
129-
* Example:
130-
*
131-
* <pre>{@code
132-
* IncogniaAPI api = new IncogniaAPI("client-id", "client-secret", Region.BR);
133-
* try {
134-
* UUID signupId = UUID.fromString("c9ac2803-c868-4b7a-8323-8a6b96298ebe");
135-
* SignupAssessment assessment = api.getSignupAssessment(signupId);
136-
* } catch (IncogniaAPIException e) {
137-
* //Some api error happened (invalid data, invalid credentials)
138-
* } catch (IncogniaException e) {
139-
* //Something unexpected happened
140-
* }
141-
* }</pre>
142-
*
143-
* @param signupId the signup id
144-
* @return the latest assessment
145-
* @throws IncogniaAPIException in case of api errors
146-
* @throws IncogniaException in case of unexpected errors
147-
*/
148-
public SignupAssessment getSignupAssessment(UUID signupId) throws IncogniaException {
149-
Asserts.assertNotNull(signupId, "signup id");
150-
String path = String.format("api/v2/onboarding/signups/%s", signupId);
151-
return tokenAwareNetworkingClient.doGet(path, SignupAssessment.class);
152-
}
153-
154125
/**
155126
* Registers a login to obtain a risk assessment. Check <a
156127
* href="https://dash.incognia.com/api-reference#operation/transactions-post">the docs</a><br>

src/main/java/com/incognia/api/clients/NetworkingClient.java

-21
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,6 @@ public <T> void doPost(
9292
}
9393
}
9494

95-
public <T> T doGet(String path, Class<T> responseType, Map<String, String> headers)
96-
throws IncogniaException {
97-
Request request =
98-
new Builder()
99-
.url(baseUrl.newBuilder().addPathSegments(path).build())
100-
.get()
101-
.headers(Headers.of(headers))
102-
.build();
103-
try (Response response = httpClient.newCall(request).execute()) {
104-
return parseResponse(response, responseType);
105-
} catch (IOException e) {
106-
// TODO(rato): handle timeout
107-
throw new IncogniaException("network call failed", e);
108-
}
109-
}
110-
111-
private <T> Request buildPostRequest(String path, T body, Map<String, String> headers)
112-
throws IncogniaException {
113-
return buildPostRequest(path, body, headers, Collections.emptyMap());
114-
}
115-
11695
@NotNull
11796
private <T> Request buildPostRequest(
11897
String path, T body, Map<String, String> headers, Map<String, String> queryParameters)

src/main/java/com/incognia/api/clients/TokenAwareNetworkingClient.java

-12
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ public <T> void doPost(String path, T body, Map<String, String> queryParameters)
7171
networkingClient.doPost(path, body, headers, queryParameters);
7272
}
7373

74-
public <T> T doGet(String path, Class<T> responseType) throws IncogniaException {
75-
refreshTokenIfNeeded();
76-
Map<String, String> headers =
77-
new HashMap<String, String>() {
78-
{
79-
put(USER_AGENT_HEADER, USER_AGENT_HEADER_CONTENT);
80-
put(AUTHORIZATION_HEADER, buildAuthorizationHeader());
81-
}
82-
};
83-
return networkingClient.doGet(path, responseType, headers);
84-
}
85-
8674
private String buildAuthorizationHeader() {
8775
return token.getTokenType() + " " + token.getAccessToken();
8876
}

src/test/java/com/incognia/api/IncogniaAPITest.java

-46
Original file line numberDiff line numberDiff line change
@@ -271,52 +271,6 @@ void testRegisterWebSignup_whenEmptySessionToken() {
271271
.hasMessage("'session token' cannot be empty");
272272
}
273273

274-
@Test
275-
@DisplayName("should return the expected signup response")
276-
@SneakyThrows
277-
void testGetSignupAssessment_whenDataIsValid() {
278-
String token = TokenCreationFixture.createToken();
279-
UUID signupId = UUID.randomUUID();
280-
TokenAwareDispatcher dispatcher = new TokenAwareDispatcher(token, CLIENT_ID, CLIENT_SECRET);
281-
dispatcher.setExpectedSignupId(signupId);
282-
mockServer.setDispatcher(dispatcher);
283-
SignupAssessment signupAssessment = client.getSignupAssessment(signupId);
284-
assertThat(signupAssessment)
285-
.extracting("id", "requestId", "riskAssessment", "deviceId")
286-
.containsExactly(
287-
UUID.fromString("5e76a7ca-577c-4f47-a752-9e1e0cee9e49"),
288-
UUID.fromString("8afc84a7-f1d4-488d-bd69-36d9a37168b7"),
289-
Assessment.LOW_RISK,
290-
"1df6d999-556d-42c3-8c63-357e5d08d95b");
291-
Map<String, Object> locationServices = new HashMap<>();
292-
locationServices.put("location_permission_enabled", true);
293-
locationServices.put("location_sensors_enabled", true);
294-
Map<String, Object> deviceIntegrity = new HashMap<>();
295-
deviceIntegrity.put("probable_root", false);
296-
deviceIntegrity.put("emulator", false);
297-
deviceIntegrity.put("gps_spoofing", false);
298-
deviceIntegrity.put("from_official_store", true);
299-
300-
Map<String, Object> expectedEvidence = new HashMap<>();
301-
expectedEvidence.put("device_model", "Moto Z2 Play");
302-
expectedEvidence.put("geocode_quality", "good");
303-
expectedEvidence.put("address_quality", "good");
304-
expectedEvidence.put("address_match", "street");
305-
expectedEvidence.put("location_events_near_address", 38);
306-
expectedEvidence.put("location_events_quantity", 288);
307-
expectedEvidence.put("location_services", locationServices);
308-
expectedEvidence.put("device_integrity", deviceIntegrity);
309-
310-
assertThat(signupAssessment.getEvidence()).containsExactlyInAnyOrderEntriesOf(expectedEvidence);
311-
312-
Reason expectedReason =
313-
Reason.builder()
314-
.code(ReasonCode.TRUSTED_LOCATION.getCode())
315-
.source(ReasonSource.LOCAL.getSource())
316-
.build();
317-
assertThat(signupAssessment.getReasons()).containsExactly(expectedReason);
318-
}
319-
320274
@ParameterizedTest
321275
@ValueSource(booleans = {true})
322276
@NullSource

src/test/java/com/incognia/api/clients/NetworkingClientTest.java

-23
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.incognia.fixtures.TestResponseBody;
1010
import java.io.IOException;
1111
import java.nio.charset.StandardCharsets;
12-
import java.util.Collections;
1312
import lombok.SneakyThrows;
1413
import okhttp3.OkHttpClient;
1514
import okhttp3.mockwebserver.Dispatcher;
@@ -63,28 +62,6 @@ public MockResponse dispatch(@NotNull RecordedRequest request) {
6362
assertThat(response.getName()).isEqualTo("my awesome name");
6463
}
6564

66-
@Test
67-
@DisplayName("should get given url")
68-
void testDoGet_whenSuccessfulResponse() throws IncogniaException {
69-
mockServer.setDispatcher(
70-
new Dispatcher() {
71-
@SneakyThrows
72-
@NotNull
73-
@Override
74-
public MockResponse dispatch(@NotNull RecordedRequest request) {
75-
if ("/v2/testurl".equals(request.getPath()) && "GET".equals(request.getMethod())) {
76-
return new MockResponse()
77-
.setResponseCode(200)
78-
.setBody("{\"name\": \"my awesome name\"}");
79-
}
80-
return new MockResponse().setResponseCode(404);
81-
}
82-
});
83-
TestResponseBody response =
84-
client.doGet("v2/testurl", TestResponseBody.class, Collections.emptyMap());
85-
assertThat(response.getName()).isEqualTo("my awesome name");
86-
}
87-
8865
@Test
8966
@DisplayName("should throw incognia api exception with correct fields")
9067
void testDoPost_whenInternalErrorResponse() {

src/test/java/com/incognia/api/clients/TokenAwareDispatcher.java

-12
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ public MockResponse dispatch(@NotNull RecordedRequest request) {
7070
&& "POST".equals(request.getMethod())) {
7171
return handlePostSignup(request);
7272
}
73-
if (("/api/v2/onboarding/signups/" + expectedSignupId).equals(request.getPath())
74-
&& "GET".equals(request.getMethod())) {
75-
return handleGetSignup(request);
76-
}
7773
if (("/api/v2/authentication/transactions?eval=true".equals(request.getPath())
7874
|| ("/api/v2/authentication/transactions".equals(request.getPath()))
7975
&& "POST".equals(request.getMethod()))) {
@@ -128,14 +124,6 @@ private MockResponse handlePostTransactionGivenFalseEval(RecordedRequest request
128124
return new MockResponse().setResponseCode(200).setBody(response);
129125
}
130126

131-
@NotNull
132-
private MockResponse handleGetSignup(@NotNull RecordedRequest request) {
133-
assertThat(request.getHeader("User-Agent")).isEqualTo(USER_AGENT_HEADER);
134-
assertThat(request.getHeader("Authorization")).isEqualTo("Bearer " + token);
135-
String response = ResourceUtils.getResourceFileAsString("get_onboarding_response.json");
136-
return new MockResponse().setResponseCode(200).setBody(response);
137-
}
138-
139127
@NotNull
140128
private MockResponse handlePostSignup(@NotNull RecordedRequest request)
141129
throws java.io.IOException {

src/test/java/com/incognia/api/clients/TokenAwareNetworkingClientTest.java

-13
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,6 @@ void testDoPost_whenNoTokenExistsYetAndCredentialsAreValid() throws IncogniaExce
5050
assertThat(dispatcher.getTokenRequestCount()).isEqualTo(1);
5151
}
5252

53-
@Test
54-
@DisplayName("should call the api with the same valid token")
55-
void testDoGet_whenNoTokenExistsYetAndCredentialsAreValid() throws IncogniaException {
56-
String token = TokenCreationFixture.createToken();
57-
TokenAwareDispatcher dispatcher = new TokenAwareDispatcher(token, CLIENT_ID, CLIENT_SECRET);
58-
mockServer.setDispatcher(dispatcher);
59-
for (int i = 0; i < 2; i++) {
60-
TestResponseBody testResponseBody = client.doGet("api/v2/onboarding", TestResponseBody.class);
61-
assertThat(testResponseBody.getName()).isEqualTo("my awesome name");
62-
}
63-
assertThat(dispatcher.getTokenRequestCount()).isEqualTo(1);
64-
}
65-
6653
@Test
6754
@DisplayName("should get a 401 error")
6855
void testDoPost_whenNoTokenExistsYetAndCredentialsAreInvalid() {

src/test/resources/get_onboarding_response.json

-30
This file was deleted.

0 commit comments

Comments
 (0)