Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
java-version: ${{ matrix.java }}
distribution: 'adopt'
- name: Cache Gradle packages
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand Down
26 changes: 18 additions & 8 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.4.0</version>
<version>3.11.0</version>
</dependency>
```
```xml
<dependency>
<groupId>com.incognia</groupId>
<artifactId>incognia-api-client-shaded</artifactId>
<version>3.4.0</version>
<version>3.11.0</version>
</dependency>
```

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

Expand All @@ -69,7 +69,9 @@ Before calling the API methods, you need to create an instance of the `IncogniaA
IncogniaAPI api = IncogniaAPI.init("your-client-id", "your-client-secret");
```

This will create a singleton instance of the IncogniaAPI class, which will handle token renewal automatically. You should reuse this instance throughout your application.
This will create a instance of the IncogniaAPI class, which will handle token renewal automatically. You should reuse this instance throughout your application.

The IncogniaAPI class implements the Multiton design pattern by maintaining a single instance per unique (client id, client secret) pair.

The library also allow the users to configure the call timeout themselves. This will give them more control over the expected time response. This can be done by calling the init passing the CustomOptions object as a parameter.

Expand All @@ -78,13 +80,21 @@ The library also allow the users to configure the call timeout themselves. This
IncogniaAPI api = IncogniaAPI.init(
"your-client-id",
"your-client-secret",
CustomOptions.builder().timeoutMillis(2000).build()
CustomOptions.builder()
.timeoutMillis(2000L)
.keepAliveSeconds(3000)
.maxConnections(5)
.build()
);
```

If no parameter is passed the library will use the default timeout of 10 seconds.
If no parameter is passed the library will use the default timeout of 10 seconds, 5 minutes of keep alive and 5 max connections.

After calling `init`, you can get the created instance by simply calling `IncogniaAPI.instance()` if only one instance has been created,
or by calling `IncogniaAPI.instance("your-client-id", "your-client-secret")` to specify which instance should be returned.

After calling `init`, you can get the singleton instance simply calling `IncogniaAPI.instance()`.
If you need to use more than one `clientId`/`clientSecret`, it is recommended to use **only** the
`IncogniaAPI.instance("your-client-id", "your-client-secret")` to get already created instances.

#### Dependency Injection integration examples

Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "com.incognia"
version = "3.4.0"
version = "3.11.0"

task createProjectVersionFile {
def projectVersionDir = "$projectDir/src/main/java/com/incognia/api"
Expand Down Expand Up @@ -47,8 +47,9 @@ dependencies {
testImplementation 'com.auth0:java-jwt:4.4.0'
testImplementation 'commons-io:commons-io:2.16.1'
testImplementation 'org.assertj:assertj-core:3.26.0'
testImplementation 'org.mockito:mockito-core:5.12.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.12.0'
testImplementation 'org.mockito:mockito-core:4.11.0'
testImplementation 'org.mockito:mockito-inline:4.11.0'
testImplementation 'org.mockito:mockito-junit-jupiter:4.11.0'
testImplementation "com.squareup.okhttp3:mockwebserver"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testImplementation "org.junit.jupiter:junit-jupiter-params:5.10.2"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading