Skip to content

Commit 4d081eb

Browse files
committed
Merge branch 'trunk' into woomob-449-refund-integrate-refund-api
2 parents 63a869c + 4940372 commit 4d081eb

File tree

96 files changed

+1754
-912
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1754
-912
lines changed

.swiftlint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
swiftlint_version: 0.54.0
1+
swiftlint_version: 0.58.2
22

33
excluded:
4+
- BuildTools/.build
45
- DerivedData
56
- fastlane
7+
- Modules/.build
68
- Pods
79
- Scripts
810
# Automattic's CI caching setup may generate this in the project folder

BuildTools/.sourcery.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# At the time of writing and with Sourcery 2.2.6, running the tool via `swift
2+
# package plugin` ignores the --config parameter, looking instead for the
3+
# .sourcery.yml configuration file.
4+
#
5+
# That means we cannot invoke Sourcery individually for each target.
6+
#
7+
# Luckily, the configuration files supports child configurations, so we can
8+
# achieve the same result this way.
9+
configurations:
10+
- child: ../CodeGeneration/Sourcery/Copiable/Hardware-Copiable.sourcery.yaml
11+
- child: ../CodeGeneration/Sourcery/Copiable/Networking-Copiable.sourcery.yaml
12+
- child: ../CodeGeneration/Sourcery/Copiable/Storage-Copiable.sourcery.yaml
13+
- child: ../CodeGeneration/Sourcery/Copiable/WooCommerce-Copiable.sourcery.yaml
14+
- child: ../CodeGeneration/Sourcery/Copiable/WooFoundation-Copiable.sourcery.yaml
15+
- child: ../CodeGeneration/Sourcery/Copiable/Yosemite-Copiable.sourcery.yaml
16+
- child: ../CodeGeneration/Sourcery/Fakes/Hardware-Fakes.yaml
17+
- child: ../CodeGeneration/Sourcery/Fakes/Networking-Fakes.yaml
18+
- child: ../CodeGeneration/Sourcery/Fakes/WooFoundation-Fakes.yaml
19+
- child: ../CodeGeneration/Sourcery/Fakes/Yosemite-Fakes.yaml

BuildTools/Empty.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Here only to satisfy SwiftPM requirement.
2+
// See https://github.com/nicklockwood/SwiftFormat#1-create-a-buildtools-folder-and-packageswift

BuildTools/Package.resolved

Lines changed: 195 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BuildTools/Package.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// swift-tools-version:6.0
2+
import Foundation
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "BuildTools",
7+
platforms: [.macOS(.v10_13)],
8+
dependencies: [
9+
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", exact: loadSwiftLintVersion()),
10+
.package(url: "https://github.com/krzysztofzablocki/Sourcery.git", from: "2.2.6")
11+
],
12+
targets: [.target(name: "BuildTools", path: "")]
13+
)
14+
15+
func loadSwiftLintVersion() -> Version {
16+
let swiftLintConfigURL = URL(fileURLWithPath: #filePath)
17+
.deletingLastPathComponent()
18+
.appendingPathComponent("..")
19+
.appendingPathComponent(".swiftlint.yml")
20+
21+
guard let yamlString = try? String(contentsOf: swiftLintConfigURL) else {
22+
fatalError("Failed to read SwiftLint config file at \(swiftLintConfigURL).")
23+
}
24+
25+
guard let versionLine = yamlString.components(separatedBy: .newlines)
26+
.first(where: { $0.contains("swiftlint_version") }) else {
27+
fatalError("SwiftLint version not found in YAML file.")
28+
}
29+
30+
// Assumes the format `swiftlint_version: <version>`
31+
guard let version = Version(versionLine.components(separatedBy: ":")
32+
.last?
33+
.trimmingCharacters(in: .whitespaces) ?? "") else {
34+
fatalError("Failed to extract SwiftLint version.")
35+
}
36+
37+
return version
38+
}

Networking/Networking/Model/PaymentGateway.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ extension PaymentGateway: Codable {
130130
}
131131
}
132132

