simkl-client

API client for https://simkl.com show/movie progress tracker.

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.github.srgsf
ArtifactId

ArtifactId

simkl-client
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

simkl-client
API client for https://simkl.com show/movie progress tracker.
Project URL

Project URL

https://github.com/srgsf/simkl-client
Source Code Management

Source Code Management

https://github.com/srgsf/simkl-client

Download simkl-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.srgsf/simkl-client/ -->
<dependency>
    <groupId>com.github.srgsf</groupId>
    <artifactId>simkl-client</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.srgsf/simkl-client/
implementation 'com.github.srgsf:simkl-client:0.1'
// https://jarcasting.com/artifacts/com.github.srgsf/simkl-client/
implementation ("com.github.srgsf:simkl-client:0.1")
'com.github.srgsf:simkl-client:jar:0.1'
<dependency org="com.github.srgsf" name="simkl-client" rev="0.1">
  <artifact name="simkl-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.srgsf', module='simkl-client', version='0.1')
)
libraryDependencies += "com.github.srgsf" % "simkl-client" % "0.1"
[com.github.srgsf/simkl-client "0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
com.squareup.retrofit2 : retrofit jar 2.9.0
com.squareup.retrofit2 : converter-moshi jar 2.9.0

test (3)

Group / Artifact Type Version
com.squareup.okhttp3 : logging-interceptor jar 3.12.0
com.squareup.okhttp3 : mockwebserver jar 3.12.0
org.junit.jupiter : junit-jupiter-engine jar 5.5.2

Project Modules

There are no modules declared in this project.

simkl-client

Tests License maven
A Java wrapper around https://simkl.com API using Retrofit2 and Moshi

Pull requests are welcome.

Usage

Add the following dependency to your Gradle project:

implementation 'com.github.srgsf:simkl-client:0.1'

Or for Maven:

<dependency>
  <groupId>com.github.srgsf</groupId>
  <artifactId>simkl-client</artifactId>
  <version>0.1</version>
</dependency>

Authorization

Some of SIMKL API methods can only be accessed via OAuth 2.0.

Current version supports Web Application flow and Limited Device flow. See SimklAuthClient for details.

Example of Web Application flow token request.

            HttpUrl url = SimklAuthClient.authorizationRequestUrl("<clientId>", 
                    "<redirectUrl>", 
                    "1234");
            
            // let user to sign in using url, then use <code> to get access token
            
            SimklAuthClient authClient = new SimklAuthClient.Builder()
                    .clientCredentials("<clientId>", "<clientSecret>", "<redirectUrl>")
                    .build();
            
            AccessToken token = authClient.accessToken(SimklAuthClient.GrantType.authorization_code, "<code>")
                    .body();

Example

Use like any other retrofit2 based service.
Optionally you can share OkHttp client and Retrofit instances to keep single request pooling, disk cache, routing logic, etc.

        Simkl simkl = new Simkl.Builder()
                .clientId("<clientId>")
                .tokenProvider(() -> "<token>")
                .build();
        Users usersApi = simkl.users();
        usersApi.info().enqueue(new Callback<UserInfo>() {
            @Override
            public void onResponse(Call<UserInfo> call, Response<UserInfo> response) {
                if(response.isSuccessful()) {
                    UserInfo info = response.body();
                    //use info
                }
            }

            @Override
            public void onFailure(Call<UserInfo> call, Throwable t) {
                //handle
            }
        });

See test cases in src/test/ for more examples.

Known API Issues

Versions

Version
0.1