Skip to content

Commit

Permalink
fix(GiniHealthSDK): Remove GiniDocument protocol
Browse files Browse the repository at this point in the history
IPC-153
  • Loading branch information
razvancapra committed Mar 11, 2024
1 parent 96d3913 commit bdb412b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 40 deletions.
26 changes: 4 additions & 22 deletions HealthSDK/GiniHealthSDK/Documentation/source/Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,7 @@ Payment component looks like this:
let paymentComponentsController = PaymentComponentsController(giniHealth: health)
```

#### 2. Pass the `paymentComponentsController` to the invoices/documents controller.
You should have a list of invoices/documents that confirm the `GiniDocument` protocol.

```swift
public protocol GiniDocument {
/// The document's unique identifier.
var documentID: String { get set }
/// The document's amount to pay.
var amountToPay: String? { get set }
/// The document's payment due date.
var paymentDueDate: String? { get set }
/// The document's recipient name.
var recipient: String? { get set }
/// Boolean value that indicates if the document is payable. This is obtained by calling the checkIfDocumentIsPayable method.
var isPayable: Bool? { get set }
}
```

#### 3. For each invoice/document, you need to call the `checkIfDocumentIsPayable` function from the `PaymentComponentsController` and store the value for each invoice in the `isPayable` field.
#### 2. For each invoice/document, you need to call the `checkIfDocumentIsPayable` function from the `PaymentComponentsController` and store the value for each invoice in the `isPayable` field.

```swift
public func checkIfDocumentIsPayable(docId: String, completion: @escaping (Result<Bool, GiniHealthError>) -> Void)
Expand All @@ -167,12 +149,12 @@ dispatchGroup.notify(queue: .main) {
}
```

#### 4. You have to load the payment providers by calling the `loadPaymentProviders` function from the `PaymentComponentsController` and listen to the `PaymentComponentsControllerProtocol`.
#### 3. You have to load the payment providers by calling the `loadPaymentProviders` function from the `PaymentComponentsController` and listen to the `PaymentComponentsControllerProtocol`.

> - We effectively handle situations where there are no payment providers available.
> - Based on the payment provider's colors, the `UIView` will automatically change its color.
#### 5. Depending on the value of `isPayable`, incorporate the corresponding payment component view into your cells using this function:
#### 4. Depending on the value of `isPayable`, incorporate the corresponding payment component view into your cells using this function:

```swift
public func paymentView(paymentProvider: PaymentProvider?) -> UIView
Expand All @@ -181,7 +163,7 @@ public func paymentView(paymentProvider: PaymentProvider?) -> UIView
> - We suggest placing this `UIView` within a vertical `UIStackView`. Additionally, in the `prepareForReuse()` function of each cell, remove the payment component view if it exists.
> - Furthermore, employing automatic dimension height in the `UITableView` containing the cells is recommended.
#### 6. `PaymentComponentsController` has 2 delegates that you can listen to: `PaymentComponentsControllerProtocol` and the `PaymentComponentViewProtocol`
#### 5. `PaymentComponentsController` has 2 delegates that you can listen to: `PaymentComponentsControllerProtocol` and the `PaymentComponentViewProtocol`

* `PaymentComponentsControllerProtocol` provides information when the `PaymentComponentsController` is loading. You can show/hide an `UIActivityIndicator` based on that.
* `PaymentComponentsControllerProtocol` provides completion handlers when `PaymentComponentsController` fetched successfully payment providers or when it failed with an error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@

import UIKit
import GiniHealthAPILibrary

/**
Data structure protocol for the stored invoices/documents needed for Payment Component Controller
*/
public protocol GiniDocument {
/// The document's unique identifier.
var documentID: String { get set }
/// The document's amount to pay.
var amountToPay: String? { get set }
/// The document's payment due date.
var paymentDueDate: String? { get set }
/// The document's recipient name.
var recipient: String? { get set }
/// Boolean value that indicates if the document is payable. This is obtained by calling the checkIfDocumentIsPayable method.
var isPayable: Bool? { get set }
}

/**
Protocol used to provide updates on the current status of the Payment Components Controller.
Uses a callback mechanism to handle payment provider requests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import GiniHealthAPILibrary
import GiniCaptureSDK
import GiniHealthSDK

struct DocumentWithExtractions: GiniDocument, Codable {
struct DocumentWithExtractions: Codable {
var documentID: String
var amountToPay: String?
var paymentDueDate: String?
Expand Down

0 comments on commit bdb412b

Please sign in to comment.