Skip to content

Commit

Permalink
Merge pull request #552 from gini/PM-105-Fix-field-name-of-the-Captur…
Browse files Browse the repository at this point in the history
…e-SDK-version-in-the-upload-metadata

Pm 105 fix field name of the capture sdk version in the upload metadata
  • Loading branch information
danicretu authored Sep 12, 2024
2 parents af16041 + 63d0d14 commit 4729aaf
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ import net.gini.android.bank.sdk.error.AmountParsingException
import net.gini.android.bank.sdk.pay.getBusinessIntent
import net.gini.android.bank.sdk.pay.getRequestId
import net.gini.android.bank.sdk.util.parseAmountToBackendFormat
import net.gini.android.capture.*
import net.gini.android.capture.Amount
import net.gini.android.capture.AsyncCallback
import net.gini.android.capture.Document
import net.gini.android.capture.GiniCapture
import net.gini.android.capture.ImportedFileValidationException
import net.gini.android.capture.onboarding.view.ImageOnboardingIllustrationAdapter
import net.gini.android.capture.onboarding.view.OnboardingIllustrationAdapter
import net.gini.android.capture.requirements.GiniCaptureRequirements
Expand Down Expand Up @@ -61,6 +65,8 @@ object GiniBank {
private var captureConfiguration: CaptureConfiguration? = null
private var giniApi: GiniBankAPI? = null

internal const val USER_COMMENT_GINI_BANK_VERSION = "GiniBankVer"

/**
* Bottom navigation bar adapters. Could be changed to custom ones.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.gini.android.bank.sdk.capture

import net.gini.android.bank.sdk.BuildConfig
import net.gini.android.bank.sdk.GiniBank
import net.gini.android.bank.sdk.capture.skonto.SkontoNavigationBarBottomAdapter
import net.gini.android.capture.DocumentImportEnabledFileTypes
import net.gini.android.capture.EntryPoint
Expand Down Expand Up @@ -233,6 +235,7 @@ internal fun GiniCapture.Builder.applyConfiguration(configuration: CaptureConfig
.setBottomNavigationBarEnabled(configuration.bottomNavigationBarEnabled)
.setEntryPoint(configuration.entryPoint)
.setAllowScreenshots(configuration.allowScreenshots)
.addCustomUploadMetadata(GiniBank.USER_COMMENT_GINI_BANK_VERSION, BuildConfig.VERSION_NAME)
.apply {
configuration.eventTracker?.let { setEventTracker(it) }
configuration.errorLoggerListener?.let { setCustomErrorLoggerListener(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public class GiniCapture {
private final EntryPoint entryPoint;
private final boolean allowScreenshots;

private final Map<String, String> mCustomUploadMetadata;


/**
* Retrieve the current instance.
Expand Down Expand Up @@ -345,6 +347,7 @@ private GiniCapture(@NonNull final Builder builder) {
onButtonLoadingIndicatorAdapterInstance = builder.getOnButtonLoadingIndicatorAdapterInstance();
entryPoint = builder.getEntryPoint();
allowScreenshots = builder.getAllowScreenshots();
mCustomUploadMetadata = builder.getCustomUploadMetadata();
}

/**
Expand Down Expand Up @@ -695,6 +698,14 @@ public boolean getAllowScreenshots() {
return allowScreenshots;
}

/**
* Get upload metadata to be added to the HTTP headers
*
* @return the map of custom metadata
*/
@Nullable
public Map<String, String> getCustomUploadMetadata() { return mCustomUploadMetadata; }

public static GiniCaptureFragment createGiniCaptureFragment() {
if (!GiniCapture.hasInstance()) {
throw new IllegalStateException("GiniCapture instance was created. Call GiniCapture.newInstance() before creating the GiniCaptureFragment.");
Expand Down Expand Up @@ -808,6 +819,8 @@ public void onAnalysisScreenEvent(@NotNull final Event<AnalysisScreenEvent> even
private EntryPoint entryPoint = Internal.DEFAULT_ENTRY_POINT;
private boolean allowScreenshots = true;

private Map<String, String> customUploadMetadata;

/**
* Create a new {@link GiniCapture} instance.
*/
Expand Down Expand Up @@ -1344,6 +1357,18 @@ public Builder setAllowScreenshots(boolean allowScreenshots) {
private boolean getAllowScreenshots() {
return allowScreenshots;
}

public Builder addCustomUploadMetadata(String key, String value) {
if (customUploadMetadata == null) {
customUploadMetadata = new HashMap<>();
}
customUploadMetadata.put(key, value);
return this;
}

private Map<String, String> getCustomUploadMetadata() {
return customUploadMetadata;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal object UploadMetadata {

private const val USER_COMMENT_PLATFORM = "Platform"
private const val USER_COMMENT_OS_VERSION = "OSVer"
private const val USER_COMMENT_GINI_CAPTURE_VERSION = "GiniVisionVer"
private const val USER_COMMENT_GINI_CAPTURE_VERSION = "GiniCaptureVer"
private const val USER_COMMENT_DEVICE_ORIENTATION = "DeviceOrientation"
private const val USER_COMMENT_DEVICE_TYPE = "DeviceType"
private const val USER_COMMENT_SOURCE = "Source"
Expand Down Expand Up @@ -70,10 +70,14 @@ internal object UploadMetadata {
metadataMap[USER_COMMENT_GINI_CAPTURE_VERSION] = BuildConfig.VERSION_NAME.replace(" ", "")

if (GiniCapture.hasInstance()) {
metadataMap[USER_COMMENT_ENTRY_POINT] = entryPointToString(GiniCapture.getInstance().getEntryPoint())
metadataMap[USER_COMMENT_ENTRY_POINT] = entryPointToString(GiniCapture.getInstance().entryPoint)
GiniCapture.getInstance().customUploadMetadata?.forEach {
metadataMap[it.key] = it.value
}
} else {
metadataMap[USER_COMMENT_ENTRY_POINT] = entryPointToString(GiniCapture.Internal.DEFAULT_ENTRY_POINT)
}

return convertMapToCSV(metadataMap)
}

Expand Down

0 comments on commit 4729aaf

Please sign in to comment.