From 8aafe687230ecadf8be7437e0338196074135038 Mon Sep 17 00:00:00 2001 From: dleis612 Date: Tue, 2 Apr 2024 12:47:21 -0400 Subject: [PATCH] Add the default header to lock all endpoints --- .idea/kotlinc.xml | 2 +- .idea/misc.xml | 2 +- .../forage/android/network/OkHttpClientBuilder.kt | 12 +++++++++++- .../forage/android/vault/AbstractVaultSubmitter.kt | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index b1077fbd..0fc31131 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 704c883b..0ad17cbd 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + diff --git a/forage-android/src/main/java/com/joinforage/forage/android/network/OkHttpClientBuilder.kt b/forage-android/src/main/java/com/joinforage/forage/android/network/OkHttpClientBuilder.kt index 4144309c..0f9ad730 100644 --- a/forage-android/src/main/java/com/joinforage/forage/android/network/OkHttpClientBuilder.kt +++ b/forage-android/src/main/java/com/joinforage/forage/android/network/OkHttpClientBuilder.kt @@ -18,7 +18,17 @@ internal object OkHttpClientBuilder { .addHeader( ForageConstants.Headers.AUTHORIZATION, "${ForageConstants.Headers.BEARER} $sessionToken" - ).run { + ) + .run { + chain.request().headers[ForageConstants.Headers.API_VERSION]?.let { + this + } + ?: addHeader( + ForageConstants.Headers.API_VERSION, + "default" + ) + } + .run { merchantId?.let { addHeader( ForageConstants.Headers.MERCHANT_ACCOUNT, diff --git a/forage-android/src/main/java/com/joinforage/forage/android/vault/AbstractVaultSubmitter.kt b/forage-android/src/main/java/com/joinforage/forage/android/vault/AbstractVaultSubmitter.kt index 383dcdc5..0dcdde3c 100644 --- a/forage-android/src/main/java/com/joinforage/forage/android/vault/AbstractVaultSubmitter.kt +++ b/forage-android/src/main/java/com/joinforage/forage/android/vault/AbstractVaultSubmitter.kt @@ -131,6 +131,7 @@ internal abstract class AbstractVaultSubmitter( .setHeader(ForageConstants.Headers.MERCHANT_ACCOUNT, params.merchantId) .setHeader(ForageConstants.Headers.IDEMPOTENCY_KEY, params.idempotencyKey) .setHeader(ForageConstants.Headers.TRACE_ID, logger.getTraceIdValue()) + .setHeader(ForageConstants.Headers.API_VERSION, "default") .setToken(vaultToken) // PaymentMethod.card.token is in the comma-separated format ,,