Skip to content

Commit badf635

Browse files
committed
Merge branch 'trunk' into issue/catalyst/1-groundwork
# Conflicts: # Podfile.lock
2 parents 39e12fa + 62e514d commit badf635

File tree

195 files changed

+9278
-2073
lines changed

Some content is hidden

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

195 files changed

+9278
-2073
lines changed

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ 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:
4141
return true
42+
case .canadaInPersonPayments:
43+
return buildConfig == .localDeveloper || buildConfig == .alpha
4244
case .taxLinesInSimplePayments:
4345
return buildConfig == .localDeveloper || buildConfig == .alpha
46+
case .inbox:
47+
return buildConfig == .localDeveloper || buildConfig == .alpha
4448
default:
4549
return true
4650
}

Experiments/Experiments/FeatureFlag.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@ public enum FeatureFlag: Int {
7878
///
7979
case productSKUInputScanner
8080

81+
/// Support for In-Person Payments in Canada
82+
///
83+
case canadaInPersonPayments
84+
8185
/// Displays the tax lines breakup in simple payments summary screen
8286
///
8387
case taxLinesInSimplePayments
88+
89+
/// Displays the Inbox option under the Hub Menu.
90+
///
91+
case inbox
8492
}

Fakes/Fakes/Networking.generated.swift

