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

feat(GiniHealthSDK): Brand ingredient configuration #766

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

razvancapra
Copy link
Contributor

IPC-507

@razvancapra razvancapra self-assigned this Jan 15, 2025
@razvancapra razvancapra requested a review from zladzeyka January 15, 2025 13:12
Copy link
Collaborator

@zladzeyka zladzeyka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @razvancapra
Please find some notes below:

@@ -16,6 +16,17 @@ public enum GiniLocalization: String, CaseIterable {
case de = "de"
}

/**
An enumeration representing the visibility type of an ingredient brand.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

This service implements the `ClientConfigurationServiceProtocol` and provides methods to retrieve configuration data from a specified API domain.
*/
public final class ClientConfigurationService: ClientConfigurationServiceProtocol {
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:
Please follow the comment style that you use in the past

`/**
Initializes a new instance of GiniMerchant.

 This initializer creates a GiniMerchant instance by first constructing a Client object with the provided client credentials (id, secret, domain)
 
 - Parameters:
 - id: The client ID provided by Gini when you register your application. This is a unique identifier for your application.
 - secret: The client secret provided by Gini alongside the client ID. This is used to authenticate your application to the Gini API.
 - domain: The domain associated with your client credentials. This is used to scope the client credentials to a specific domain.
 - pinningConfig: Configuration for certificate pinning. Format ["PinnedDomains" : ["PublicKeyHashes"]]
 - logLevel: The log level. `LogLevel.none` by default.
 */`

import Foundation

extension ClientConfigurationServiceProtocol {
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion]: Please use the comment format

    /**
     Initializes a new instance of GiniMerchant.
     
     This initializer creates a GiniMerchant instance by first constructing a Client object with the provided client credentials (id, secret, domain)
     
     - Parameters:
     - id: The client ID provided by Gini when you register your application. This is a unique identifier for your application.
     - secret: The client secret provided by Gini alongside the client ID. This is used to authenticate your application to the Gini API.
     - domain: The domain associated with your client credentials. This is used to scope the client credentials to a specific domain.
     - pinningConfig: Configuration for certificate pinning. Format ["PinnedDomains" : ["PublicKeyHashes"]]
     - logLevel: The log level. `LogLevel.none` by default.
     */

Protocol for client configuration service
*/
public protocol ClientConfigurationServiceProtocol: AnyObject {
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion]: Please use the comment format :

    /**
     Initializes a new instance of GiniMerchant.
     
     This initializer creates a GiniMerchant instance by first constructing a Client object with the provided client credentials (id, secret, domain)
     
     - Parameters:
     - id: The client ID provided by Gini when you register your application. This is a unique identifier for your application.
     - secret: The client secret provided by Gini alongside the client ID. This is used to authenticate your application to the Gini API.
     - domain: The domain associated with your client credentials. This is used to scope the client credentials to a specific domain.
     - pinningConfig: Configuration for certificate pinning. Format ["PinnedDomains" : ["PublicKeyHashes"]]
     - logLevel: The log level. `LogLevel.none` by default.
     */

*/
public struct ClientConfiguration: Codable {
/**
Creates a new `ClientConfiguration` instance.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion]: Please use the comment format :

    /**
     Initializes a new instance of GiniMerchant.
     
     This initializer creates a GiniMerchant instance by first constructing a Client object with the provided client credentials (id, secret, domain)
     
     - Parameters:
     - id: The client ID provided by Gini when you register your application. This is a unique identifier for your application.
     - secret: The client secret provided by Gini alongside the client ID. This is used to authenticate your application to the Gini API.
     - domain: The domain associated with your client credentials. This is used to scope the client credentials to a specific domain.
     - pinningConfig: Configuration for certificate pinning. Format ["PinnedDomains" : ["PublicKeyHashes"]]
     - logLevel: The log level. `LogLevel.none` by default.
     */

- parameter comunicationTone: A configuration that indicates the comunication tone of the texts. Defaults to `nil
- parameter ingredientBrandType: A configuration that indicates the presence of the ingredient brand. Defaults to `nil`.
*/
public init(clientID: String,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Clarification]: one of our customers is using AlternativeTokenSource and there is no clientID, how will we handle that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question. We need to ask backend team.

@@ -126,6 +127,7 @@ public final class PaymentComponentsController: BottomSheetsProviderProtocol, Gi
self.stringsProvider = giniHealth
setupObservers()
loadPaymentProviders()
fetchAndConfigureClientConfiguration()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fetchAndConfigureClientConfiguration()
fetchAndUpdateClientConfiguration()

@@ -169,7 +170,8 @@ final class PaymentComponentsControllerTests: XCTestCase {
poweredByGiniStrings: giniHealth.poweredByGiniStrings,
moreInformationConfiguration: giniHealth.moreInformationConfiguration,
moreInformationStrings: giniHealth.moreInformationStrings,
urlOpener: URLOpener(MockUIApplication(canOpen: false)))
urlOpener: URLOpener(MockUIApplication(canOpen: false)),
clientConfiguration: nil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Clarification]: why do we always pass clientConfiguration: nil in tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any tests for client configuration. Should we create some?

@razvancapra razvancapra requested a review from zladzeyka January 23, 2025 11:56
Copy link

@razvancapra razvancapra requested a review from igor-gini February 5, 2025 09:09
Copy link
Collaborator

@zladzeyka zladzeyka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@razvancapra please check a tiny suggestion: you removed accidentally whitespace and it's good to go in QA

@@ -153,7 +154,12 @@ public final class GiniHealthConfiguration: NSObject {
/**
Custom localization configuration for localizable strings.
*/
public var customLocalization: GiniLocalization?
public var customLocalization: GiniLocalization?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public var customLocalization: GiniLocalization?
public var customLocalization: GiniLocalization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants