Skip to content

Commit a535ee4

Browse files
committed
docs: Add AI overview documentation for Kotlin SDK
1 parent 6c96c2a commit a535ee4

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

ai.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# AI Overview: Kotlin SDK
2+
3+
## 1. High Level Overview
4+
The Kotlin SDK is an SDK that provides a way to interact with the CtrlHub APIs using Kotlin.
5+
6+
## 2. Overview of Technologies
7+
- **Kotlin**
8+
- **Gradle**: Build tool for Kotlin projects.
9+
- **Ktor**: Asynchronous HTTP client for making API requests.
10+
11+
This is not a KMP project.
12+
13+
## 3. Project Structure
14+
- `src/main/kotlin`: Contains the main Kotlin code for the SDK.
15+
- `src/test/kotlin`: Contains the test code for the SDK.
16+
- `build.gradle.kts`: Gradle build file for the project.
17+
- `settings.gradle.kts`: Gradle settings file for the project.
18+
19+
## 4. Coding Conventions
20+
- Use Kotlin's idiomatic style.
21+
- Use Routers for organising API "domains". A domain is a particular resource that the API supports. Example: `projects`.
22+
- Use `suspend` functions for API calls to allow for asynchronous programming.
23+
- Use `data class` for models to represent API responses.
24+
- API responses are annotated using the `jasminb.jsonapi-converter` library for JSONAPI serialization/deserialization.
25+
- IDs are strings, not integers.
26+
- Use `@JvmField` for fields that need to be accessed from Java code.
27+
- Responses that reference a collection use `java.util.List` instead of Kotlin's `List` to ensure compatibility with Java and the JSON API library.
28+
- Routers register an extension function on the `Api` class to provide a convenient way to access the API endpoints.
29+
30+
## Git Commits
31+
- Use conventional commit messages.
32+
- First line of the commit should be 72 characters or less.
33+
- Provide a description of the changes in the commit body if necessary.
34+
35+
## 7. Examples
36+
Given the following JSON snippet:
37+
```json
38+
{
39+
"data": {
40+
"type": "projects",
41+
"id": "123",
42+
"attributes": {
43+
"name": "My Project"
44+
}
45+
}
46+
}
47+
```
48+
49+
You can create a data class to represent this response:
50+
51+
```kotlin
52+
import com.fasterxml.jackson.annotation.JsonCreator
53+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
54+
import com.fasterxml.jackson.annotation.JsonProperty
55+
import com.github.jasminb.jsonapi.StringIdHandler
56+
import com.github.jasminb.jsonapi.annotations.Id
57+
import com.github.jasminb.jsonapi.annotations.Relationship
58+
import com.github.jasminb.jsonapi.annotations.Type
59+
60+
@Type("projects")
61+
@JsonIgnoreProperties(ignoreUnknown = true)
62+
data class Project @JsonCreator constructor(
63+
@Id(StringIdHandler::class) var id: String = "",
64+
@JsonProperty("name") var name: String = ""
65+
)
66+
```

0 commit comments

Comments
 (0)