Merge 2d761144e4
into e846078f9d
commit
ca2538d897
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.network.api
|
||||
|
||||
import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList
|
||||
import com.google.samples.apps.nowinandroid.core.network.model.NetworkNewsResource
|
||||
import com.google.samples.apps.nowinandroid.core.network.retrofit.NetworkResponse
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Query
|
||||
|
||||
/**
|
||||
* Retrofit API declaration for News Resource API
|
||||
*/
|
||||
internal interface NewsResourceApi {
|
||||
@GET(value = "newsresources")
|
||||
suspend fun getNewsResources(
|
||||
@Query("id") ids: List<String>?,
|
||||
): NetworkResponse<List<NetworkNewsResource>>
|
||||
|
||||
@GET(value = "changelists/newsresources")
|
||||
suspend fun getNewsResourcesChangeList(
|
||||
@Query("after") after: Int?,
|
||||
): List<NetworkChangeList>
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.network.api
|
||||
|
||||
import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList
|
||||
import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic
|
||||
import com.google.samples.apps.nowinandroid.core.network.retrofit.NetworkResponse
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Query
|
||||
|
||||
/**
|
||||
* Retrofit API declaration for Topic API
|
||||
*/
|
||||
internal interface TopicApi {
|
||||
@GET(value = "topics")
|
||||
suspend fun getTopics(
|
||||
@Query("id") ids: List<String>?,
|
||||
): NetworkResponse<List<NetworkTopic>>
|
||||
|
||||
@GET(value = "changelists/topics")
|
||||
suspend fun getTopicChangeList(
|
||||
@Query("after") after: Int?,
|
||||
): List<NetworkChangeList>
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.samples.apps.nowinandroid.core.network.di
|
||||
|
||||
import androidx.tracing.trace
|
||||
import com.google.samples.apps.nowinandroid.core.network.api.NewsResourceApi
|
||||
import com.google.samples.apps.nowinandroid.core.network.api.TopicApi
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import retrofit2.Retrofit
|
||||
import javax.inject.Singleton
|
||||
import kotlin.jvm.java
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal object ApiModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
internal fun providesTopicApi(retrofit: Retrofit): TopicApi {
|
||||
trace("RetrofitNiaNetwork") {
|
||||
return retrofit.create(TopicApi::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
internal fun providesNewsResourceApi(retrofit: Retrofit): NewsResourceApi {
|
||||
trace("RetrofitNiaNetwork") {
|
||||
return retrofit.create(NewsResourceApi::class.java)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue