Skip to content

Commit f97c02d

Browse files
frettclaude
andcommitted
Introduce CdnApi and configure CDN base URL per flavor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a6027f8 commit f97c02d

5 files changed

Lines changed: 28 additions & 2 deletions

File tree

app/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ android {
4646
applicationIdSuffix = ".stage"
4747

4848
buildConfigField("String", "MOBILE_CONTENT_API", "\"$URI_MOBILE_CONTENT_API_STAGE\"")
49+
buildConfigField("String", "MOBILE_CONTENT_CDN", "\"https://mobilecontent-stage.cru.org\"")
4950

5051
// Facebook
5152
resValue("string", "facebook_app_id", "448969905944197")
@@ -61,6 +62,7 @@ android {
6162
}
6263
named("production") {
6364
buildConfigField("String", "MOBILE_CONTENT_API", "\"$URI_MOBILE_CONTENT_API_PRODUCTION\"")
65+
buildConfigField("String", "MOBILE_CONTENT_CDN", "\"https://mobilecontent.cru.org\"")
6466

6567
// Facebook
6668
resValue("string", "facebook_app_id", "2236701616451487")

app/src/main/kotlin/org/cru/godtools/dagger/ConfigModule.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.cru.godtools.api.ApiConfig
1212
object ConfigModule {
1313
@get:Provides
1414
val apiConfig = ApiConfig(
15-
mobileContentApiUrl = BuildConfig.MOBILE_CONTENT_API
15+
mobileContentApiUrl = BuildConfig.MOBILE_CONTENT_API,
16+
cdnUrl = BuildConfig.MOBILE_CONTENT_CDN
1617
)
1718
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.cru.godtools.api
22

33
data class ApiConfig(
4-
val mobileContentApiUrl: String
4+
val mobileContentApiUrl: String,
5+
val cdnUrl: String,
56
)

library/api/src/main/kotlin/org/cru/godtools/api/ApiModule.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,13 @@ object ApiModule {
196196
.callFactory(okhttp)
197197
.build().create<CampaignFormsApi>()
198198
// endregion Adobe APIs
199+
200+
// region CDN APIs
201+
@Provides
202+
@Reusable
203+
fun cdnApi(okhttp: OkHttpClient, apiConfig: ApiConfig): CdnApi = Retrofit.Builder().baseUrl(apiConfig.cdnUrl)
204+
.callFactory(okhttp)
205+
.build()
206+
.create()
207+
// endregion CDN APIs
199208
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.cru.godtools.api
2+
3+
import okhttp3.ResponseBody
4+
import retrofit2.Response
5+
import retrofit2.http.GET
6+
import retrofit2.http.Path
7+
import retrofit2.http.Streaming
8+
9+
interface CdnApi {
10+
@Streaming
11+
@GET("translations/files/{filename}")
12+
suspend fun downloadPublishedFile(@Path("filename") name: String): Response<ResponseBody>
13+
}

0 commit comments

Comments
 (0)