Skip to content

Commit b088969

Browse files
committed
Merge Trunk
2 parents d36da15 + 4eaa141 commit b088969

File tree

87 files changed

+2353
-496
lines changed

Some content is hidden

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

87 files changed

+2353
-496
lines changed

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
3434
case .stripeExtensionInPersonPayments:
3535
return buildConfig == .localDeveloper || buildConfig == .alpha
3636
case .myStoreTabUpdates:
37-
return buildConfig == .localDeveloper || buildConfig == .alpha
37+
return true
3838
case .couponManagement:
3939
return buildConfig == .localDeveloper || buildConfig == .alpha
4040
case .productSKUInputScanner:

Fakes/Fakes/Networking.generated.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,38 @@ extension DotcomError {
187187
.empty
188188
}
189189
}
190+
extension InboxAction {
191+
/// Returns a "ready to use" type filled with fake values.
192+
///
193+
public static func fake() -> InboxAction {
194+
.init(
195+
id: .fake(),
196+
name: .fake(),
197+
label: .fake(),
198+
status: .fake(),
199+
url: .fake()
200+
)
201+
}
202+
}
203+
extension InboxNote {
204+
/// Returns a "ready to use" type filled with fake values.
205+
///
206+
public static func fake() -> InboxNote {
207+
.init(
208+
siteID: .fake(),
209+
id: .fake(),
210+
name: .fake(),
211+
type: .fake(),
212+
status: .fake(),
213+
actions: .fake(),
214+
title: .fake(),
215+
content: .fake(),
216+
isDeleted: .fake(),
217+
isRead: .fake(),
218+
dateCreated: .fake()
219+
)
220+
}
221+
}
190222
extension Leaderboard {
191223
/// Returns a "ready to use" type filled with fake values.
192224
///

Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ extension StripeCardReaderService: CardReaderService {
295295
let batteryLevel = reader.batteryLevel?.doubleValue
296296

297297
return Future { [weak self] promise in
298-
299298
guard let self = self else {
300299
promise(.failure(CardReaderServiceError.connection()))
301300
return

Hardware/Hardware/CardReader/StripeCardReader/UnderlyingError+Stripe.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ extension UnderlyingError {
3636
self = .bluetoothScanTimedOut
3737
case ErrorCode.Code.bluetoothLowEnergyUnsupported.rawValue:
3838
self = .bluetoothLowEnergyUnsupported
39+
case ErrorCode.Code.bluetoothConnectionFailedBatteryCriticallyLow.rawValue:
40+
self = .bluetoothConnectionFailedBatteryCriticallyLow
3941
case ErrorCode.Code.readerSoftwareUpdateFailedBatteryLow.rawValue:
4042
self = .readerSoftwareUpdateFailedBatteryLow
4143
case ErrorCode.Code.readerSoftwareUpdateFailedInterrupted.rawValue:

Hardware/Hardware/CardReader/UnderlyingError.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public enum UnderlyingError: Error, Equatable {
4848
/// Bluetooth Low Energy is unsupported on this iOS device. Use a different iOS device that supports BLE (also known as Bluetooth 4.0)
4949
case bluetoothLowEnergyUnsupported
5050

51+
/// The reader has a critically low battery and cannot connect to the iOS device. Charge the reader before trying again.
52+
case bluetoothConnectionFailedBatteryCriticallyLow
53+
5154
/// Updating the reader software failed because the reader’s battery is too low. Charge the reader before trying again.
5255
case readerSoftwareUpdateFailedBatteryLow
5356

@@ -224,6 +227,9 @@ extension UnderlyingError: LocalizedError {
224227
case .bluetoothLowEnergyUnsupported:
225228
return NSLocalizedString("Unable to search for card readers - Bluetooth Low Energy is not supported on this device - please use a different device",
226229
comment: "Error message when Bluetooth Low Energy is not supported on the user device.")
230+
case .bluetoothConnectionFailedBatteryCriticallyLow:
231+
return NSLocalizedString("Unable to connect to reader - the reader has a critically low battery - charge the reader and try again.",
232+
comment: "Error message the card reader battery level is too low to connect to the phone or tablet.")
227233
case .readerSoftwareUpdateFailedBatteryLow:
228234
return NSLocalizedString("Unable to update card reader software - the reader battery is too low",
229235
comment: "Error message when the card reader battery level is too low to safely perform a software update.")

Hardware/HardwareTests/ErrorCodesTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ final class CardReaderServiceErrorTests: XCTestCase {
7070
XCTAssertEqual(.readerSoftwareUpdateFailedInterrupted, domainError(stripeCode: 2660))
7171
}
7272

73+
func test_stripe_unable_to_connect_to_reader_the_reader_has_a_critically_low_battery() {
74+
XCTAssertEqual(.bluetoothConnectionFailedBatteryCriticallyLow, domainError(stripeCode: 2680))
75+
}
76+
7377
func test_stripe_software_update_failed_maps_to_expected_error() {
7478
XCTAssertEqual(.readerSoftwareUpdateFailed, domainError(stripeCode: 3800))
7579
}

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@
276276
45B204B82489095100FE6526 /* ProductCategoryMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45B204B72489095100FE6526 /* ProductCategoryMapper.swift */; };
277277
45B204BA24890A8C00FE6526 /* ProductCategoryMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45B204B924890A8C00FE6526 /* ProductCategoryMapperTests.swift */; };
278278
45B204BC24890B1200FE6526 /* category.json in Resources */ = {isa = PBXBuildFile; fileRef = 45B204BB24890B1200FE6526 /* category.json */; };
279+
45CCFCE227A2C9BF0012E8CB /* InboxNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CCFCE127A2C9BF0012E8CB /* InboxNote.swift */; };
280+
45CCFCE427A2DC270012E8CB /* InboxAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CCFCE327A2DC270012E8CB /* InboxAction.swift */; };
281+
45CCFCE627A2E3710012E8CB /* InboxNoteListMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CCFCE527A2E3710012E8CB /* InboxNoteListMapper.swift */; };
282+
45CCFCE827A2E5020012E8CB /* InboxNoteListMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CCFCE727A2E5020012E8CB /* InboxNoteListMapperTests.swift */; };
283+
45CCFCEA27A2E59B0012E8CB /* inbox-note-list.json in Resources */ = {isa = PBXBuildFile; fileRef = 45CCFCE927A2E59B0012E8CB /* inbox-note-list.json */; };
279284
45CDAFAB2434CA9300F83C22 /* ProductCatalogVisibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CDAFAA2434CA9300F83C22 /* ProductCatalogVisibility.swift */; };
280285
45D1CF4923BACA6500945A36 /* ProductTaxStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D1CF4823BACA6500945A36 /* ProductTaxStatus.swift */; };
281286
45D685F823D0BC78005F87D0 /* ProductSkuMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D685F723D0BC78005F87D0 /* ProductSkuMapper.swift */; };
@@ -922,6 +927,11 @@
922927
45B204B72489095100FE6526 /* ProductCategoryMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCategoryMapper.swift; sourceTree = "<group>"; };
923928
45B204B924890A8C00FE6526 /* ProductCategoryMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCategoryMapperTests.swift; sourceTree = "<group>"; };
924929
45B204BB24890B1200FE6526 /* category.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = category.json; sourceTree = "<group>"; };
930+
45CCFCE127A2C9BF0012E8CB /* InboxNote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxNote.swift; sourceTree = "<group>"; };
931+
45CCFCE327A2DC270012E8CB /* InboxAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxAction.swift; sourceTree = "<group>"; };
932+
45CCFCE527A2E3710012E8CB /* InboxNoteListMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxNoteListMapper.swift; sourceTree = "<group>"; };
933+
45CCFCE727A2E5020012E8CB /* InboxNoteListMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxNoteListMapperTests.swift; sourceTree = "<group>"; };
934+
45CCFCE927A2E59B0012E8CB /* inbox-note-list.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "inbox-note-list.json"; sourceTree = "<group>"; };
925935
45CDAFAA2434CA9300F83C22 /* ProductCatalogVisibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCatalogVisibility.swift; sourceTree = "<group>"; };
926936
45D1CF4823BACA6500945A36 /* ProductTaxStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductTaxStatus.swift; sourceTree = "<group>"; };
927937
45D685F723D0BC78005F87D0 /* ProductSkuMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductSkuMapper.swift; sourceTree = "<group>"; };
@@ -1688,6 +1698,8 @@
16881698
45150A9B2683417A006922EA /* StateOfACountry.swift */,
16891699
B53EF53721813806003E146F /* DotcomError.swift */,
16901700
24F98C552502EA4800F49B68 /* FeatureFlag.swift */,
1701+
45CCFCE127A2C9BF0012E8CB /* InboxNote.swift */,
1702+
45CCFCE327A2DC270012E8CB /* InboxAction.swift */,
16911703
B5A2417C217F9ECC00595DEF /* MetaContainer.swift */,
16921704
B59325C6217E22FC000B0E8E /* Note.swift */,
16931705
B59325D0217E4206000B0E8E /* NoteBlock.swift */,
@@ -1953,6 +1965,7 @@
19531965
02A26F1A2744F5FC008E4EDB /* wp-site-settings.json */,
19541966
DEC51AEC2768A0AD009F3DF4 /* systemStatusWithPluginsOnly.json */,
19551967
077F39D726A58EB600ABEADC /* systemStatus.json */,
1968+
45CCFCE927A2E59B0012E8CB /* inbox-note-list.json */,
19561969
);
19571970
path = Responses;
19581971
sourceTree = "<group>";
@@ -1972,6 +1985,7 @@
19721985
B524193E21AC5FE400D6FC0A /* DotcomDeviceMapper.swift */,
19731986
24F98C572502EA8800F49B68 /* FeatureFlagMapper.swift */,
19741987
AEF9458A27297FF6001DCCFB /* IgnoringResponseMapper.swift */,
1988+
45CCFCE527A2E3710012E8CB /* InboxNoteListMapper.swift */,
19751989
26B2F74424C5573F0065CCC8 /* LeaderboardListMapper.swift */,
19761990
020D07BD23D8570800FD9580 /* MediaListMapper.swift */,
19771991
D823D904223746CE00C90817 /* NewShipmentTrackingMapper.swift */,
@@ -2113,6 +2127,7 @@
21132127
45150A9F26837357006922EA /* CountryListMapperTests.swift */,
21142128
B524194221AC622500D6FC0A /* DotcomDeviceMapperTests.swift */,
21152129
AED8AEBB272A997500663FCC /* IgnoringResponseMapperTests.swift */,
2130+
45CCFCE727A2E5020012E8CB /* InboxNoteListMapperTests.swift */,
21162131
B554FA922180C17200C54DFF /* NoteHashListMapperTests.swift */,
21172132
B5C151BF217EE3FB00C7BDC1 /* NoteListMapperTests.swift */,
21182133
B5C6FCCC20A34B8300A4F8E4 /* OrderListMapperTests.swift */,
@@ -2448,6 +2463,7 @@
24482463
45B204BC24890B1200FE6526 /* category.json in Resources */,
24492464
022902D422E2436400059692 /* stats_module_disabled_error.json in Resources */,
24502465
31A451D227863A2E00FE81AA /* stripe-account-restricted-pending.json in Resources */,
2466+
45CCFCEA27A2E59B0012E8CB /* inbox-note-list.json in Resources */,
24512467
025CA2C8238F4FF400B05C81 /* product-shipping-classes-load-all.json in Resources */,
24522468
74046E21217A73D0007DD7BF /* settings-general.json in Resources */,
24532469
31054724262E2FC600C5C02B /* wcpay-payment-intent-requires-capture.json in Resources */,
@@ -2798,6 +2814,7 @@
27982814
B518662220A097C200037A38 /* Network.swift in Sources */,
27992815
B572F69A21AC475C003EEFF0 /* DevicesRemote.swift in Sources */,
28002816
3192F220260D33BB0067FEF9 /* WCPayAccount.swift in Sources */,
2817+
45CCFCE227A2C9BF0012E8CB /* InboxNote.swift in Sources */,
28012818
311D412C2783BF7400052F64 /* StripeAccount.swift in Sources */,
28022819
B518662420A099BF00037A38 /* AlamofireNetwork.swift in Sources */,
28032820
311D412E2783C07D00052F64 /* StripeAccountMapper.swift in Sources */,
@@ -2857,6 +2874,7 @@
28572874
CE17C6B1229462C000AACE1C /* ProductStockStatus.swift in Sources */,
28582875
B557DA0420975500005962F4 /* OrdersRemote.swift in Sources */,
28592876
CE43066C2347C5F90073CBFF /* OrderItemRefund.swift in Sources */,
2877+
45CCFCE427A2DC270012E8CB /* InboxAction.swift in Sources */,
28602878
B5C6FCD420A373BB00A4F8E4 /* OrderMapper.swift in Sources */,
28612879
D88D5A49230BC8C7007B6E01 /* ProductReviewStatus.swift in Sources */,
28622880
451A97C92609FF050059D135 /* ShippingLabelPackagesResponse.swift in Sources */,
@@ -2883,6 +2901,7 @@
28832901
02BDB83523EA98C800BCC63E /* String+HTML.swift in Sources */,
28842902
B505F6CF20BEE38B00BB1B69 /* Account.swift in Sources */,
28852903
743E84EA22171C5800FAC9D7 /* ShipmentsRemote.swift in Sources */,
2904+
45CCFCE627A2E3710012E8CB /* InboxNoteListMapper.swift in Sources */,
28862905
B59325D5217E4206000B0E8E /* NoteRange.swift in Sources */,
28872906
26B2F74324C545D50065CCC8 /* Leaderboard.swift in Sources */,
28882907
458C6DE425AC72A1009B300D /* StoredProductSettings.swift in Sources */,
@@ -2987,6 +3006,7 @@
29873006
D8FBFF0F22D3B25E006E3336 /* WooAPIVersionTests.swift in Sources */,
29883007
45152831257A8E1A0076B03C /* ProductAttributeMapperTests.swift in Sources */,
29893008
26B2F74924C55ACE0065CCC8 /* LeaderboardsRemoteTests.swift in Sources */,
3009+
45CCFCE827A2E5020012E8CB /* InboxNoteListMapperTests.swift in Sources */,
29903010
74002D6C2118B88200A63C19 /* SiteVisitStatsRemoteTests.swift in Sources */,
29913011
0212683524C046CB00F8A892 /* MockNetwork+Path.swift in Sources */,
29923012
B554FA932180C17200C54DFF /* NoteHashListMapperTests.swift in Sources */,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Foundation
2+
3+
/// Mapper: Inbox Note List
4+
///
5+
struct InboxNoteListMapper: Mapper {
6+
7+
/// Site we're parsing `InboxNote`s for
8+
/// We're injecting this field by copying it in after parsing responses, because `siteID` is not returned in any of the Inbox Note endpoints.
9+
///
10+
let siteID: Int64
11+
12+
/// (Attempts) to convert a dictionary into an Inbox Note Array.
13+
///
14+
func map(response: Data) throws -> [InboxNote] {
15+
let decoder = JSONDecoder()
16+
decoder.dateDecodingStrategy = .formatted(DateFormatter.Defaults.dateTimeFormatter)
17+
decoder.userInfo = [
18+
.siteID: siteID
19+
]
20+
return try decoder.decode([InboxNote].self, from: response)
21+
}
22+
}

