Skip to content

Commit 9e37a47

Browse files
Initial Commit
0 parents  commit 9e37a47

22 files changed

+829
-0
lines changed

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
.idea/discord.xml
12+
.idea/encodings.xml
13+
*.iws
14+
*.iml
15+
*.ipr
16+
17+
### Eclipse ###
18+
.apt_generated
19+
.classpath
20+
.factorypath
21+
.project
22+
.settings
23+
.springBeans
24+
.sts4-cache
25+
26+
### NetBeans ###
27+
/nbproject/private/
28+
/nbbuild/
29+
/dist/
30+
/nbdist/
31+
/.nb-gradle/
32+
build/
33+
!**/src/main/**/build/
34+
!**/src/test/**/build/
35+
36+
### VS Code ###
37+
.vscode/
38+
39+
### Mac OS ###
40+
.DS_Store

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
2+
<p align="center" dir="auto">
3+
<a href="https://omdbapi.com" rel="nofollow">
4+
<img src="https://i.imgur.com/2oq2xSh.png" width="200" alt="OMDb API Icon" style="max-width: 100%;"/>
5+
</a>
6+
</p>
7+
8+
<h1 align="center"><a href="https://omdbapi.com">OMDbAPI.com</a> Client for Kotlin</h1>
9+
10+
## Installation
11+
12+
To begin, import the library using jitpack.io.
13+
14+
You can include jitpack in your `pom.xml` by adding the following jitpack repository:
15+
16+
```xml
17+
<repository>
18+
<id>jitpack.io</id>
19+
<url>https://www.jitpack.io</url>
20+
</repository>
21+
```
22+
23+
Then add this `omdb-kotlin` dependency to your `pom.xml` project!
24+
25+
```xml
26+
<dependency>
27+
<groupId>com.github.official-wizard</groupId>
28+
<artifactId>omdb-kotlin</artifactId>
29+
<version>1.0.0</version>
30+
</dependency>
31+
```
32+
33+
## Usage
34+
35+
### Basic Usage
36+
37+
```kotlin
38+
val credentials = Credentials("<web api key>")
39+
val api: OmdbInterface = OmdbClient(credentials).api
40+
41+
// access the api interface in `api`
42+
```
43+
44+
#### Search
45+
46+
<details>
47+
<summary>Search Title (or imdb ID)</summary>
48+
<br>
49+
50+
> A call to this function will retrieve a single result for the provided title or Imdb ID
51+
52+
**Available Parameters**
53+
54+
> NOTE: Although `Title` and `ImdbId` are optional, at least 1 of them is required!
55+
56+
| Name | Type | Description | Example | OPTIONAL |
57+
|:--------------|:----------|:-------------------------------------------------------------------|:----------------|----------|
58+
| title | String | The name of the film you'd like to search for. | Demons | yes |
59+
| imdbId | String | The imdb ID for the film you'd like to search for. | tt0089013 | yes |
60+
| type | QueryType | The type of film you'd like to search for (Movie, Series, Episode) | QueryType.movie | yes |
61+
| yearOfRelease | String | The year the film was released | 1985 | yes |
62+
| plot | Plot | Short or full plot. | Plot.short | yes |
63+
64+
**Example**
65+
```kotlin
66+
val credentials = Credentials("<web api key>")
67+
val api: OmdbInterface = OmdbClient(credentials).api
68+
69+
val response: NetworkResponse<Search.Response, Error.Response> = api.searchTitle(
70+
title = "Demons"
71+
)
72+
73+
if (response is NetworkResponse.Success) {
74+
// handle the data
75+
val searchResult: Search.Response = response.body
76+
77+
} else if (response is NetworkResponse.Error) {
78+
// if the server returns an error it be found here
79+
val errorResponse: Error.Response? = response.body
80+
81+
// if the api (locally) had an internal error, it'll be found here
82+
val internalError: Throwable? = response.error
83+
}
84+
```
85+
86+
</details>
87+
88+
<details>
89+
<summary>Search List</summary>
90+
<br>
91+
92+
> A call to this function will retrieve a list of results for the provided title
93+
94+
**Available Parameters**
95+
96+
| Name | Type | Description | Example | OPTIONAL |
97+
|:--------------|:----------|:-------------------------------------------------------------------|:----------------|----------|
98+
| title | String | The name of the film you'd like to search for. | Demons | no |
99+
| type | QueryType | The type of film you'd like to search for (Movie, Series, Episode) | QueryType.movie | yes |
100+
| yearOfRelease | String | The year the film was released | 1985 | yes |
101+
| page | Int | The page number to search through. | Plot.short | yes |
102+
103+
**Example**
104+
```kotlin
105+
val credentials = Credentials("<web api key>")
106+
val api: OmdbInterface = OmdbClient(credentials).api
107+
108+
val response: NetworkResponse<SearchList.Response, Error.Response> = api.searchList(
109+
title = "Demons"
110+
)
111+
112+
if (response is NetworkResponse.Success) {
113+
// handle the data
114+
val searchResult: SearchList.Response = response.body
115+
116+
} else if (response is NetworkResponse.Error) {
117+
// if the server returns an error it be found here
118+
val errorResponse: Error.Response? = response.body
119+
120+
// if the api (locally) had an internal error, it'll be found here
121+
val internalError: Throwable? = response.error
122+
}
123+
```
124+
125+
</details>

