Skip to content

Commit 037ed02

Browse files
committed
Merge branch 'trunk' into issue/8517-selection-state
2 parents 0957edc + 16e118f commit 037ed02

File tree

138 files changed

+8059
-923
lines changed

Some content is hidden

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

138 files changed

+8059
-923
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<!--
22
Contains editorialized release notes. Raw release notes should go into `RELEASE-NOTES.txt`.
33
-->
4+
## 11.8
5+
You’ll notice some nice visual changes to the look of the app! Take a look and please share your feedback – more updates to come in the next few weeks!
6+
47
## 11.7
58
Did you know we've added a new analytics section? It's now possible to select custom date ranges when viewing your stats! Simply click on the See More button under the store stats to check it out.
69

Experiments/Experiments/ABTest.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ public extension Variation {
6363
switch self {
6464
case .control:
6565
return "control"
66-
case .treatment(let string):
67-
return string.map { "treatment: \($0)" } ?? "treatment"
66+
case .treatment:
67+
return "treatment"
68+
case .customTreatment(let name):
69+
return "treatment: \(name)"
6870
}
6971
}
7072
}

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 80 additions & 8 deletions
Large diffs are not rendered by default.

Networking/Networking/ApplicationPassword/ApplicationPasswordUseCase.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public enum ApplicationPasswordUseCaseError: Error {
88
case duplicateName
99
case applicationPasswordsDisabled
1010
case failedToConstructLoginOrAdminURLUsingSiteAddress
11+
case unauthorizedRequest
1112
}
1213

