Skip to content

Commit 9c5dac0

Browse files
committed
Merge branch 'trunk' into feat/8558-domain-list
* trunk: (79 commits) Updated copyright year Bump version number Update metadata translations Update app translations – `Localizable.strings` Correct title in the Payments Menu Fix bug where variation count was duplicated Update EditAttributesViewModel.swift 8627 Add manual link fixes to the 11.9 release 8627 Update card reader manual URLs 8622 8621 Add metadata to payment intent for TTPoI Update documentation for Today and `to date` ranges Adjust formatting operations for date ranges Remove commented code Adds changelog Removes genereateAllVariation feature flag Fix contentEdgeInsets deprecation warnings Show action sheet/popover with bulk edit options Improve string descriptions Add disabled state for link button style Enabled bulk edit button conditionally ...
2 parents 6b06025 + 72a96db commit 9c5dac0

File tree

110 files changed

+24536
-1459
lines changed

Some content is hidden

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

110 files changed

+24536
-1459
lines changed

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
6060
case .applicationPasswordAuthenticationForSiteCredentialLogin:
6161
// Enable this to test application password authentication (WIP)
6262
return false
63-
case .generateAllVariations:
64-
return buildConfig == .localDeveloper || buildConfig == .alpha
6563
case .productsBulkEditing:
6664
return buildConfig == .localDeveloper || buildConfig == .alpha
6765
case .domainSettings:

