Skip to content

Commit 7837e65

Browse files
initial project with api module
Signed-off-by: Arnav Gupta <[email protected]>
0 parents  commit 7837e65

File tree

83 files changed

+1729
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1729
-0
lines changed

Diff for: .gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

Diff for: .idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/codeStyles/Project.xml

+138
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/codeStyles/codeStyleConfig.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/compiler.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/google-java-format.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/gradle.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/inspectionProfiles/Project_Default.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/jarRepositories.xml

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/misc.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/render.experimental.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: api/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: api/build.gradle

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
id 'java-library'
3+
id 'kotlin'
4+
id 'kotlin-kapt'
5+
}
6+
7+
java {
8+
sourceCompatibility = JavaVersion.VERSION_11
9+
targetCompatibility = JavaVersion.VERSION_11
10+
}
11+
12+
dependencies {
13+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
14+
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
15+
implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"
16+
implementation "com.squareup.moshi:moshi:$moshi_version"
17+
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
18+
19+
// test
20+
testImplementation 'junit:junit:4.13.1'
21+
22+
}

Diff for: api/src/main/java/io/realworld/api/ConduitClient.kt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.realworld.api
2+
3+
import io.realworld.api.services.ConduitAPI
4+
import retrofit2.Retrofit
5+
import retrofit2.converter.moshi.MoshiConverterFactory
6+
7+
class ConduitClient {
8+
9+
val retrofit = Retrofit.Builder()
10+
.baseUrl("https://conduit.productionready.io/api/")
11+
.addConverterFactory(MoshiConverterFactory.create())
12+
.build()
13+
14+
val api = retrofit.create(ConduitAPI::class.java)
15+
16+
}

Diff for: api/src/main/java/io/realworld/api/models/Article.kt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.realworld.api.models
2+
3+
4+
import com.squareup.moshi.Json
5+
import com.squareup.moshi.JsonClass
6+
7+
@JsonClass(generateAdapter = true)
8+
data class Article(
9+
@Json(name = "author")
10+
val author: Profile,
11+
@Json(name = "body")
12+
val body: String,
13+
@Json(name = "createdAt")
14+
val createdAt: String,
15+
@Json(name = "description")
16+
val description: String,
17+
@Json(name = "favorited")
18+
val favorited: Boolean,
19+
@Json(name = "favoritesCount")
20+
val favoritesCount: Int,
21+
@Json(name = "slug")
22+
val slug: String,
23+
@Json(name = "tagList")
24+
val tagList: List<String>,
25+
@Json(name = "title")
26+
val title: String,
27+
@Json(name = "updatedAt")
28+
val updatedAt: String
29+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.realworld.api.models
2+
3+
4+
import com.squareup.moshi.Json
5+
import com.squareup.moshi.JsonClass
6+
7+
@JsonClass(generateAdapter = true)
8+
data class ArticleResponse(
9+
@Json(name = "article")
10+
val article: Article
11+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.realworld.api.models
2+
3+
4+
import com.squareup.moshi.Json
5+
import com.squareup.moshi.JsonClass
6+
7+
@JsonClass(generateAdapter = true)
8+
data class ArticlesResponse(
9+
@Json(name = "articles")
10+
val articles: List<Article>,
11+
@Json(name = "articlesCount")
12+
val articlesCount: Int
13+
)

Diff for: api/src/main/java/io/realworld/api/models/Comment.kt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package io.realworld.api.models
2+
3+
4+
import com.squareup.moshi.Json
5+
import com.squareup.moshi.JsonClass
6+
7+
@JsonClass(generateAdapter = true)
8+
data class Comment(
9+
@Json(name = "author")
10+
val author: Profile,
11+
@Json(name = "body")
12+
val body: String,
13+
@Json(name = "createdAt")
14+
val createdAt: String,
15+
@Json(name = "id")
16+
val id: Int,
17+
@Json(name = "updatedAt")
18+
val updatedAt: String
19+
)

0 commit comments

Comments
 (0)