Lines changed: 33 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
///
@@ -305,6 +337,7 @@ extension Order {
305337
totalTax: .fake(),
306338
paymentMethodID: .fake(),
307339
paymentMethodTitle: .fake(),
340+
chargeID: .fake(),
308341
items: .fake(),
309342
billingAddress: .fake(),
310343
shippingAddress: .fake(),

Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift

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

298298
return Future { [weak self] promise in
299-
300299
guard let self = self else {
301300
promise(.failure(CardReaderServiceError.connection()))
302301
return

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ extension UnderlyingError {
3737
self = .bluetoothScanTimedOut
3838
case ErrorCode.Code.bluetoothLowEnergyUnsupported.rawValue:
3939
self = .bluetoothLowEnergyUnsupported
40+
case ErrorCode.Code.bluetoothConnectionFailedBatteryCriticallyLow.rawValue:
41+
self = .bluetoothConnectionFailedBatteryCriticallyLow
4042
case ErrorCode.Code.readerSoftwareUpdateFailedBatteryLow.rawValue:
4143
self = .readerSoftwareUpdateFailedBatteryLow
4244
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

@@ -228,6 +231,9 @@ extension UnderlyingError: LocalizedError {
228231
case .bluetoothLowEnergyUnsupported:
229232
return NSLocalizedString("Unable to search for card readers - Bluetooth Low Energy is not supported on this device - please use a different device",
230233
comment: "Error message when Bluetooth Low Energy is not supported on the user device.")
234+
case .bluetoothConnectionFailedBatteryCriticallyLow:
235+
return NSLocalizedString("Unable to connect to reader - the reader has a critically low battery - charge the reader and try again.",
236+
comment: "Error message the card reader battery level is too low to connect to the phone or tablet.")
231237
case .readerSoftwareUpdateFailedBatteryLow:
232238
return NSLocalizedString("Unable to update card reader software - the reader battery is too low",
233239
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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
02E7FFCB256218F600C53030 /* ShippingLabelRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02E7FFCA256218F600C53030 /* ShippingLabelRemoteTests.swift */; };
7777
02E7FFCF25621C7900C53030 /* shipping-label-print.json in Resources */ = {isa = PBXBuildFile; fileRef = 02E7FFCE25621C7900C53030 /* shipping-label-print.json */; };
7878
02F096C22406691100C0C1D5 /* media-library.json in Resources */ = {isa = PBXBuildFile; fileRef = 02F096C12406691100C0C1D5 /* media-library.json */; };
79+
034480C327A42F9100DFACD2 /* order-with-charge.json in Resources */ = {isa = PBXBuildFile; fileRef = 034480C227A42F9100DFACD2 /* order-with-charge.json */; };
7980
03DCB72626244B9B00C8953D /* Coupon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB72526244B9B00C8953D /* Coupon.swift */; };
8081
03DCB7402624AD7D00C8953D /* CouponListMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB73F2624AD7D00C8953D /* CouponListMapper.swift */; };
8182
03DCB7442624AD9B00C8953D /* CouponListMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03DCB7432624AD9A00C8953D /* CouponListMapperTests.swift */; };
@@ -276,6 +277,11 @@
276277
45B204B82489095100FE6526 /* ProductCategoryMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45B204B72489095100FE6526 /* ProductCategoryMapper.swift */; };
277278
45B204BA24890A8C00FE6526 /* ProductCategoryMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45B204B924890A8C00FE6526 /* ProductCategoryMapperTests.swift */; };
278279
45B204BC24890B1200FE6526 /* category.json in Resources */ = {isa = PBXBuildFile; fileRef = 45B204BB24890B1200FE6526 /* category.json */; };
280+
45CCFCE227A2C9BF0012E8CB /* InboxNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CCFCE127A2C9BF0012E8CB /* InboxNote.swift */; };
281+
45CCFCE427A2DC270012E8CB /* InboxAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CCFCE327A2DC270012E8CB /* InboxAction.swift */; };
282+
45CCFCE627A2E3710012E8CB /* InboxNoteListMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CCFCE527A2E3710012E8CB /* InboxNoteListMapper.swift */; };
283+
45CCFCE827A2E5020012E8CB /* InboxNoteListMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CCFCE727A2E5020012E8CB /* InboxNoteListMapperTests.swift */; };
284+
45CCFCEA27A2E59B0012E8CB /* inbox-note-list.json in Resources */ = {isa = PBXBuildFile; fileRef = 45CCFCE927A2E59B0012E8CB /* inbox-note-list.json */; };
279285
45CDAFAB2434CA9300F83C22 /* ProductCatalogVisibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CDAFAA2434CA9300F83C22 /* ProductCatalogVisibility.swift */; };
280286
45D1CF4923BACA6500945A36 /* ProductTaxStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D1CF4823BACA6500945A36 /* ProductTaxStatus.swift */; };
281287
45D685F823D0BC78005F87D0 /* ProductSkuMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45D685F723D0BC78005F87D0 /* ProductSkuMapper.swift */; };
@@ -724,6 +730,7 @@
724730
02E7FFCA256218F600C53030 /* ShippingLabelRemoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelRemoteTests.swift; sourceTree = "<group>"; };
725731
02E7FFCE25621C7900C53030 /* shipping-label-print.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "shipping-label-print.json"; sourceTree = "<group>"; };
726732
02F096C12406691100C0C1D5 /* media-library.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "media-library.json"; sourceTree = "<group>"; };
733+
034480C227A42F9100DFACD2 /* order-with-charge.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "order-with-charge.json"; sourceTree = "<group>"; };
727734
03DCB72526244B9B00C8953D /* Coupon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Coupon.swift; sourceTree = "<group>"; };
728735
03DCB73F2624AD7D00C8953D /* CouponListMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponListMapper.swift; sourceTree = "<group>"; };
729736
03DCB7432624AD9A00C8953D /* CouponListMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponListMapperTests.swift; sourceTree = "<group>"; };
@@ -922,6 +929,11 @@
922929
45B204B72489095100FE6526 /* ProductCategoryMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCategoryMapper.swift; sourceTree = "<group>"; };
923930
45B204B924890A8C00FE6526 /* ProductCategoryMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCategoryMapperTests.swift; sourceTree = "<group>"; };
924931
45B204BB24890B1200FE6526 /* category.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = category.json; sourceTree = "<group>"; };
932+
45CCFCE127A2C9BF0012E8CB /* InboxNote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxNote.swift; sourceTree = "<group>"; };
933+
45CCFCE327A2DC270012E8CB /* InboxAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxAction.swift; sourceTree = "<group>"; };
934+
45CCFCE527A2E3710012E8CB /* InboxNoteListMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxNoteListMapper.swift; sourceTree = "<group>"; };
935+
45CCFCE727A2E5020012E8CB /* InboxNoteListMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxNoteListMapperTests.swift; sourceTree = "<group>"; };
936+
45CCFCE927A2E59B0012E8CB /* inbox-note-list.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "inbox-note-list.json"; sourceTree = "<group>"; };
925937
45CDAFAA2434CA9300F83C22 /* ProductCatalogVisibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCatalogVisibility.swift; sourceTree = "<group>"; };
926938
45D1CF4823BACA6500945A36 /* ProductTaxStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductTaxStatus.swift; sourceTree = "<group>"; };
927939
45D685F723D0BC78005F87D0 /* ProductSkuMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductSkuMapper.swift; sourceTree = "<group>"; };
@@ -1688,6 +1700,8 @@
16881700
45150A9B2683417A006922EA /* StateOfACountry.swift */,
16891701
B53EF53721813806003E146F /* DotcomError.swift */,
16901702
24F98C552502EA4800F49B68 /* FeatureFlag.swift */,
1703+
45CCFCE127A2C9BF0012E8CB /* InboxNote.swift */,
1704+
45CCFCE327A2DC270012E8CB /* InboxAction.swift */,
16911705
B5A2417C217F9ECC00595DEF /* MetaContainer.swift */,
16921706
B59325C6217E22FC000B0E8E /* Note.swift */,
16931707
B59325D0217E4206000B0E8E /* NoteBlock.swift */,
@@ -1813,6 +1827,7 @@
18131827
B554FA8C2180B59700C54DFF /* notifications-load-hashes.json */,
18141828
AE2D6624272A941C004A2C3A /* null-data.json */,
18151829
B5C6FCD520A3768900A4F8E4 /* order.json */,
1830+
034480C227A42F9100DFACD2 /* order-with-charge.json */,
18161831
02C254D62563999200A04423 /* order-shipping-labels.json */,
18171832
B559EBA920A0B5CD00836CD4 /* orders-load-all.json */,
18181833
74C8F06520EEB76400B6EDC9 /* order-notes.json */,
@@ -1953,6 +1968,7 @@
19531968
02A26F1A2744F5FC008E4EDB /* wp-site-settings.json */,
19541969
DEC51AEC2768A0AD009F3DF4 /* systemStatusWithPluginsOnly.json */,
19551970
077F39D726A58EB600ABEADC /* systemStatus.json */,
1971+
45CCFCE927A2E59B0012E8CB /* inbox-note-list.json */,
19561972
);
19571973
path = Responses;
19581974
sourceTree = "<group>";
@@ -1972,6 +1988,7 @@
19721988
B524193E21AC5FE400D6FC0A /* DotcomDeviceMapper.swift */,
19731989
24F98C572502EA8800F49B68 /* FeatureFlagMapper.swift */,
19741990
AEF9458A27297FF6001DCCFB /* IgnoringResponseMapper.swift */,
1991+
45CCFCE527A2E3710012E8CB /* InboxNoteListMapper.swift */,
19751992
26B2F74424C5573F0065CCC8 /* LeaderboardListMapper.swift */,
19761993
020D07BD23D8570800FD9580 /* MediaListMapper.swift */,
19771994
D823D904223746CE00C90817 /* NewShipmentTrackingMapper.swift */,
@@ -2113,6 +2130,7 @@
21132130
45150A9F26837357006922EA /* CountryListMapperTests.swift */,
21142131
B524194221AC622500D6FC0A /* DotcomDeviceMapperTests.swift */,
21152132
AED8AEBB272A997500663FCC /* IgnoringResponseMapperTests.swift */,
2133+
45CCFCE727A2E5020012E8CB /* InboxNoteListMapperTests.swift */,
21162134
B554FA922180C17200C54DFF /* NoteHashListMapperTests.swift */,
21172135
B5C151BF217EE3FB00C7BDC1 /* NoteListMapperTests.swift */,
21182136
B5C6FCCC20A34B8300A4F8E4 /* OrderListMapperTests.swift */,
@@ -2354,6 +2372,7 @@
23542372
D823D91422377EE600C90817 /* shipment_tracking_providers.json in Resources */,
23552373
4599FC5C24A6276F0056157A /* product-tags-all.json in Resources */,
23562374
03DCB77E262738E300C8953D /* coupon.json in Resources */,
2375+
034480C327A42F9100DFACD2 /* order-with-charge.json in Resources */,
23572376
74A7B4BE217A841400E85A8B /* broken-settings-general.json in Resources */,
23582377
026CF624237D839B009563D4 /* product-variations-load-all.json in Resources */,
23592378
02AF07EC27492FDD00B2D81E /* media-library-from-wordpress-site.json in Resources */,
@@ -2448,6 +2467,7 @@
24482467
45B204BC24890B1200FE6526 /* category.json in Resources */,
24492468
022902D422E2436400059692 /* stats_module_disabled_error.json in Resources */,
24502469
31A451D227863A2E00FE81AA /* stripe-account-restricted-pending.json in Resources */,
2470+
45CCFCEA27A2E59B0012E8CB /* inbox-note-list.json in Resources */,
24512471
025CA2C8238F4FF400B05C81 /* product-shipping-classes-load-all.json in Resources */,
24522472
74046E21217A73D0007DD7BF /* settings-general.json in Resources */,
24532473
31054724262E2FC600C5C02B /* wcpay-payment-intent-requires-capture.json in Resources */,
@@ -2798,6 +2818,7 @@
27982818
B518662220A097C200037A38 /* Network.swift in Sources */,
27992819
B572F69A21AC475C003EEFF0 /* DevicesRemote.swift in Sources */,
28002820
3192F220260D33BB0067FEF9 /* WCPayAccount.swift in Sources */,
2821+
45CCFCE227A2C9BF0012E8CB /* InboxNote.swift in Sources */,
28012822
311D412C2783BF7400052F64 /* StripeAccount.swift in Sources */,
28022823
B518662420A099BF00037A38 /* AlamofireNetwork.swift in Sources */,
28032824
311D412E2783C07D00052F64 /* StripeAccountMapper.swift in Sources */,
@@ -2857,6 +2878,7 @@
28572878
CE17C6B1229462C000AACE1C /* ProductStockStatus.swift in Sources */,
28582879
B557DA0420975500005962F4 /* OrdersRemote.swift in Sources */,
28592880
CE43066C2347C5F90073CBFF /* OrderItemRefund.swift in Sources */,
2881+
45CCFCE427A2DC270012E8CB /* InboxAction.swift in Sources */,
28602882
B5C6FCD420A373BB00A4F8E4 /* OrderMapper.swift in Sources */,
28612883
D88D5A49230BC8C7007B6E01 /* ProductReviewStatus.swift in Sources */,
28622884
451A97C92609FF050059D135 /* ShippingLabelPackagesResponse.swift in Sources */,
@@ -2883,6 +2905,7 @@
28832905
02BDB83523EA98C800BCC63E /* String+HTML.swift in Sources */,
28842906
B505F6CF20BEE38B00BB1B69 /* Account.swift in Sources */,
28852907
743E84EA22171C5800FAC9D7 /* ShipmentsRemote.swift in Sources */,
2908+
45CCFCE627A2E3710012E8CB /* InboxNoteListMapper.swift in Sources */,
28862909
B59325D5217E4206000B0E8E /* NoteRange.swift in Sources */,
28872910
26B2F74324C545D50065CCC8 /* Leaderboard.swift in Sources */,
28882911
458C6DE425AC72A1009B300D /* StoredProductSettings.swift in Sources */,
@@ -2987,6 +3010,7 @@
29873010
D8FBFF0F22D3B25E006E3336 /* WooAPIVersionTests.swift in Sources */,
29883011
45152831257A8E1A0076B03C /* ProductAttributeMapperTests.swift in Sources */,
29893012
26B2F74924C55ACE0065CCC8 /* LeaderboardsRemoteTests.swift in Sources */,
3013+
45CCFCE827A2E5020012E8CB /* InboxNoteListMapperTests.swift in Sources */,
29903014
74002D6C2118B88200A63C19 /* SiteVisitStatsRemoteTests.swift in Sources */,
29913015
0212683524C046CB00F8A892 /* MockNetwork+Path.swift in Sources */,
29923016
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+
}

0 commit comments

Comments
 (0)