Skip to content

Commit

Permalink
fix(POM-360): enableThreeDS2 parameter encoding (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-vysotskyi-cko authored Apr 10, 2024
1 parent 3c39a7d commit 5c72285
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Scripts/Sourcery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export PATH="/opt/homebrew/bin:$PATH"
# Run sourcery
sourcery \
--sources $PROJECT_DIR/Sources/$TARGET_NAME/Sources \
--templates $PROJECT_DIR/Templates/AutoCompletion.stencil \
--templates $PROJECT_DIR/Templates \
--parseDocumentation \
--output $PROJECT_DIR/Sources/$TARGET_NAME/Sources/Generated/Sourcery+Generated.swift
38 changes: 36 additions & 2 deletions Sources/ProcessOut/Sources/Generated/Sourcery+Generated.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.2 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import UIKit

// swiftlint:disable all
// MARK: - AutoCodingKeys

extension POAssignCustomerTokenRequest {

enum CodingKeys: String, CodingKey {
case source
case preferredScheme
case verify
case invoiceId
case enableThreeDS2 = "enable_three_d_s_2"
case thirdPartySdkVersion
case metadata
}
}

extension POInvoiceAuthorizationRequest {

enum CodingKeys: String, CodingKey {
case source
case incremental
case enableThreeDS2 = "enable_three_d_s_2"
case preferredScheme
case thirdPartySdkVersion
case invoiceDetailIds
case overrideMacBlocking
case initialSchemeTransactionId
case autoCaptureAt
case captureAmount
case authorizeOnly
case allowFallbackToSale
case metadata
}
}

// MARK: - AutoCompletion

extension POCardsService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
import Foundation

/// Request to use to assign new source to existing customer token and potentially verify it.
public struct POAssignCustomerTokenRequest: Encodable {
public struct POAssignCustomerTokenRequest: Encodable { // sourcery: AutoCodingKeys

/// Id of the customer who token belongs to.
@POImmutableExcludedCodable
public var customerId: String
public let customerId: String // sourcery:coding: skip

/// Tokens that belong to the customer.
@POImmutableExcludedCodable
public var tokenId: String
public let tokenId: String // sourcery:coding: skip

/// Payment source to associate with token. The source can be a card, an APM or a gateway request. For the source
/// to be valid, you must not have used it for any previous payment or to create any other customer tokens.
Expand All @@ -34,7 +32,7 @@ public struct POAssignCustomerTokenRequest: Encodable {
public let invoiceId: String?

/// Boolean value indicating whether 3DS2 is enabled. Default value is `true`.
public let enableThreeDS2: Bool
public let enableThreeDS2: Bool // sourcery:coding: key="enable_three_d_s_2"

/// Can be used for a 3DS2 request to indicate which third party SDK is used for the call.
public let thirdPartySdkVersion: String?
Expand All @@ -54,8 +52,8 @@ public struct POAssignCustomerTokenRequest: Encodable {
thirdPartySdkVersion: String? = nil,
metadata: [String: String]? = nil
) {
self._customerId = .init(value: customerId)
self._tokenId = .init(value: tokenId)
self.customerId = customerId
self.tokenId = tokenId
self.source = source
self.preferredScheme = preferredScheme
self.verify = verify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

import Foundation

public struct POInvoiceAuthorizationRequest: Encodable {
public struct POInvoiceAuthorizationRequest: Encodable { // sourcery: AutoCodingKeys

/// Invoice identifier to to perform authorization for.
@POImmutableExcludedCodable
public var invoiceId: String
public let invoiceId: String // sourcery:coding: skip

/// Payment source to use for authorization.
public let source: String
Expand All @@ -20,7 +19,7 @@ public struct POInvoiceAuthorizationRequest: Encodable {
public let incremental: Bool

/// Boolean value indicating whether 3DS2 is enabled. Default value is `true`.
public let enableThreeDS2: Bool
public let enableThreeDS2: Bool // sourcery:coding: key="enable_three_d_s_2"

/// Card scheme or co-scheme that should get priority if it is available.
public let preferredScheme: String?
Expand Down Expand Up @@ -75,7 +74,7 @@ public struct POInvoiceAuthorizationRequest: Encodable {
allowFallbackToSale: Bool = false,
metadata: [String: String]? = nil
) {
self._invoiceId = .init(value: invoiceId)
self.invoiceId = invoiceId
self.source = source
self.incremental = incremental
self.enableThreeDS2 = enableThreeDS2
Expand Down
2 changes: 2 additions & 0 deletions Templates/Auto.stencil
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Foundation
import UIKit
12 changes: 12 additions & 0 deletions Templates/AutoCodingKeys.stencil
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// MARK: - AutoCodingKeys
{% for type in types.all|annotated:"AutoCodingKeys" %}

extension {{ type.name }} {

enum CodingKeys: String, CodingKey {
{% for variable in type.instanceVariables where not variable.annotations.coding.skip %}
case {{ variable.name }}{% if variable.annotations.coding.key %} = "{{ variable.annotations.coding.key }}"{% endif %}
{% endfor %}
}
}
{% endfor %}
5 changes: 1 addition & 4 deletions Templates/AutoCompletion.stencil
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import Foundation
import UIKit

// swiftlint:disable all
// MARK: - AutoCompletion
{% for type in types.implementing.POAutoCompletion|protocol %}

extension {{ type.name }} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import XCTest
@testable import ProcessOut

@MainActor final class CardsServiceTests: XCTestCase {
final class CardsServiceTests: XCTestCase {

override func setUp() {
super.setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import XCTest
@_spi(PO) @testable import ProcessOut

@MainActor final class CustomerTokensServiceTests: XCTestCase {
final class CustomerTokensServiceTests: XCTestCase {

override func setUp() {
super.setUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import XCTest
@testable import ProcessOut

@MainActor final class GatewayConfigurationsRepositoryTests: XCTestCase {
final class GatewayConfigurationsRepositoryTests: XCTestCase {

override func setUp() {
super.setUp()
Expand Down

0 comments on commit 5c72285

Please sign in to comment.