From bdb412bb21e6441ddc02ed084d926f687385f584 Mon Sep 17 00:00:00 2001 From: Razvan Capra Date: Mon, 11 Mar 2024 14:26:14 +0200 Subject: [PATCH] fix(GiniHealthSDK): Remove GiniDocument protocol IPC-153 --- .../Documentation/source/Integration.md | 26 +++---------------- .../PaymentComponentsController.swift | 17 ------------ .../InvoicesList/InvoicesListViewModel.swift | 2 +- 3 files changed, 5 insertions(+), 40 deletions(-) diff --git a/HealthSDK/GiniHealthSDK/Documentation/source/Integration.md b/HealthSDK/GiniHealthSDK/Documentation/source/Integration.md index 775817110..f8a5d2903 100644 --- a/HealthSDK/GiniHealthSDK/Documentation/source/Integration.md +++ b/HealthSDK/GiniHealthSDK/Documentation/source/Integration.md @@ -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) -> Void) @@ -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 @@ -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. diff --git a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentComponentsController.swift b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentComponentsController.swift index 5a44acaa2..4ca0af658 100644 --- a/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentComponentsController.swift +++ b/HealthSDK/GiniHealthSDK/Sources/GiniHealthSDK/Core/PaymentComponent/PaymentComponentsController.swift @@ -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. diff --git a/HealthSDK/GiniHealthSDKExample/GiniHealthSDKExample/InvoicesList/InvoicesListViewModel.swift b/HealthSDK/GiniHealthSDKExample/GiniHealthSDKExample/InvoicesList/InvoicesListViewModel.swift index e270a5241..b0c6af9b6 100644 --- a/HealthSDK/GiniHealthSDKExample/GiniHealthSDKExample/InvoicesList/InvoicesListViewModel.swift +++ b/HealthSDK/GiniHealthSDKExample/GiniHealthSDKExample/InvoicesList/InvoicesListViewModel.swift @@ -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?