Skip to content

Commit 33080c4

Browse files
Merge branch 'trunk' into feat/15127-store-id-app-events
2 parents e31de65 + b610727 commit 33080c4

File tree

129 files changed

+2273
-680
lines changed

Some content is hidden

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

129 files changed

+2273
-680
lines changed

Experiments/Experiments/DefaultFeatureFlagService.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
8484
case .blazeCampaignObjective:
8585
return true
8686
case .favoriteProducts:
87-
return buildConfig == .localDeveloper || buildConfig == .alpha
88-
case .productGlobalUniqueIdentifierSupport:
8987
return true
90-
case .sendReceiptsForPointOfSale:
88+
case .productGlobalUniqueIdentifierSupport:
9189
return true
9290
case .hideSitesInStorePicker:
9391
return true

Experiments/Experiments/FeatureFlag.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,6 @@ public enum FeatureFlag: Int {
189189
///
190190
case productGlobalUniqueIdentifierSupport
191191

192-
/// Adds support for sending receipts after the payment for POS
193-
///
194-
case sendReceiptsForPointOfSale
195-
196192
/// Supports hiding sites from the store picker
197193
///
198194
case hideSitesInStorePicker

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ gem 'fastlane-plugin-sentry', '~> 1.0'
1717
# This comment avoids typing to switch to a development version for testing.
1818
#
1919
# gem 'fastlane-plugin-wpmreleasetoolkit', git: '[email protected]:wordpress-mobile/release-toolkit', branch: ''
20-
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 12.3'
20+
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 12.5'
2121
gem 'rake', '~> 12.3'
2222
gem 'rubocop', '~> 1.65'
2323
gem 'rubocop-rake', '~> 0.6'

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ GEM
213213
fastlane-plugin-appcenter (2.1.2)
214214
fastlane-plugin-sentry (1.25.1)
215215
os (~> 1.1, >= 1.1.4)
216-
fastlane-plugin-wpmreleasetoolkit (12.4.0)
216+
fastlane-plugin-wpmreleasetoolkit (12.5.0)
217217
activesupport (>= 6.1.7.1)
218218
buildkit (~> 1.5)
219219
chroma (= 0.2.0)
@@ -305,10 +305,10 @@ GEM
305305
naturally (2.2.1)
306306
netrc (0.11.0)
307307
nkf (0.2.0)
308-
nokogiri (1.18.1)
308+
nokogiri (1.18.3)
309309
mini_portile2 (~> 2.8.2)
310310
racc (~> 1.4)
311-
nokogiri (1.18.1-x86_64-darwin)
311+
nokogiri (1.18.3-x86_64-darwin)
312312
racc (~> 1.4)
313313
octokit (6.1.1)
314314
faraday (>= 1, < 3)
@@ -418,7 +418,7 @@ DEPENDENCIES
418418
fastlane (~> 2.217)
419419
fastlane-plugin-appcenter (~> 2.0)
420420
fastlane-plugin-sentry (~> 1.0)
421-
fastlane-plugin-wpmreleasetoolkit (~> 12.3)
421+
fastlane-plugin-wpmreleasetoolkit (~> 12.5)
422422
rake (~> 12.3)
423423
rmagick (~> 4.1)
424424
rubocop (~> 1.65)

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,11 @@
11691169
EE078D912AD2EFBA00C1199E /* JWTokenMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE078D902AD2EFBA00C1199E /* JWTokenMapper.swift */; };
11701170
EE078D932AD2F1E500C1199E /* JWTokenMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE078D922AD2F1E500C1199E /* JWTokenMapperTests.swift */; };
11711171
EE078D952AD2FCFA00C1199E /* jwt-token-expired-token.json in Resources */ = {isa = PBXBuildFile; fileRef = EE078D942AD2FCFA00C1199E /* jwt-token-expired-token.json */; };
1172+
EE1042AD2D65CE61005AB07F /* WooShippingVerifyDestinationAddressMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1042AC2D65CE5E005AB07F /* WooShippingVerifyDestinationAddressMapper.swift */; };
1173+
EE1042AF2D65CED8005AB07F /* WooShippingVerifyDestinationAddressResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1042AE2D65CED7005AB07F /* WooShippingVerifyDestinationAddressResponse.swift */; };
1174+
EE1042B12D65CF9D005AB07F /* WooShippingVerifyDestinationAddressSuccess.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1042B02D65CF9A005AB07F /* WooShippingVerifyDestinationAddressSuccess.swift */; };
1175+
EE1042B42D65DF9B005AB07F /* wooshipping-verify-destination-success.json in Resources */ = {isa = PBXBuildFile; fileRef = EE1042B32D65DF9B005AB07F /* wooshipping-verify-destination-success.json */; };
1176+
EE1042B52D65DF9B005AB07F /* wooshipping-verify-destination-error.json in Resources */ = {isa = PBXBuildFile; fileRef = EE1042B22D65DF9B005AB07F /* wooshipping-verify-destination-error.json */; };
11721177
EE1217DC2AFE04A500E6CAB1 /* ProductVariationEncoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1217DB2AFE04A500E6CAB1 /* ProductVariationEncoderTests.swift */; };
11731178
EE1CB9002B4BC85B00AD24D5 /* BlazeTargetOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1CB8FC2B4BC85B00AD24D5 /* BlazeTargetOptions.swift */; };
11741179
EE1CB9012B4BC85B00AD24D5 /* CreateBlazeCampaign.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1CB8FD2B4BC85B00AD24D5 /* CreateBlazeCampaign.swift */; };
@@ -2382,6 +2387,11 @@
23822387
EE078D902AD2EFBA00C1199E /* JWTokenMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWTokenMapper.swift; sourceTree = "<group>"; };
23832388
EE078D922AD2F1E500C1199E /* JWTokenMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWTokenMapperTests.swift; sourceTree = "<group>"; };
23842389
EE078D942AD2FCFA00C1199E /* jwt-token-expired-token.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "jwt-token-expired-token.json"; sourceTree = "<group>"; };
2390+
EE1042AC2D65CE5E005AB07F /* WooShippingVerifyDestinationAddressMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooShippingVerifyDestinationAddressMapper.swift; sourceTree = "<group>"; };
2391+
EE1042AE2D65CED7005AB07F /* WooShippingVerifyDestinationAddressResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooShippingVerifyDestinationAddressResponse.swift; sourceTree = "<group>"; };
2392+
EE1042B02D65CF9A005AB07F /* WooShippingVerifyDestinationAddressSuccess.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooShippingVerifyDestinationAddressSuccess.swift; sourceTree = "<group>"; };
2393+
EE1042B22D65DF9B005AB07F /* wooshipping-verify-destination-error.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "wooshipping-verify-destination-error.json"; sourceTree = "<group>"; };
2394+
EE1042B32D65DF9B005AB07F /* wooshipping-verify-destination-success.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "wooshipping-verify-destination-success.json"; sourceTree = "<group>"; };
23852395
EE1217DB2AFE04A500E6CAB1 /* ProductVariationEncoderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductVariationEncoderTests.swift; sourceTree = "<group>"; };
23862396
EE1CB8FC2B4BC85B00AD24D5 /* BlazeTargetOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlazeTargetOptions.swift; sourceTree = "<group>"; };
23872397
EE1CB8FD2B4BC85B00AD24D5 /* CreateBlazeCampaign.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateBlazeCampaign.swift; sourceTree = "<group>"; };
@@ -2564,6 +2574,7 @@
25642574
02C2548225635BB500A04423 /* ShippingLabel */ = {
25652575
isa = PBXGroup;
25662576
children = (
2577+
EE1042AB2D64E409005AB07F /* VerifyDestinationAddress */,
25672578
02C254B525637A8300A04423 /* Enums */,
25682579
029BA4F3255D72EC006171FD /* ShippingLabelPrintData.swift */,
25692580
02C254A7256373AB00A04423 /* ShippingLabel.swift */,
@@ -3610,6 +3621,8 @@
36103621
CED9BCBA2D3EAC5E00C063B8 /* wooshipping-address-validation-success.json */,
36113622
CED9BCBC2D3EAE4400C063B8 /* wooshipping-address-validation-error.json */,
36123623
CED9BCC82D3FDFCC00C063B8 /* wooshipping-update-origin-success.json */,
3624+
EE1042B22D65DF9B005AB07F /* wooshipping-verify-destination-error.json */,
3625+
EE1042B32D65DF9B005AB07F /* wooshipping-verify-destination-success.json */,
36133626
);
36143627
path = Responses;
36153628
sourceTree = "<group>";
@@ -3723,6 +3736,7 @@
37233736
DAEE64292D104B720031DCDC /* WooShippingOriginAddressesMapper.swift */,
37243737
CED9BCCA2D3FE0E400C063B8 /* WooShippingOriginAddressMapper.swift */,
37253738
CED9BCC42D3EBD0D00C063B8 /* WooShippingAddressValidationSuccessMapper.swift */,
3739+
EE1042AC2D65CE5E005AB07F /* WooShippingVerifyDestinationAddressMapper.swift */,
37263740
CE90E99D2CEFCB100068D852 /* WooShippingStatusMapper.swift */,
37273741
CE606D8E2BE39426001CB424 /* ShippingMethodMapper.swift */,
37283742
FE28F6E326842848004465C7 /* UserMapper.swift */,
@@ -4052,6 +4066,15 @@
40524066
path = SystemStatusDetails;
40534067
sourceTree = "<group>";
40544068
};
4069+
EE1042AB2D64E409005AB07F /* VerifyDestinationAddress */ = {
4070+
isa = PBXGroup;
4071+
children = (
4072+
EE1042B02D65CF9A005AB07F /* WooShippingVerifyDestinationAddressSuccess.swift */,
4073+
EE1042AE2D65CED7005AB07F /* WooShippingVerifyDestinationAddressResponse.swift */,
4074+
);
4075+
path = VerifyDestinationAddress;
4076+
sourceTree = "<group>";
4077+
};
40554078
EE1CB8F22B4BC7F300AD24D5 /* Blaze */ = {
40564079
isa = PBXGroup;
40574080
children = (
@@ -4347,6 +4370,8 @@
43474370
DEEF8E6529C832B500D47411 /* wordpress-site-info-with-auth-url.json in Resources */,
43484371
D865CE5F278CA183002C8520 /* stripe-payment-intent-requires-action.json in Resources */,
43494372
DE2004662BF7499600660A72 /* product-stock-decimal-sku.json in Resources */,
4373+
EE1042B42D65DF9B005AB07F /* wooshipping-verify-destination-success.json in Resources */,
4374+
EE1042B52D65DF9B005AB07F /* wooshipping-verify-destination-error.json in Resources */,
43504375
CCF48B2C2628AE160034EA83 /* shipping-label-account-settings.json in Resources */,
43514376
31A451D927863A2E00FE81AA /* stripe-account-live-test.json in Resources */,
43524377
DE42F9602967C88400D514C2 /* report-orders-total-without-data.json in Resources */,
@@ -5117,6 +5142,7 @@
51175142
CE12AE9729F2AB3F0056DD17 /* SubscriptionMapper.swift in Sources */,
51185143
025CA2C2238EBBAA00B05C81 /* ProductShippingClassListMapper.swift in Sources */,
51195144
CED9BCC72D3FAD1500C063B8 /* WooShippingAddress.swift in Sources */,
5145+
EE1042B12D65CF9D005AB07F /* WooShippingVerifyDestinationAddressSuccess.swift in Sources */,
51205146
74ABA1CD213F1B6B00FFAD30 /* TopEarnerStats.swift in Sources */,
51215147
CCAAD10F2683974000909664 /* ShippingLabelPackagePurchase.swift in Sources */,
51225148
265EFBDC285257950033BD33 /* Order+Fallbacks.swift in Sources */,
@@ -5161,6 +5187,7 @@
51615187
3178A49F2703E5CF00A8B4CA /* RemoteReaderLocationMapper.swift in Sources */,
51625188
45D685F823D0BC78005F87D0 /* ProductSkuMapper.swift in Sources */,
51635189
7412A8EA21B6E192005D182A /* ReportRemote.swift in Sources */,
5190+
EE1042AD2D65CE61005AB07F /* WooShippingVerifyDestinationAddressMapper.swift in Sources */,
51645191
CC01CE5A29B0FD61004FF537 /* ProductBundleItem.swift in Sources */,
51655192
DAEE642A2D104B7C0031DCDC /* WooShippingOriginAddressesMapper.swift in Sources */,
51665193
B5A2417D217F9ECC00595DEF /* MetaContainer.swift in Sources */,
@@ -5472,6 +5499,7 @@
54725499
B59325C7217E22FC000B0E8E /* Note.swift in Sources */,
54735500
CE0A0F13223942D90075ED8D /* ProductImage.swift in Sources */,
54745501
D8FBFF0B22D3ADB1006E3336 /* OrderStatsRemoteV4.swift in Sources */,
5502+
EE1042AF2D65CED8005AB07F /* WooShippingVerifyDestinationAddressResponse.swift in Sources */,
54755503
029BA53B255DFABD006171FD /* ShippingLabelPrintDataMapper.swift in Sources */,
54765504
0359EA0D27AAC5F80048DE2D /* WCPayChargeStatus.swift in Sources */,
54775505
CE430674234BA6AD0073CBFF /* RefundMapper.swift in Sources */,

Networking/Networking/ApplicationPassword/RequestAuthenticator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
enum RequestAuthenticatorError: Error {
3+
public enum RequestAuthenticatorError: Error {
44
case applicationPasswordUseCaseNotAvailable
55
case applicationPasswordNotAvailable
66
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import Foundation
2+
3+
/// Mapper: Verify Destination Address Response from WooCommerce Shipping extension
4+
///
5+
struct WooShippingVerifyDestinationAddressMapper: Mapper {
6+
/// (Attempts) to convert a dictionary into WooShippingVerifyDestinationAddressResponse.
7+
///
8+
func map(response: Data) throws -> WooShippingVerifyDestinationAddressSuccess {
9+
let decoder = JSONDecoder()
10+
let data: WooShippingVerifyDestinationAddressResponse = try {
11+
if hasDataEnvelope(in: response) {
12+
return try decoder.decode(WooShippingVerifyDestinationAddressResponseEnvelope.self, from: response).data
13+
} else {
14+
return try decoder.decode(WooShippingVerifyDestinationAddressResponse.self, from: response)
15+
}
16+
}()
17+
return try data.result.get()
18+
}
19+
}
20+
21+
/// WooShippingVerifyDestinationAddressResponseEnvelope Disposable Entity:
22+
/// `Veridy Destination Address` endpoint returns the shipping label address document in the `data` key.
23+
/// This entity allows us to do parse all the things with JSONDecoder.
24+
///
25+
private struct WooShippingVerifyDestinationAddressResponseEnvelope: Decodable {
26+
let data: WooShippingVerifyDestinationAddressResponse
27+
28+
private enum CodingKeys: String, CodingKey {
29+
case data = "data"
30+
}
31+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import Foundation
2+
3+
/// Represents Shipping Label Destination Address that has been validated or that generated an error from the WooCommerce Shipping Extension.
4+
///
5+
/// Only used internally for JSON decoding since the response might contain validation errors.
6+
/// For public consumption, we'll convert those to a `WooShippingAddressValidationError`, and expose
7+
/// a `WooShippingVerifyDestinationAddressSuccess` instead if there were no errors.
8+
///
9+
internal struct WooShippingVerifyDestinationAddressResponse: Equatable {
10+
let result: Result<WooShippingVerifyDestinationAddressSuccess, WooShippingAddressValidationError>
11+
12+
init(normalizedAddress: WooShippingAddress?,
13+
isTrivialNormalization: Bool?,
14+
isVerified: Bool?,
15+
errors: WooShippingAddressValidationError?) {
16+
if let errors {
17+
result = .failure(errors)
18+
} else if let normalizedAddress,
19+
let isTrivialNormalization,
20+
let isVerified {
21+
result = .success(.init(normalizedAddress: normalizedAddress,
22+
isTrivialNormalization: isTrivialNormalization,
23+
isVerified: isVerified))
24+
} else {
25+
// This case should never happen, but that's not guaranteed.
26+
// We'll treat the absence of both the addresses and errors as an error with no message.
27+
result = .failure(.init(addressError: nil, generalError: nil, nameError: nil))
28+
}
29+
}
30+
}
31+
32+
extension WooShippingVerifyDestinationAddressResponse: Decodable {
33+
init(from decoder: Decoder) throws {
34+
let container = try decoder.container(keyedBy: CodingKeys.self)
35+
let normalizedAddress = try container.decodeIfPresent(WooShippingAddress.self, forKey: .normalized)
36+
let isTrivialNormalization = try container.decodeIfPresent(Bool.self, forKey: .isTrivialNormalization)
37+
let isVerified = try container.decodeIfPresent(Bool.self, forKey: .isVerified)
38+
let errors = try container.decodeIfPresent(WooShippingAddressValidationError.self, forKey: .errors)
39+
self.init(normalizedAddress: normalizedAddress,
40+
isTrivialNormalization: isTrivialNormalization,
41+
isVerified: isVerified,
42+
errors: errors)
43+
}
44+
}
45+
46+
/// Defines all of the WooShippingVerifyDestinationAddressResponse CodingKeys
47+
///
48+
private extension WooShippingVerifyDestinationAddressResponse {
49+
enum CodingKeys: String, CodingKey {
50+
case normalized = "normalizedAddress"
51+
case errors = "errors"
52+
case isTrivialNormalization = "isTrivialNormalization"
53+
case isVerified = "isVerified"
54+
}
55+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Foundation
2+
import Codegen
3+
4+
/// Represents Shipping Label Destination Address that has been verified by the WooCommerce Shipping extension.
5+
///
6+
public struct WooShippingVerifyDestinationAddressSuccess: Equatable {
7+
public let normalizedAddress: WooShippingAddress
8+
9+
/// When sending an address to normalize to the server, if the response has the is_trivial_normalization property set to true,
10+
/// then the normalized address will be automatically accepted without user intervention.
11+
/// As its name indicates, that flag will be set when the changes made by the address normalizator were trivial,
12+
/// such as adding the +4 portion to a ZIP code, or changing capitalization, or changing street to st for example.
13+
///
14+
public let isTrivialNormalization: Bool
15+
16+
public let isVerified: Bool
17+
18+
public init(normalizedAddress: WooShippingAddress,
19+
isTrivialNormalization: Bool,
20+
isVerified: Bool) {
21+
self.normalizedAddress = normalizedAddress
22+
self.isTrivialNormalization = isTrivialNormalization
23+
self.isVerified = isVerified
24+
}
25+
}

Networking/Networking/Remote/WooShippingRemote.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public protocol WooShippingRemoteProtocol {
4242
address: WooShippingOriginAddress,
4343
isVerified: Bool,
4444
completion: @escaping (Result<WooShippingOriginAddressUpdate, Error>) -> Void)
45+
func verifyDestinationAddress(siteID: Int64,
46+
orderID: Int64,
47+
completion: @escaping (Result<WooShippingVerifyDestinationAddressSuccess, Error>) -> Void)
4548
}
4649

4750
/// Shipping Labels Remote Endpoints for the WooShipping Plugin.
@@ -348,6 +351,24 @@ public final class WooShippingRemote: Remote, WooShippingRemoteProtocol {
348351
completion(.failure(error))
349352
}
350353
}
354+
355+
/// Verifies the destination address of an order.
356+
/// - Parameters:
357+
/// - siteID: Remote ID of the site.
358+
/// - orderID: Remote ID of the order.
359+
/// - completion: Closure to be executed upon completion.
360+
public func verifyDestinationAddress(siteID: Int64,
361+
orderID: Int64,
362+
completion: @escaping (Result<WooShippingVerifyDestinationAddressSuccess, Error>) -> Void) {
363+
let path = Path.verifyOrder(orderID: orderID)
364+
let request = JetpackRequest(wooApiVersion: .wooShipping,
365+
method: .get,
366+
siteID: siteID,
367+
path: path,
368+
availableAsRESTRequest: true)
369+
let mapper = WooShippingVerifyDestinationAddressMapper()
370+
enqueue(request, mapper: mapper, completion: completion)
371+
}
351372
}
352373

353374
// MARK: Constants
@@ -362,6 +383,9 @@ private extension WooShippingRemote {
362383
static let originAddresses = "address/origins"
363384
static let normalizeAddress = "address/normalize"
364385
static let updateOrigin = "address/update_origin"
386+
static func verifyOrder(orderID: Int64) -> String {
387+
"address/\(orderID)/verify_order"
388+
}
365389
}
366390

367391
enum ParameterKey {

0 commit comments

Comments
 (0)