diff --git a/data/news/.gitignore b/data/news/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/data/news/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/data/news/build.gradle.kts b/data/news/build.gradle.kts new file mode 100644 index 0000000000..86796fcedd --- /dev/null +++ b/data/news/build.gradle.kts @@ -0,0 +1,53 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) + id("configuration") +} + +android { + namespace = "com.tangem.data.news" +} + +tasks.withType().configureEach { + useJUnitPlatform() +} + +dependencies { + // region Project - Core + implementation(projects.core.datasource) + api(projects.core.utils) + // endregion + + // region Project - Data + implementation(projects.data.common) + // endregion + + // region Project - Domain + implementation(projects.domain.news) + // endregion + + // region Project - Libs + implementation(projects.libs.blockchainSdk) + // endregion + + // region DI + implementation(deps.hilt.android) + kapt(deps.hilt.kapt) + // endregion + + // region Other libraries + implementation(deps.androidx.datastore) + implementation(deps.moshi.kotlin) + implementation(deps.timber) + // endregion + + // region Tests + testImplementation(deps.test.coroutine) + testImplementation(deps.test.junit5) + testRuntimeOnly(deps.test.junit5.engine) + testImplementation(deps.test.mockk) + testImplementation(deps.test.truth) + testImplementation(projects.common.test) + // endregion +} \ No newline at end of file diff --git a/data/news/src/main/java/com/tangem/data/news/di/NewsDataModule.kt b/data/news/src/main/java/com/tangem/data/news/di/NewsDataModule.kt new file mode 100644 index 0000000000..4d1f74a2d8 --- /dev/null +++ b/data/news/src/main/java/com/tangem/data/news/di/NewsDataModule.kt @@ -0,0 +1,20 @@ +package com.tangem.data.news.di + +import com.tangem.data.news.repository.DefaultNewsRepository +import com.tangem.domain.news.repository.NewsRepository +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal object NewsDataModule { + + @Singleton + @Provides + fun providesQuotesRepository(): NewsRepository { + return DefaultNewsRepository() + } +} \ No newline at end of file diff --git a/data/news/src/main/java/com/tangem/data/news/repository/DefaultNewsRepository.kt b/data/news/src/main/java/com/tangem/data/news/repository/DefaultNewsRepository.kt new file mode 100644 index 0000000000..259934d383 --- /dev/null +++ b/data/news/src/main/java/com/tangem/data/news/repository/DefaultNewsRepository.kt @@ -0,0 +1,10 @@ +package com.tangem.data.news.repository + +import com.tangem.domain.news.repository.NewsRepository + +/** + * Default implementation of [NewsRepository] + * +[REDACTED_AUTHOR] + */ +internal class DefaultNewsRepository : NewsRepository \ No newline at end of file diff --git a/domain/news/.gitignore b/domain/news/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/domain/news/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/news/build.gradle.kts b/domain/news/build.gradle.kts new file mode 100644 index 0000000000..7bc8c1d8dc --- /dev/null +++ b/domain/news/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + alias(deps.plugins.kotlin.jvm) + alias(deps.plugins.kotlin.serialization) + id("configuration") +} + +dependencies { + api(projects.domain.core) + api(projects.domain.models) + implementation(deps.kotlin.serialization) +} \ No newline at end of file diff --git a/domain/news/src/main/java/com/tangem/domain/news/models/ArticleCategory.kt b/domain/news/src/main/java/com/tangem/domain/news/models/ArticleCategory.kt new file mode 100644 index 0000000000..c5876b9e37 --- /dev/null +++ b/domain/news/src/main/java/com/tangem/domain/news/models/ArticleCategory.kt @@ -0,0 +1,16 @@ +package com.tangem.domain.news.models + +import kotlinx.serialization.Serializable + +/** + * Represents an article category. + * +[REDACTED_AUTHOR] + * @param id - unique identifier of the category + * @param name - category name + */ +@Serializable +data class ArticleCategory( + val id: Int, + val name: String, +) \ No newline at end of file diff --git a/domain/news/src/main/java/com/tangem/domain/news/models/DetailedArticle.kt b/domain/news/src/main/java/com/tangem/domain/news/models/DetailedArticle.kt new file mode 100644 index 0000000000..2086d850df --- /dev/null +++ b/domain/news/src/main/java/com/tangem/domain/news/models/DetailedArticle.kt @@ -0,0 +1,36 @@ +package com.tangem.domain.news.models + +import kotlinx.serialization.Serializable + +/** + * Represents an detailed article via news. + * +[REDACTED_AUTHOR] + * @param id - unique identifier of the article + + * @param score - score of article (ex. 6.9) + * @param locale - language of the article + * @param isTrending - flag for trending article + * @param categories - list of included categories + * @param relatedTokens - tokens, which were mentioned in article + * @param title - article title + * @param newsUrl - link for article to share + * @param shortContent - short description + * @param content - main text of the article + * @param originalArticles - original articles, which were base to build detailed article. + */ +@Serializable +data class DetailedArticle( + val id: Int, + val createdAt: String, + val score: Float, + val locale: String, + val isTrending: Boolean, + val categories: List, + val relatedTokens: List, + val title: String, + val newsUrl: String, + val shortContent: String, + val content: String, + val originalArticles: List, +) \ No newline at end of file diff --git a/domain/news/src/main/java/com/tangem/domain/news/models/OriginalArticle.kt b/domain/news/src/main/java/com/tangem/domain/news/models/OriginalArticle.kt new file mode 100644 index 0000000000..700dfe5978 --- /dev/null +++ b/domain/news/src/main/java/com/tangem/domain/news/models/OriginalArticle.kt @@ -0,0 +1,26 @@ +package com.tangem.domain.news.models + +import kotlinx.serialization.Serializable + +/** + * Represents an original article, which was base to build detailed article. + * +[REDACTED_AUTHOR] + * @param id - unique identifier of the article + * @param title - article title + * @param sourceName - name of original article source + * @param locale - language of the article + * @param publishedAt - date of article publishing + * @param url - link to source of original article + * @param imageUrl - image from source of original article + */ +@Serializable +data class OriginalArticle( + val id: Int, + val title: String, + val sourceName: String, + val locale: String, + val publishedAt: String, + val url: String, + val imageUrl: String?, +) \ No newline at end of file diff --git a/domain/news/src/main/java/com/tangem/domain/news/models/RelatedToken.kt b/domain/news/src/main/java/com/tangem/domain/news/models/RelatedToken.kt new file mode 100644 index 0000000000..4e796c9840 --- /dev/null +++ b/domain/news/src/main/java/com/tangem/domain/news/models/RelatedToken.kt @@ -0,0 +1,18 @@ +package com.tangem.domain.news.models + +import kotlinx.serialization.Serializable + +/** + * Represents related tokens for article. + * +[REDACTED_AUTHOR] + * @param id - unique identifier of the token + * @param symbol - token symbol(BTC, ETH etc.) + * @param name - token name + */ +@Serializable +data class RelatedToken( + val id: String, + val symbol: String, + val name: String, +) \ No newline at end of file diff --git a/domain/news/src/main/java/com/tangem/domain/news/models/ShortArticle.kt b/domain/news/src/main/java/com/tangem/domain/news/models/ShortArticle.kt new file mode 100644 index 0000000000..8ec22d6474 --- /dev/null +++ b/domain/news/src/main/java/com/tangem/domain/news/models/ShortArticle.kt @@ -0,0 +1,30 @@ +package com.tangem.domain.news.models + +import kotlinx.serialization.Serializable + +/** + * Represents an short article info in news. + * +[REDACTED_AUTHOR] + * @param id - unique identifier of the article + + * @param score - score of article (ex. 6.9) + * @param locale - language of the article + * @param isTrending - flag for trending article + * @param categories - list of included categories + * @param relatedTokens - tokens, which were mentioned in article + * @param title - article title + * @param newsUrl - link for article to share + */ +@Serializable +data class ShortArticle( + val id: Int, + val createdAt: String, + val score: Float, + val locale: String, + val categories: List, + val relatedTokens: List, + val isTrending: Boolean, + val title: String, + val newsUrl: String, +) \ No newline at end of file diff --git a/domain/news/src/main/java/com/tangem/domain/news/repository/NewsRepository.kt b/domain/news/src/main/java/com/tangem/domain/news/repository/NewsRepository.kt new file mode 100644 index 0000000000..07e81c249a --- /dev/null +++ b/domain/news/src/main/java/com/tangem/domain/news/repository/NewsRepository.kt @@ -0,0 +1,8 @@ +package com.tangem.domain.news.repository + +/** + * News repository + * +[REDACTED_AUTHOR] + */ +interface NewsRepository \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 5b286caeaf..7703f86c1f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -362,6 +362,7 @@ include(":domain:wallet-manager") include(":domain:wallet-manager:models") include(":domain:yield-supply") include(":domain:yield-supply:models") +include(":domain:news") // endregion Domain modules // region Data modules @@ -396,4 +397,5 @@ include(":data:swap") include(":data:express") include(":data:wallet-manager") include(":data:yield-supply") +include(":data:news") // endregion Data modules \ No newline at end of file