Networking/Networking/Model/Copiable/Models+Copiable.generated.swift

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,72 @@ extension CouponReport {
169169
}
170170
}
171171

172+
extension InboxAction {
173+
public func copy(
174+
id: CopiableProp<Int64> = .copy,
175+
name: CopiableProp<String> = .copy,
176+
label: CopiableProp<String> = .copy,
177+
status: CopiableProp<String> = .copy,
178+
url: CopiableProp<String> = .copy
179+
) -> InboxAction {
180+
let id = id ?? self.id
181+
let name = name ?? self.name
182+
let label = label ?? self.label
183+
let status = status ?? self.status
184+
let url = url ?? self.url
185+
186+
return InboxAction(
187+
id: id,
188+
name: name,
189+
label: label,
190+
status: status,
191+
url: url
192+
)
193+
}
194+
}
195+
196+
extension InboxNote {
197+
public func copy(
198+
siteID: CopiableProp<Int64> = .copy,
199+
id: CopiableProp<Int64> = .copy,
200+
name: CopiableProp<String> = .copy,
201+
type: CopiableProp<String> = .copy,
202+
status: CopiableProp<String> = .copy,
203+
actions: CopiableProp<[InboxAction]> = .copy,
204+
title: CopiableProp<String> = .copy,
205+
content: CopiableProp<String> = .copy,
206+
isDeleted: CopiableProp<Bool> = .copy,
207+
isRead: CopiableProp<Bool> = .copy,
208+
dateCreated: CopiableProp<Date> = .copy
209+
) -> InboxNote {
210+
let siteID = siteID ?? self.siteID
211+
let id = id ?? self.id
212+
let name = name ?? self.name
213+
let type = type ?? self.type
214+
let status = status ?? self.status
215+
let actions = actions ?? self.actions
216+
let title = title ?? self.title
217+
let content = content ?? self.content
218+
let isDeleted = isDeleted ?? self.isDeleted
219+
let isRead = isRead ?? self.isRead
220+
let dateCreated = dateCreated ?? self.dateCreated
221+
222+
return InboxNote(
223+
siteID: siteID,
224+
id: id,
225+
name: name,
226+
type: type,
227+
status: status,
228+
actions: actions,
229+
title: title,
230+
content: content,
231+
isDeleted: isDeleted,
232+
isRead: isRead,
233+
dateCreated: dateCreated
234+
)
235+
}
236+
}
237+
172238
extension Order {
173239
public func copy(
174240
siteID: CopiableProp<Int64> = .copy,
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import Foundation
2+
import Codegen
3+
4+
/// Represents an Inbox Action entity.
5+
/// Doc: p91TBi-6o2
6+
///
7+
public struct InboxAction: GeneratedCopiable, GeneratedFakeable, Equatable {
8+
9+
/// Action ID in WP database.
10+
///
11+
public let id: Int64
12+
13+
/// Name of the action.
14+
///
15+
public let name: String
16+
17+
/// Label of the action.
18+
///
19+
public let label: String
20+
21+
/// All values: `unactioned`, `actioned`, `snoozed`. It seems there isn't a way to snooze a notification at the moment.
22+
///
23+
public let status: String
24+
25+
/// URL where the action points.
26+
///
27+
public let url: String
28+
29+
30+
public init(id: Int64,
31+
name: String,
32+
label: String,
33+
status: String,
34+
url: String) {
35+
self.id = id
36+
self.name = name
37+
self.label = label
38+
self.status = status
39+
self.url = url
40+
}
41+
}
42+
43+
44+
// MARK: - Codable Conformance
45+
46+
/// Defines all of the InboxNote CodingKeys
47+
extension InboxAction: Codable {
48+
enum CodingKeys: String, CodingKey {
49+
case id
50+
case name
51+
case label
52+
case status
53+
case url
54+
}
55+
}

0 commit comments

Comments
 (0)