133+
extension PaymentGateway {
134+
public enum Constants {
135+
public static let cashOnDeliveryGatewayID = "cod"
136+
}
137+
}
138+
133139
// MARK: - Features Decodable
134140
extension PaymentGateway.Feature: RawRepresentable, Codable {
135141

Networking/Networking/Remote/CouponsRemote.swift

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import Foundation
77
public protocol CouponsRemoteProtocol {
88
func loadAllCoupons(for siteID: Int64,
99
pageNumber: Int,
10-
pageSize: Int,
11-
completion: @escaping (Result<[Coupon], Error>) -> ())
10+
pageSize: Int) async throws -> [Coupon]
1211

1312
func loadCoupons(for siteID: Int64,
1413
by couponIDs: [Int64],
@@ -19,8 +18,7 @@ public protocol CouponsRemoteProtocol {
1918
func searchCoupons(for siteID: Int64,
2019
keyword: String,
2120
pageNumber: Int,
22-
pageSize: Int,
23-
completion: @escaping (Result<[Coupon], Error>) -> ())
21+
pageSize: Int) async throws -> [Coupon]
2422

2523
func retrieveCoupon(for siteID: Int64,
2624
couponID: Int64,
@@ -75,8 +73,7 @@ public final class CouponsRemote: Remote, CouponsRemoteProtocol {
7573
///
7674
public func loadAllCoupons(for siteID: Int64,
7775
pageNumber: Int = Default.pageNumber,
78-
pageSize: Int = Default.pageSize,
79-
completion: @escaping (Result<[Coupon], Error>) -> ()) {
76+
pageSize: Int = Default.pageSize) async throws -> [Coupon] {
8077
let parameters = [
8178
ParameterKey.page: String(pageNumber),
8279
ParameterKey.perPage: String(pageSize)
@@ -91,7 +88,7 @@ public final class CouponsRemote: Remote, CouponsRemoteProtocol {
9188

9289
let mapper = CouponListMapper(siteID: siteID)
9390

94-
enqueue(request, mapper: mapper, completion: completion)
91+
return try await enqueue(request, mapper: mapper)
9592
}
9693

9794
/// Retrieves a specific list of `Coupon`s by `couponID`.
@@ -139,8 +136,7 @@ public final class CouponsRemote: Remote, CouponsRemoteProtocol {
139136
public func searchCoupons(for siteID: Int64,
140137
keyword: String,
141138
pageNumber: Int,
142-
pageSize: Int,
143-
completion: @escaping (Result<[Coupon], Error>) -> ()) {
139+
pageSize: Int) async throws -> [Coupon] {
144140
let parameters = [
145141
ParameterKey.page: String(pageNumber),
146142
ParameterKey.perPage: String(pageSize),
@@ -156,7 +152,7 @@ public final class CouponsRemote: Remote, CouponsRemoteProtocol {
156152

157153
let mapper = CouponListMapper(siteID: siteID)
158154

159-
enqueue(request, mapper: mapper, completion: completion)
155+
return try await enqueue(request, mapper: mapper)
160156
}
161157

162158
/// Retrieves a `Coupon`.
@@ -372,23 +368,6 @@ public final class CouponsRemote: Remote, CouponsRemoteProtocol {
372368
}
373369
}
374370

375-
extension CouponsRemote {
376-
public func loadAllCoupons(for siteID: Int64,
377-
pageNumber: Int = CouponsRemote.Default.pageNumber,
378-
pageSize: Int = CouponsRemote.Default.pageSize) async throws -> [Coupon] {
379-
try await withCheckedThrowingContinuation { continuation in
380-
loadAllCoupons(for: siteID, pageNumber: pageNumber, pageSize: pageSize) { result in
381-
switch result {
382-
case .success(let coupons):
383-
continuation.resume(returning: coupons)
384-
case .failure(let error):
385-
continuation.resume(throwing: error)
386-
}
387-
}
388-
}
389-
}
390-
}
391-
392371
// MARK: - Constants
393372
//
394373
public extension CouponsRemote {

0 commit comments

Comments
 (0)