Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(health-sdk): Added missing documentation, fixed some typos #405

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import net.gini.android.core.api.models.SpecificExtraction
import org.json.JSONObject

/**
* The [DocumentManager] is a high level API on top of the Gini API, which is used via the [DocumentRepository]. It
* The [DocumentManager] is a high level API on top of the Gini API, via which the [DocumentRepository] is used. It
* provides high level methods to handle document related tasks easily.
*/
abstract class DocumentManager<out DR: DocumentRepository<E>, E: ExtractionsContainer>(private val documentRepository: DR) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package net.gini.android.core.api;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
* Media Types used across the application (e.g document types, http headers)
*/
public class MediaTypes {

public static final String IMAGE_JPEG = "image/jpeg";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import net.gini.android.core.api.requests.ApiException
import java.util.concurrent.CancellationException

/**
* Represents a requested API resource. Resources can be requested successfully, with an error or they can be cancelled.
* Represents a requested API resource. Resource requests can be returned successfully, with an error or they can be cancelled.
*/
sealed class Resource<T>(
open val data: T? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ import javax.net.ssl.SSLContext
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.TrustManager

/**
* The [GiniCoreAPIBuilder] allows you to build and configure a [GiniCoreAPI] instance.
*
* @constructor Initializes a new builder instance.
* @param context your application's Context instance (Android)
* @param clientId your application's client ID for the Gini Health API
* @param clientSecret your application's client secret for the Gini Health API
* @param emailDomain the email domain which is used for created Gini users
* @param sessionManager if not null, then the [SessionManager] instance will be used for session management. If null, then anonymous Gini users will be used.
*/
abstract class GiniCoreAPIBuilder<DM : DocumentManager<DR, E>, G : GiniCoreAPI<DM,DR, E>, DR : DocumentRepository<E>, E : ExtractionsContainer>(
private val context: Context,
private val clientId: String,
Expand Down Expand Up @@ -107,6 +117,9 @@ abstract class GiniCoreAPIBuilder<DM : DocumentManager<DR, E>, G : GiniCoreAPI<D
return this
}

/**
* Differentiate between different types of GiniApi's.
*/
abstract fun getGiniApiType(): GiniApiType

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
import org.json.JSONException;
import org.json.JSONObject;

/**
* The box where an extraction is found.
*
* Only available on some extractions.
*/
public class Box implements Parcelable {
private final int mPageNumber;
private final double mLeft;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.Map;

/**
* A compound extraction describes a group of extractions.
*
* Created by Alpar Szotyori on 13.02.2020.
*
* Copyright (c) 2020 Gini GmbH.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import java.util.Date;
import java.util.List;

/**
* A document sent for processing to the Gini API.
*/
public class Document implements Parcelable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import android.os.Parcelable;
import androidx.annotation.Nullable;

/**
* An extraction contains an entity that describes a general semantic type of the extraction, such as iban, bic, or amount.
* The entity also determines the format of the value containing text information.
*
* There might be an optional box element describing the position of the extraction value on the document. We refer to it as the bounding box.
* In most cases, the extractions without a bounding box are considered to be meta information such as doctype.
*/
public class Extraction implements Parcelable {
private String mValue;
private final String mEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import java.util.ArrayList;
import java.util.List;

/**
* A specific extraction assigns a semantic property to the extraction. It also has an additional candidates field.
*/
public class SpecificExtraction extends Extraction {

private final String mName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class GiniHealthAPIBuilder @JvmOverloads constructor(
}

/**
* Builds the GiniBankAPI instance with the configuration settings of the builder instance.
* Builds the GiniHealthAPI instance with the configuration settings of the builder instance.
*
* @return The fully configured GiniBankAPI instance.
* @return The fully configured GiniHealthAPI instance.
*/
override fun build(): GiniHealthAPI {
return GiniHealthAPI(createDocumentManager(), getCredentialsStore())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.lang.ref.WeakReference
/**
* [GiniHealth] is the main class for interacting with the Gini Health SDK.
* It provides a way to submit a document for reviewing its extracted payment details and
* let's the user make the payment with one of the payment providers.
* lets the user make the payment with one of the payment providers.
*
* The recommended flow is:
* 1. Call one of the overloads of [setDocumentForReview], to submit a document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import net.gini.android.health.sdk.bankselection.BankSelectionBottomSheet
data class ReviewConfiguration(
/**
* If set to `true`, the [ReviewFragment] will handle errors internally and show snackbars for errors.
* If set to `false` errors will be ignored by the [ReviewFragment]. In this case the flows exposed by [GiniHealth] should be observed for errors.
* If set to `false`, errors will be ignored by the [ReviewFragment]. In this case the flows exposed by [GiniHealth] should be observed for errors.
*
* Default value is `true`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@ package net.gini.android.health.sdk.review.model

import net.gini.android.core.api.Resource

/**
* Represents the result of processing a document to get its extractions.
* Wraps the result of the extraction request.
*/
sealed class ResultWrapper<out T> {

/**
* Request completed successfully and extractions were returned.
*/
class Success<T>(val value: T) : ResultWrapper<T>()

/**
* Request was unable to complete - returns the cause of the error
*/
class Error<T>(val error: Throwable) : ResultWrapper<T>()

/**
* Request did not complete yet.
*/
class Loading<T> : ResultWrapper<T>()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import net.gini.android.core.api.models.SpecificExtraction
import net.gini.android.health.sdk.review.error.NoPaymentDataExtracted
import net.gini.android.health.sdk.util.toBackendFormat

/**
* Represents the payment details of an invoice as extracted from a document.
*/
@Parcelize
data class PaymentDetails(
val recipient: String,
Expand Down Expand Up @@ -44,7 +47,7 @@ internal fun String.toAmount(): String {
/**
* Checks if the document is payable which looks for iban extraction.
*/
val PaymentDetails.isPayable get() = iban.isNotEmpty()
val PaymentDetails.isPayable get() = iban.isNotEmpty() // It appears this is not used anymore - we could remove it at a later stage (would remove it from the documentation as well)

internal fun MutableMap<String, CompoundExtraction>.withFeedback(paymentDetails: PaymentDetails): Map<String, CompoundExtraction> {
this["payment"] = this["payment"].let { payment ->
Expand Down
Loading