1314
public struct ApplicationPassword {
@@ -138,7 +139,7 @@ private extension DefaultApplicationPasswordUseCase {
138139
let passwordName = await applicationPasswordName
139140

140141
let parameters = [ParameterKey.name: passwordName]
141-
let request = WordPressOrgRequest(baseURL: siteAddress, method: .post, path: Path.applicationPasswords, parameters: parameters)
142+
let request = RESTRequest(siteURL: siteAddress, method: .post, path: Path.applicationPasswords, parameters: parameters)
142143
return try await withCheckedThrowingContinuation { continuation in
143144
network.responseData(for: request) { result in
144145
switch result {
@@ -163,6 +164,8 @@ private extension DefaultApplicationPasswordUseCase {
163164
continuation.resume(throwing: ApplicationPasswordUseCaseError.applicationPasswordsDisabled)
164165
case .responseValidationFailed(reason: .unacceptableStatusCode(code: ErrorCode.duplicateNameErrorCode)):
165166
continuation.resume(throwing: ApplicationPasswordUseCaseError.duplicateName)
167+
case .responseValidationFailed(reason: .unacceptableStatusCode(code: ErrorCode.unauthorized)):
168+
continuation.resume(throwing: ApplicationPasswordUseCaseError.unauthorizedRequest)
166169
default:
167170
continuation.resume(throwing: error)
168171
}
@@ -179,7 +182,7 @@ private extension DefaultApplicationPasswordUseCase {
179182

180183
let passwordName = await applicationPasswordName
181184
let parameters = [ParameterKey.name: passwordName]
182-
let request = WordPressOrgRequest(baseURL: siteAddress, method: .delete, path: Path.applicationPasswords, parameters: parameters)
185+
let request = RESTRequest(siteURL: siteAddress, method: .delete, path: Path.applicationPasswords, parameters: parameters)
183186

184187
try await withCheckedThrowingContinuation { continuation in
185188
network.responseData(for: request) { result in
@@ -209,6 +212,7 @@ private extension DefaultApplicationPasswordUseCase {
209212
static let notFound = 404
210213
static let applicationPasswordsDisabledErrorCode = 501
211214
static let duplicateNameErrorCode = 409
215+
static let unauthorized = 401
212216
}
213217

214218
enum Constants {

Networking/Networking/Mapper/EntityIDMapper.swift

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,34 @@ struct EntityIDMapper: Mapper {
99
func map(response: Data) throws -> Int64 {
1010
let decoder = JSONDecoder()
1111

12-
return try decoder.decode(EntityIDEnvelope.self, from: response).id
12+
do {
13+
return try decoder.decode(EntityIDEnvelope.self, from: response).id
14+
} catch {
15+
let idDictionary = try decoder.decode(EntityIDEnvelope.EntityIDDictionaryType.self, from: response)
16+
return idDictionary[Constants.idKey] ?? .zero
17+
}
18+
}
19+
}
20+
21+
// MARK: Constants
22+
//
23+
private extension EntityIDMapper {
24+
enum Constants {
25+
static let idKey = "id"
1326
}
1427
}
1528

1629
/// Disposable Entity:
1730
/// Allows us to parse a product ID with JSONDecoder.
1831
///
1932
private struct EntityIDEnvelope: Decodable {
20-
private let data: [String: Int64]
33+
typealias EntityIDDictionaryType = [String: Int64]
34+
35+
private let data: EntityIDDictionaryType
2136

2237
// Extracts the entity ID from the underlying data
2338
var id: Int64 {
24-
data["id"] ?? .zero
39+
data[EntityIDMapper.Constants.idKey] ?? .zero
2540
}
2641

2742
private enum CodingKeys: String, CodingKey {

Networking/Networking/Mapper/LeaderboardListMapper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ struct LeaderboardListMapper: Mapper {
88
///
99
func map(response: Data) throws -> [Leaderboard] {
1010
let decoder = JSONDecoder()
11-
return try decoder.decode(LeaderboardsEnvelope.self, from: response).data
11+
do {
12+
return try decoder.decode(LeaderboardsEnvelope.self, from: response).data
13+
} catch {
14+
return try decoder.decode([Leaderboard].self, from: response)
15+
}
1216
}
1317
}
1418

Networking/Networking/Mapper/OrderListMapper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ struct OrderListMapper: Mapper {
2121
.siteID: siteID
2222
]
2323

24-
return try decoder.decode(OrderListEnvelope.self, from: response).orders
24+
do {
25+
return try decoder.decode(OrderListEnvelope.self, from: response).orders
26+
} catch {
27+
return try decoder.decode([Order].self, from: response)
28+
}
2529
}
2630
}
2731

Networking/Networking/Mapper/OrderMapper.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ struct OrderMapper: Mapper {
2020
decoder.userInfo = [
2121
.siteID: siteID
2222
]
23-
24-
return try decoder.decode(OrderEnvelope.self, from: response).order
23+
do {
24+
return try decoder.decode(OrderEnvelope.self, from: response).order
25+
} catch {
26+
return try decoder.decode(Order.self, from: response)
27+
}
2528
}
2629
}
2730

Networking/Networking/Mapper/OrderNoteMapper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ class OrderNoteMapper: Mapper {
1111
let decoder = JSONDecoder()
1212
decoder.dateDecodingStrategy = .formatted(DateFormatter.Defaults.dateTimeFormatter)
1313

14-
return try decoder.decode(OrderNoteEnvelope.self, from: response).orderNote
14+
do {
15+
return try decoder.decode(OrderNoteEnvelope.self, from: response).orderNote
16+
} catch {
17+
return try decoder.decode(OrderNote.self, from: response)
18+
}
1519
}
1620
}
1721

Networking/Networking/Mapper/OrderNotesMapper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ class OrderNotesMapper: Mapper {
1111
let decoder = JSONDecoder()
1212
decoder.dateDecodingStrategy = .formatted(DateFormatter.Defaults.dateTimeFormatter)
1313

14-
return try decoder.decode(OrderNotesEnvelope.self, from: response).orderNotes
14+
do {
15+
return try decoder.decode(OrderNotesEnvelope.self, from: response).orderNotes
16+
} catch {
17+
return try decoder.decode([OrderNote].self, from: response)
18+
}
1519
}
1620
}
1721

0 commit comments

Comments
 (0)