pom.xml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.omdbapi</groupId>
8+
<artifactId>omdb-kotlin</artifactId>
9+
<version>1.0.0</version>
10+
11+
<dependencyManagement>
12+
<dependencies>
13+
<dependency>
14+
<groupId>org.junit</groupId>
15+
<artifactId>junit-bom</artifactId>
16+
<version>5.10.2</version>
17+
<type>pom</type>
18+
<scope>import</scope>
19+
</dependency>
20+
</dependencies>
21+
</dependencyManagement>
22+
23+
<properties>
24+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25+
<kotlin.code.style>official</kotlin.code.style>
26+
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
27+
</properties>
28+
29+
<repositories>
30+
<repository>
31+
<id>jitpack.io</id>
32+
<url>https://jitpack.io</url>
33+
</repository>
34+
35+
<repository>
36+
<id>mavenCentral</id>
37+
<url>https://repo1.maven.org/maven2/</url>
38+
</repository>
39+
</repositories>
40+
41+
<build>
42+
<sourceDirectory>src/main/kotlin</sourceDirectory>
43+
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
44+
<plugins>
45+
<plugin>
46+
<groupId>org.jetbrains.kotlin</groupId>
47+
<artifactId>kotlin-maven-plugin</artifactId>
48+
<version>1.9.22</version>
49+
<executions>
50+
<execution>
51+
<id>compile</id>
52+
<phase>compile</phase>
53+
<goals>
54+
<goal>compile</goal>
55+
</goals>
56+
</execution>
57+
<execution>
58+
<id>test-compile</id>
59+
<phase>test-compile</phase>
60+
<goals>
61+
<goal>test-compile</goal>
62+
</goals>
63+
</execution>
64+
</executions>
65+
</plugin>
66+
<plugin>
67+
<artifactId>maven-surefire-plugin</artifactId>
68+
<version>2.22.2</version>
69+
</plugin>
70+
<plugin>
71+
<artifactId>maven-failsafe-plugin</artifactId>
72+
<version>2.22.2</version>
73+
</plugin>
74+
<plugin>
75+
<groupId>org.codehaus.mojo</groupId>
76+
<artifactId>exec-maven-plugin</artifactId>
77+
<version>1.6.0</version>
78+
<configuration>
79+
<mainClass>MainKt</mainClass>
80+
</configuration>
81+
</plugin>
82+
</plugins>
83+
</build>
84+
85+
<dependencies>
86+
<dependency>
87+
<groupId>org.jetbrains.kotlin</groupId>
88+
<artifactId>kotlin-test-junit5</artifactId>
89+
<version>1.9.22</version>
90+
<scope>test</scope>
91+
</dependency>
92+
93+
<dependency>
94+
<groupId>org.junit.jupiter</groupId>
95+
<artifactId>junit-jupiter-engine</artifactId>
96+
<scope>test</scope>
97+
</dependency>
98+
99+
<dependency>
100+
<groupId>org.jetbrains.kotlin</groupId>
101+
<artifactId>kotlin-stdlib</artifactId>
102+
<version>1.9.22</version>
103+
</dependency>
104+
105+
<!-- RetroFit Dependencies -->
106+
<dependency>
107+
<groupId>com.squareup.okhttp3</groupId>
108+
<artifactId>logging-interceptor</artifactId>
109+
<version>4.12.0</version>
110+
</dependency>
111+
112+
<dependency>
113+
<groupId>com.github.haroldadmin</groupId>
114+
<artifactId>NetworkResponseAdapter</artifactId>
115+
<version>5.0.0</version>
116+
</dependency>
117+
118+
<dependency>
119+
<groupId>com.squareup.retrofit2</groupId>
120+
<artifactId>retrofit</artifactId>
121+
<version>2.9.0</version>
122+
</dependency>
123+
124+
<dependency>
125+
<groupId>com.squareup.retrofit2</groupId>
126+
<artifactId>converter-gson</artifactId>
127+
<version>2.11.0</version>
128+
</dependency>
129+
130+
<dependency>
131+
<groupId>co.infinum</groupId>
132+
<artifactId>retromock</artifactId>
133+
<version>1.1.1</version>
134+
</dependency>
135+
</dependencies>
136+
137+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.omdbapi.api
2+
3+
import com.omdbapi.api.core.Credentials
4+
import com.omdbapi.api.core.CoreClient
5+
6+
class OMDbClient(credentials: Credentials, debugging: Boolean = false)
7+
: CoreClient(credentials, "https://www.omdbapi.com/", debugging) {
8+
9+
// the API interface for the client
10+
val api: OMDbInterface = omdbClient.create(OMDbInterface::class.java)
11+
}

0 commit comments

Comments
 (0)