Skip to content

Commit 3220d09

Browse files
chore: Fix SwiftFormat lint issues
1 parent 0b0f618 commit 3220d09

6 files changed

Lines changed: 145 additions & 92 deletions

File tree

Sources/PrimerSDK/Classes/CheckoutComponents/Internal/DI/Framework/Container.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ actor Container: ContainerProtocol, LogReporter {
311311
domain: "DIContainer", code: -1,
312312
userInfo: [
313313
NSLocalizedDescriptionKey: "Synchronous resolution timed out"
314-
])
314+
]
315+
)
315316
)
316317
}
317318

Sources/PrimerSDK/Classes/CheckoutComponents/Internal/DI/Framework/DIContainter+SwiftUI.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ extension DIContainer {
6363
return StateObject(wrappedValue: resolved)
6464
} catch {
6565
logger.debug(
66-
message: "Failed to resolve \(String(describing: type)) from environment DI container")
66+
message: "Failed to resolve \(String(describing: type)) from environment DI container"
67+
)
6768
return StateObject(wrappedValue: fallback())
6869
}
6970
} else {

Sources/PrimerSDK/Classes/Core/Analytics/AnalyticsEvent.swift

Lines changed: 66 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ extension Analytics {
3333
let integrationType: String
3434
let minDeploymentTarget: String
3535

36-
fileprivate init(eventType: Analytics.Event.EventType,
37-
properties: AnalyticsEventProperties?,
38-
analyticsUrl: String? = PrimerAPIConfigurationModule.decodedJWTToken?.analyticsUrlV2) {
36+
fileprivate init(
37+
eventType: Analytics.Event.EventType,
38+
properties: AnalyticsEventProperties?,
39+
analyticsUrl: String? = PrimerAPIConfigurationModule.decodedJWTToken?.analyticsUrlV2
40+
) {
3941
self.analyticsUrl = analyticsUrl
4042
localId = String.randomString(length: 32)
4143

@@ -783,11 +785,13 @@ extension Analytics.Event {
783785
)
784786
}
785787

786-
static func message(message: String?,
787-
messageType: Property.MessageType,
788-
severity: Property.Severity,
789-
diagnosticsId: String? = nil,
790-
context: [String: Any]? = nil) -> Self {
788+
static func message(
789+
message: String?,
790+
messageType: Property.MessageType,
791+
severity: Property.Severity,
792+
diagnosticsId: String? = nil,
793+
context: [String: Any]? = nil
794+
) -> Self {
791795
.init(
792796
eventType: .message,
793797
properties: MessageEventProperties(
@@ -800,13 +804,15 @@ extension Analytics.Event {
800804
)
801805
}
802806

803-
static func ui(action: Property.Action,
804-
context: Property.Context?,
805-
extra: String?,
806-
objectType: Property.ObjectType,
807-
objectId: Property.ObjectId?,
808-
objectClass: String?,
809-
place: Property.Place) -> Self {
807+
static func ui(
808+
action: Property.Action,
809+
context: Property.Context?,
810+
extra: String?,
811+
objectType: Property.ObjectType,
812+
objectId: Property.ObjectId?,
813+
objectClass: String?,
814+
place: Property.Place
815+
) -> Self {
810816
.init(
811817
eventType: .ui,
812818
properties: UIEventProperties(
@@ -816,17 +822,20 @@ extension Analytics.Event {
816822
objectType: objectType,
817823
objectId: objectId,
818824
objectClass: objectClass,
819-
place: place)
825+
place: place
826+
)
820827
)
821828
}
822829

823-
static func networkCall(callType: Property.NetworkCallType,
824-
id: String,
825-
url: String,
826-
method: HTTPMethod,
827-
errorBody: String?,
828-
responseCode: Int?,
829-
duration: TimeInterval? = nil) -> Self {
830+
static func networkCall(
831+
callType: Property.NetworkCallType,
832+
id: String,
833+
url: String,
834+
method: HTTPMethod,
835+
errorBody: String?,
836+
responseCode: Int?,
837+
duration: TimeInterval? = nil
838+
) -> Self {
830839
.init(
831840
eventType: .networkCall,
832841
properties: NetworkCallEventProperties(
@@ -855,10 +864,12 @@ extension Analytics.Event {
855864
)
856865
}
857866

858-
static func timer(momentType: Property.TimerType,
859-
id: String?,
860-
duration: TimeInterval? = nil,
861-
context: [String: Any]? = nil) -> Self {
867+
static func timer(
868+
momentType: Property.TimerType,
869+
id: String?,
870+
duration: TimeInterval? = nil,
871+
context: [String: Any]? = nil
872+
) -> Self {
862873
.init(
863874
eventType: .timerEvent,
864875
properties: TimerEventProperties(
@@ -876,12 +887,16 @@ extension Analytics.Event {
876887
case vaultManager = "VAULT_MANAGER"
877888
}
878889

879-
static func dropInLoading(duration: Int,
880-
source: DropInLoadingSource) -> Self {
881-
.timer(momentType: .end,
882-
id: "DROP_IN_LOADING",
883-
duration: TimeInterval(duration),
884-
context: ["source": source.rawValue])
890+
static func dropInLoading(
891+
duration: Int,
892+
source: DropInLoadingSource
893+
) -> Self {
894+
.timer(
895+
momentType: .end,
896+
id: "DROP_IN_LOADING",
897+
duration: TimeInterval(duration),
898+
context: ["source": source.rawValue]
899+
)
885900
}
886901

887902
static func headlessLoading(duration: Int) -> Self {
@@ -893,15 +908,22 @@ extension Analytics.Event {
893908
case network = "NETWORK"
894909
}
895910

896-
static func configurationLoading(duration: Int,
897-
source: ConfigurationLoadingSource) -> Self {
898-
.timer(momentType: .end, id: "CONFIGURATION_LOADING",
899-
duration: TimeInterval(duration),
900-
context: ["source": source.rawValue])
911+
static func configurationLoading(
912+
duration: Int,
913+
source: ConfigurationLoadingSource
914+
) -> Self {
915+
.timer(
916+
momentType: .end,
917+
id: "CONFIGURATION_LOADING",
918+
duration: TimeInterval(duration),
919+
context: ["source": source.rawValue]
920+
)
901921
}
902922

903-
static func allImagesLoading(momentType: Property.TimerType,
904-
id: String?) -> Self {
923+
static func allImagesLoading(
924+
momentType: Property.TimerType,
925+
id: String?
926+
) -> Self {
905927
.init(
906928
eventType: .paymentMethodAllImagesLoading,
907929
properties: TimerEventProperties(
@@ -911,8 +933,10 @@ extension Analytics.Event {
911933
)
912934
}
913935

914-
static func imageLoading(momentType: Property.TimerType,
915-
id: String?) -> Self {
936+
static func imageLoading(
937+
momentType: Property.TimerType,
938+
id: String?
939+
) -> Self {
916940
.init(
917941
eventType: .paymentMethodImageLoading,
918942
properties: TimerEventProperties(

Sources/PrimerSDK/Classes/Core/Logging/PrimerLogger.swift

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,38 +52,46 @@ public protocol PrimerLogger {
5252

5353
extension PrimerLogger {
5454

55-
public func debug(message: String,
56-
userInfo: Encodable? = nil,
57-
file: String = #file,
58-
line: Int = #line,
59-
function: String = #function) {
55+
public func debug(
56+
message: String,
57+
userInfo: Encodable? = nil,
58+
file: String = #file,
59+
line: Int = #line,
60+
function: String = #function
61+
) {
6062
let metadata = PrimerLogMetadata(file: file, line: line, function: function)
6163
logProxy(level: .debug, message: message, userInfo: userInfo, metadata: metadata)
6264
}
6365

64-
public func info(message: String,
65-
userInfo: Encodable? = nil,
66-
file: String = #file,
67-
line: Int = #line,
68-
function: String = #function) {
66+
public func info(
67+
message: String,
68+
userInfo: Encodable? = nil,
69+
file: String = #file,
70+
line: Int = #line,
71+
function: String = #function
72+
) {
6973
let metadata = PrimerLogMetadata(file: file, line: line, function: function)
7074
logProxy(level: .info, message: message, userInfo: userInfo, metadata: metadata)
7175
}
7276

73-
public func warn(message: String,
74-
userInfo: Encodable? = nil,
75-
file: String = #file,
76-
line: Int = #line,
77-
function: String = #function) {
77+
public func warn(
78+
message: String,
79+
userInfo: Encodable? = nil,
80+
file: String = #file,
81+
line: Int = #line,
82+
function: String = #function
83+
) {
7884
let metadata = PrimerLogMetadata(file: file, line: line, function: function)
7985
logProxy(level: .warning, message: message, userInfo: userInfo, metadata: metadata)
8086
}
8187

82-
public func error(message: String,
83-
userInfo: Encodable? = nil,
84-
file: String = #file,
85-
line: Int = #line,
86-
function: String = #function) {
88+
public func error(
89+
message: String,
90+
userInfo: Encodable? = nil,
91+
file: String = #file,
92+
line: Int = #line,
93+
function: String = #function
94+
) {
8795
let metadata = PrimerLogMetadata(file: file, line: line, function: function)
8896
logProxy(level: .error, message: message, userInfo: userInfo, metadata: metadata)
8997
}
@@ -144,18 +152,23 @@ extension PrimerLogger {
144152
}
145153
}
146154

147-
private func logUserInfo(level: LogLevel,
148-
userInfo: Encodable?, metadata: PrimerLogMetadata) {
155+
private func logUserInfo(
156+
level: LogLevel,
157+
userInfo: Encodable?,
158+
metadata: PrimerLogMetadata
159+
) {
149160
guard let userInfo, let dictionary = try? userInfo.asDictionary() else {
150161
return
151162
}
152163
logProxy(level: level, message: dictionary.debugDescription, userInfo: nil, metadata: metadata)
153164
}
154165

155-
private func logProxy(level: LogLevel,
156-
message: String,
157-
userInfo: Encodable?,
158-
metadata: PrimerLogMetadata) {
166+
private func logProxy(
167+
level: LogLevel,
168+
message: String,
169+
userInfo: Encodable?,
170+
metadata: PrimerLogMetadata
171+
) {
159172
// Currently we only send logs for debug builds to avoid transmission of PII / PCI data in production
160173
#if DEBUG
161174
guard level.rawValue >= logLevel.rawValue else { return }

Sources/PrimerSDK/Classes/Core/Primer/PrimerDelegate.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ final class PrimerDelegateProxy: LogReporter {
6060
if PrimerInternal.shared.sdkIntegrationType == .headless,
6161
(decisionHandler as ((PrimerHeadlessUniversalCheckoutResumeDecision) -> Void)?) != nil {
6262
let delegate = PrimerHeadlessUniversalCheckout.current.delegate
63-
delegate?.primerHeadlessUniversalCheckoutDidTokenizePaymentMethod?(paymentMethodTokenData,
64-
decisionHandler: decisionHandler)
63+
delegate?.primerHeadlessUniversalCheckoutDidTokenizePaymentMethod?(
64+
paymentMethodTokenData,
65+
decisionHandler: decisionHandler
66+
)
6567

6668
} else if PrimerInternal.shared.sdkIntegrationType == .dropIn,
6769
(decisionHandler as ((PrimerResumeDecision) -> Void)?) != nil {
@@ -93,8 +95,10 @@ final class PrimerDelegateProxy: LogReporter {
9395
DispatchQueue.main.async {
9496
if PrimerInternal.shared.sdkIntegrationType == .headless,
9597
(decisionHandler as ((PrimerHeadlessUniversalCheckoutResumeDecision) -> Void)?) != nil {
96-
PrimerHeadlessUniversalCheckout.current.delegate?.primerHeadlessUniversalCheckoutDidResumeWith?(resumeToken,
97-
decisionHandler: decisionHandler)
98+
PrimerHeadlessUniversalCheckout.current.delegate?.primerHeadlessUniversalCheckoutDidResumeWith?(
99+
resumeToken,
100+
decisionHandler: decisionHandler
101+
)
98102
} else if PrimerInternal.shared.sdkIntegrationType == .dropIn,
99103
(decisionHandler as ((PrimerResumeDecision) -> Void)?) != nil {
100104
Primer.shared.delegate?.primerDidResumeWith?(resumeToken, decisionHandler: decisionHandler)
@@ -128,8 +132,10 @@ final class PrimerDelegateProxy: LogReporter {
128132
if PrimerInternal.shared.sdkIntegrationType == .headless {
129133
let delegate = PrimerHeadlessUniversalCheckout.current.delegate
130134
if delegate?.primerHeadlessUniversalCheckoutWillCreatePaymentWithData != nil {
131-
delegate?.primerHeadlessUniversalCheckoutWillCreatePaymentWithData?(data,
132-
decisionHandler: decisionHandler)
135+
delegate?.primerHeadlessUniversalCheckoutWillCreatePaymentWithData?(
136+
data,
137+
decisionHandler: decisionHandler
138+
)
133139
} else {
134140
decisionHandler(.continuePaymentCreation())
135141
}
@@ -290,8 +296,10 @@ final class PrimerDelegateProxy: LogReporter {
290296

291297
} else {
292298
let delegate = PrimerHeadlessUniversalCheckout.current.delegate
293-
delegate?.primerHeadlessUniversalCheckoutDidFail!(withError: exposedError,
294-
checkoutData: data)
299+
delegate?.primerHeadlessUniversalCheckoutDidFail!(
300+
withError: exposedError,
301+
checkoutData: data
302+
)
295303
decisionHandler(.fail(withErrorMessage: nil))
296304
}
297305

Sources/PrimerSDK/Classes/Data Models/PrimerSettings.swift

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,13 @@ public final class PrimerApplePayOptions: Codable {
192192
let shippingOptions: ShippingOptions?
193193
let billingOptions: BillingOptions?
194194

195-
public init(merchantIdentifier: String,
196-
merchantName: String?,
197-
isCaptureBillingAddressEnabled: Bool = false,
198-
showApplePayForUnsupportedDevice: Bool = true,
199-
checkProvidedNetworks: Bool = true) {
195+
public init(
196+
merchantIdentifier: String,
197+
merchantName: String?,
198+
isCaptureBillingAddressEnabled: Bool = false,
199+
showApplePayForUnsupportedDevice: Bool = true,
200+
checkProvidedNetworks: Bool = true
201+
) {
200202
self.merchantIdentifier = merchantIdentifier
201203
self.merchantName = merchantName
202204
self.isCaptureBillingAddressEnabled = isCaptureBillingAddressEnabled
@@ -206,13 +208,15 @@ public final class PrimerApplePayOptions: Codable {
206208
billingOptions = nil
207209
}
208210

209-
public init(merchantIdentifier: String,
210-
merchantName: String?,
211-
isCaptureBillingAddressEnabled: Bool = false,
212-
showApplePayForUnsupportedDevice: Bool = true,
213-
checkProvidedNetworks: Bool = true,
214-
shippingOptions: ShippingOptions? = nil,
215-
billingOptions: BillingOptions? = nil) {
211+
public init(
212+
merchantIdentifier: String,
213+
merchantName: String?,
214+
isCaptureBillingAddressEnabled: Bool = false,
215+
showApplePayForUnsupportedDevice: Bool = true,
216+
checkProvidedNetworks: Bool = true,
217+
shippingOptions: ShippingOptions? = nil,
218+
billingOptions: BillingOptions? = nil
219+
) {
216220
self.merchantIdentifier = merchantIdentifier
217221
self.merchantName = merchantName
218222
self.isCaptureBillingAddressEnabled = isCaptureBillingAddressEnabled
@@ -226,8 +230,10 @@ public final class PrimerApplePayOptions: Codable {
226230
public let shippingContactFields: [RequiredContactField]?
227231
public let requireShippingMethod: Bool
228232

229-
public init(shippingContactFields: [RequiredContactField]? = nil,
230-
requireShippingMethod: Bool) {
233+
public init(
234+
shippingContactFields: [RequiredContactField]? = nil,
235+
requireShippingMethod: Bool
236+
) {
231237
self.shippingContactFields = shippingContactFields
232238
self.requireShippingMethod = requireShippingMethod
233239
}

0 commit comments

Comments
 (0)