Experiments/Experiments/FeatureFlag.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ public enum FeatureFlag: Int {
142142
///
143143
case applicationPasswordAuthenticationForSiteCredentialLogin
144144

145-
/// Allows merchants to create all variations from a single button
146-
///
147-
case generateAllVariations
148-
149145
/// Bulk editing of status and price in products list
150146
///
151147
case productsBulkEditing

Hardware/Hardware/CardReader/CardReaderService.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ public protocol CardReaderService {
1818

1919
// MARK: - Commands
2020

21+
/// Checks for support of a given reader type and discovery method combination. Does not start discovery.
22+
///
23+
func checkSupport(for cardReaderType: CardReaderType,
24+
configProvider: CardReaderConfigProvider,
25+
discoveryMethod: CardReaderDiscoveryMethod) -> Bool
26+
2127
/// Starts the service.
2228
/// That could imply, for example, that the reader discovery process starts
2329
func start(_ configProvider: CardReaderConfigProvider, discoveryMethod: CardReaderDiscoveryMethod) throws

Hardware/Hardware/CardReader/CardReaderType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension CardReaderType {
2929
case .wisepad3:
3030
return "WISEPAD_3"
3131
case .appleBuiltIn:
32-
return "BUILT_IN"
32+
return "COTS_DEVICE"
3333
default:
3434
return "UNKNOWN"
3535
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,20 @@ extension CardReaderType {
1919
return .other
2020
}
2121
}
22+
23+
func toStripe() -> DeviceType? {
24+
switch self {
25+
case .chipper:
26+
return .chipper2X
27+
case .stripeM2:
28+
return .stripeM2
29+
case .wisepad3:
30+
return .wisePad3
31+
case .appleBuiltIn:
32+
return .appleBuiltIn
33+
case .other:
34+
return nil
35+
}
36+
}
2237
}
2338
#endif

Hardware/Hardware/CardReader/StripeCardReader/NoOpCardReaderService.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Combine
2-
/// The adapter wrapping the Stripe Terminal SDK
2+
/// A no-op replacement for the adapter wrapping the Stripe Terminal SDK
33
public struct NoOpCardReaderService: CardReaderService {
44
// MARK: - Queries
55
/// The publisher that emits the list of discovered readers whenever the service discovers a new reader.
@@ -18,6 +18,12 @@ public struct NoOpCardReaderService: CardReaderService {
1818
public init() {}
1919
// MARK: - Commands
2020

21+
public func checkSupport(for cardReaderType: CardReaderType,
22+
configProvider: CardReaderConfigProvider,
23+
discoveryMethod: CardReaderDiscoveryMethod) -> Bool {
24+
return false
25+
}
26+
2127
/// Starts the service.
2228
/// That could imply, for example, that the reader discovery process starts
2329
public func start(_ configProvider: CardReaderConfigProvider, discoveryMethod: CardReaderDiscoveryMethod) throws {

Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,27 @@ extension StripeCardReaderService: CardReaderService {
6262

6363
// MARK: - CardReaderService conformance. Commands
6464

65-
public func start(_ configProvider: CardReaderConfigProvider,
66-
discoveryMethod: CardReaderDiscoveryMethod) throws {
65+
public func checkSupport(for cardReaderType: CardReaderType,
66+
configProvider: CardReaderConfigProvider,
67+
discoveryMethod: CardReaderDiscoveryMethod) -> Bool {
68+
guard let deviceType = cardReaderType.toStripe() else {
69+
return false
70+
}
71+
72+
prepare(using: configProvider)
73+
74+
let result = Terminal.shared.supportsReaders(of: deviceType,
75+
discoveryMethod: discoveryMethod.toStripe(),
76+
simulated: shouldUseSimulatedCardReader)
77+
switch result {
78+
case .success:
79+
return true
80+
case .failure:
81+
return false
82+
}
83+
}
84+
85+
func prepare(using configProvider: CardReaderConfigProvider) {
6786
setConfigProvider(configProvider)
6887

6988
Terminal.setLogListener { message in
@@ -75,6 +94,11 @@ extension StripeCardReaderService: CardReaderService {
7594
DDLogDebug("💳 [StripeTerminal] \(message)")
7695
}
7796
Terminal.shared.logLevel = terminalLogLevel
97+
}
98+
99+
public func start(_ configProvider: CardReaderConfigProvider,
100+
discoveryMethod: CardReaderDiscoveryMethod) throws {
101+
prepare(using: configProvider)
78102

79103
if shouldUseSimulatedCardReader {
80104
// You can test with different reader software update scenarios.
@@ -487,6 +511,7 @@ private extension StripeCardReaderService {
487511
///
488512
parameters.metadata?[Constants.readerIDMetadataKey] = self?.readerIDForIntent()
489513
parameters.metadata?[Constants.readerModelMetadataKey] = self?.readerModelForIntent()
514+
parameters.metadata?[Constants.platformMetadataKey] = Constants.platform
490515

491516
Terminal.shared.createPaymentIntent(parameters) { (intent, error) in
492517
if let error = error {
@@ -897,6 +922,8 @@ private extension StripeCardReaderService {
897922
///
898923
static let readerIDMetadataKey = "reader_ID"
899924
static let readerModelMetadataKey = "reader_model"
925+
static let platformMetadataKey = "platform"
926+
static let platform = "ios"
900927
}
901928
}
902929

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,9 @@
464464
93D8BBFF226BC1DA00AD2EB3 /* me-settings.json in Resources */ = {isa = PBXBuildFile; fileRef = 93D8BBFE226BC1DA00AD2EB3 /* me-settings.json */; };
465465
93D8BC01226BC20600AD2EB3 /* AccountSettingsRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93D8BC00226BC20600AD2EB3 /* AccountSettingsRemoteTests.swift */; };
466466
A69FE19D2588D70E0059A96B /* order-with-deleted-refunds.json in Resources */ = {isa = PBXBuildFile; fileRef = A69FE19C2588D70E0059A96B /* order-with-deleted-refunds.json */; };
467+
AE1950F3296DB2C2004D37D2 /* ProductsBulkUpdateMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE1950F2296DB2C2004D37D2 /* ProductsBulkUpdateMapper.swift */; };
467468
AE2D6623272A8F6E004A2C3A /* TelemetryRemoteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE2D6622272A8F6E004A2C3A /* TelemetryRemoteTests.swift */; };
469+
AEA056E4296DBA6E00948D52 /* products-batch-update.json in Resources */ = {isa = PBXBuildFile; fileRef = AEA056E3296DBA6E00948D52 /* products-batch-update.json */; };
468470
AED8AEBA272A97B400663FCC /* null-data.json in Resources */ = {isa = PBXBuildFile; fileRef = AE2D6624272A941C004A2C3A /* null-data.json */; };
469471
AED8AEBC272A997500663FCC /* IgnoringResponseMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED8AEBB272A997500663FCC /* IgnoringResponseMapperTests.swift */; };
470472
AEF94585272974F2001DCCFB /* TelemetryRemote.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEF94584272974F2001DCCFB /* TelemetryRemote.swift */; };
@@ -1278,8 +1280,10 @@
12781280
93D8BC00226BC20600AD2EB3 /* AccountSettingsRemoteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountSettingsRemoteTests.swift; sourceTree = "<group>"; };
12791281
9BD9C6C44CAC220B3C3B90B7 /* Pods-Networking.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Networking.release-alpha.xcconfig"; path = "../Pods/Target Support Files/Pods-Networking/Pods-Networking.release-alpha.xcconfig"; sourceTree = "<group>"; };
12801282
A69FE19C2588D70E0059A96B /* order-with-deleted-refunds.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "order-with-deleted-refunds.json"; sourceTree = "<group>"; };
1283+
AE1950F2296DB2C2004D37D2 /* ProductsBulkUpdateMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsBulkUpdateMapper.swift; sourceTree = "<group>"; };
12811284
AE2D6622272A8F6E004A2C3A /* TelemetryRemoteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TelemetryRemoteTests.swift; sourceTree = "<group>"; };
12821285
AE2D6624272A941C004A2C3A /* null-data.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "null-data.json"; sourceTree = "<group>"; };
1286+
AEA056E3296DBA6E00948D52 /* products-batch-update.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "products-batch-update.json"; sourceTree = "<group>"; };
12831287
AED8AEBB272A997500663FCC /* IgnoringResponseMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IgnoringResponseMapperTests.swift; sourceTree = "<group>"; };
12841288
AEF94584272974F2001DCCFB /* TelemetryRemote.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TelemetryRemote.swift; sourceTree = "<group>"; };
12851289
AEF9458A27297FF6001DCCFB /* IgnoringResponseMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IgnoringResponseMapper.swift; sourceTree = "<group>"; };
@@ -2283,6 +2287,7 @@
22832287
025CA2C7238F4FF400B05C81 /* product-shipping-classes-load-all.json */,
22842288
020220E123966CD900290165 /* product-shipping-classes-load-one.json */,
22852289
457FC68B2382B2FD00B41B02 /* product-update.json */,
2290+
AEA056E3296DBA6E00948D52 /* products-batch-update.json */,
22862291
45152818257A84A60076B03C /* product-attributes-all.json */,
22872292
4515281E257A89B90076B03C /* product-attribute-create.json */,
22882293
45152824257A8B740076B03C /* product-attribute-update.json */,
@@ -2463,6 +2468,7 @@
24632468
26731336255ACA850026F7EF /* PaymentGatewayListMapper.swift */,
24642469
0313651828AE559D00EEE571 /* PaymentGatewayMapper.swift */,
24652470
74749B96224134FF005C4CF2 /* ProductMapper.swift */,
2471+
AE1950F2296DB2C2004D37D2 /* ProductsBulkUpdateMapper.swift */,
24662472
45152810257A81730076B03C /* ProductAttributeMapper.swift */,
24672473
4515280C257A7EEC0076B03C /* ProductAttributeListMapper.swift */,
24682474
26B6453F259BCDFE00EF3FB3 /* ProductAttributeTermMapper.swift */,
@@ -2970,6 +2976,7 @@
29702976
02EF1672292F0D1900D90AD6 /* load-plan-success.json in Resources */,
29712977
DEA6B1C6296C13FB005AA5E9 /* payment-gateway-list-without-data.json in Resources */,
29722978
2685C0DE263B5A4200D9EE97 /* add-on-groups.json in Resources */,
2979+
AEA056E4296DBA6E00948D52 /* products-batch-update.json in Resources */,
29732980
DEC51A9B274E3206009F3DF4 /* plugin-inactive.json in Resources */,
29742981
CCF48B382628AEAE0034EA83 /* shipping-label-account-settings-no-payment-methods.json in Resources */,
29752982
31A451D327863A2E00FE81AA /* stripe-account-complete.json in Resources */,
@@ -3512,6 +3519,7 @@
35123519
021EAA5625493B3600AA8CCD /* OrderItemAttribute.swift in Sources */,
35133520
77CE40602514CB3E003FF69D /* ProductDownloadDragAndDrop.swift in Sources */,
35143521
2685C0FE263B5D8900D9EE97 /* AddOnGroupRemote.swift in Sources */,
3522+
AE1950F3296DB2C2004D37D2 /* ProductsBulkUpdateMapper.swift in Sources */,
35153523
450106912399B2C800E24722 /* TaxClassListMapper.swift in Sources */,
35163524
B963A5CC2853870000EFADA0 /* OrderItemRefundMetaData.swift in Sources */,
35173525
E18152BE28F85B5B0011A0EC /* InAppPurchasesRemote.swift in Sources */,

Networking/Networking/Extensions/DateFormatter+Woo.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public extension DateFormatter {
107107
/// Date formatter used for creating the properly-formatted date range info. Typically
108108
/// used when setting the end date on `AnalyticsHubTimeRangeGenerator`.
109109
///
110-
public static func createAnalyticsHubDayMonthYearFormatter(timezone: TimeZone) -> DateFormatter {
110+
public static func createDayMonthYearFormatter(timezone: TimeZone) -> DateFormatter {
111111
let formatter = DateFormatter()
112112
formatter.timeZone = timezone
113113
formatter.dateFormat = "MMM d, yyyy"
@@ -117,7 +117,7 @@ public extension DateFormatter {
117117
/// Date formatter used for creating the properly-formatted date range info. Typically
118118
/// used when setting the end date of a same-month range on `AnalyticsHubTimeRangeGenerator`.
119119
///
120-
public static func createAnalyticsHubDayYearFormatter(timezone: TimeZone) -> DateFormatter {
120+
public static func createDayYearFormatter(timezone: TimeZone) -> DateFormatter {
121121
let formatter = DateFormatter()
122122
formatter.timeZone = timezone
123123
formatter.dateFormat = "d, yyyy"
@@ -127,7 +127,7 @@ public extension DateFormatter {
127127
/// Date formatter used for creating the properly-formatted date range info. Typically
128128
/// used when setting the start date on `AnalyticsHubTimeRangeGenerator`.
129129
///
130-
public static func createAnalyticsHubDayMonthFormatter(timezone: TimeZone) -> DateFormatter {
130+
public static func createDayMonthFormatter(timezone: TimeZone) -> DateFormatter {
131131
let formatter = DateFormatter()
132132
formatter.timeZone = timezone
133133
formatter.dateFormat = "MMM d"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import Foundation
2+
3+
/// Mapper: ProductsBulkUpdateMapper
4+
///
5+
struct ProductsBulkUpdateMapper: Mapper {
6+
/// Site Identifier associated to the products that will be parsed.
7+
///
8+
/// We're injecting this field via `JSONDecoder.userInfo` because SiteID is not returned in any of the Product Endpoints.
9+
///
10+
let siteID: Int64
11+
12+
/// (Attempts) to convert a dictionary into Products.
13+
///
14+
func map(response: Data) throws -> [Product] {
15+
let decoder = JSONDecoder()
16+
decoder.dateDecodingStrategy = .formatted(DateFormatter.Defaults.dateTimeFormatter)
17+
decoder.userInfo = [
18+
.siteID: siteID
19+
]
20+
return try decoder.decode(ProductsEnvelope.self, from: response).updatedProducts
21+
}
22+
}
23+
24+
/// ProductsEnvelope Disposable Entity
25+
///
26+
/// `products/batch` endpoint returns the requested updated products in a `update` key, nested in a `data` key.
27+
/// This entity allows us to do parse all the things with JSONDecoder.
28+
///
29+
private struct ProductsEnvelope: Decodable {
30+
let updatedProducts: [Product]
31+
32+
private enum CodingKeys: String, CodingKey {
33+
case update
34+
case data
35+
}
36+
37+
public init(from decoder: Decoder) throws {
38+
let container = try decoder.container(keyedBy: CodingKeys.self)
39+
40+
let nestedContainer = try container.nestedContainer(keyedBy: CodingKeys.self, forKey: .data)
41+
updatedProducts = try nestedContainer.decode([Product].self, forKey: .update)
42+
}
43+
}

0 commit comments

Comments
 (0)