Skip to content

Commit f84f26e

Browse files
committed
Merge commit 'd231feff7094c39c56123f4fd2a065bcf459ca6f' into feat/batch-fetching-in-order-details-take-2
2 parents 3577381 + d231fef commit f84f26e

File tree

50 files changed

+1654
-424
lines changed

Some content is hidden

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

50 files changed

+1654
-424
lines changed

Fakes/Fakes/Networking.generated.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,6 +2848,24 @@ extension Networking.WooShippingDestinationAddress {
28482848
)
28492849
}
28502850
}
2851+
extension Networking.WooShippingNormalizedAddress {
2852+
/// Returns a "ready to use" type filled with fake values.
2853+
///
2854+
public static func fake() -> Networking.WooShippingNormalizedAddress {
2855+
.init(
2856+
company: .fake(),
2857+
firstName: .fake(),
2858+
lastName: .fake(),
2859+
phone: .fake(),
2860+
country: .fake(),
2861+
state: .fake(),
2862+
address1: .fake(),
2863+
address2: .fake(),
2864+
city: .fake(),
2865+
postcode: .fake()
2866+
)
2867+
}
2868+
}
28512869
extension Networking.WooShippingOriginAddress {
28522870
/// Returns a "ready to use" type filled with fake values.
28532871
///

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@
12431243
EE57C1542980F18500BC31E7 /* ShipmentTrackingProviderListMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE57C1532980F18500BC31E7 /* ShipmentTrackingProviderListMapperTests.swift */; };
12441244
EE57C1562980F3BF00BC31E7 /* shipment_tracking_single_without_data.json in Resources */ = {isa = PBXBuildFile; fileRef = EE57C1552980F3BF00BC31E7 /* shipment_tracking_single_without_data.json */; };
12451245
EE57C1582980F3D400BC31E7 /* shipment_tracking_providers_without_data.json in Resources */ = {isa = PBXBuildFile; fileRef = EE57C1572980F3D400BC31E7 /* shipment_tracking_providers_without_data.json */; };
1246+
EE5EEDE72D6F2D5400E1EC05 /* WooShippingNormalizedAddress.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE5EEDE62D6F2D4000E1EC05 /* WooShippingNormalizedAddress.swift */; };
12461247
EE62EE61295ACF8D009C965B /* RequestConverterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE62EE60295ACF8D009C965B /* RequestConverterTests.swift */; };
12471248
EE62EE63295AD45E009C965B /* String+URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE62EE62295AD45E009C965B /* String+URL.swift */; };
12481249
EE62EE65295AD46D009C965B /* String+URLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE62EE64295AD46D009C965B /* String+URLTests.swift */; };
@@ -2465,6 +2466,7 @@
24652466
EE57C1532980F18500BC31E7 /* ShipmentTrackingProviderListMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShipmentTrackingProviderListMapperTests.swift; sourceTree = "<group>"; };
24662467
EE57C1552980F3BF00BC31E7 /* shipment_tracking_single_without_data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = shipment_tracking_single_without_data.json; sourceTree = "<group>"; };
24672468
EE57C1572980F3D400BC31E7 /* shipment_tracking_providers_without_data.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = shipment_tracking_providers_without_data.json; sourceTree = "<group>"; };
2469+
EE5EEDE62D6F2D4000E1EC05 /* WooShippingNormalizedAddress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooShippingNormalizedAddress.swift; sourceTree = "<group>"; };
24682470
EE62EE60295ACF8D009C965B /* RequestConverterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestConverterTests.swift; sourceTree = "<group>"; };
24692471
EE62EE62295AD45E009C965B /* String+URL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+URL.swift"; sourceTree = "<group>"; };
24702472
EE62EE64295AD46D009C965B /* String+URLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+URLTests.swift"; sourceTree = "<group>"; };
@@ -2647,6 +2649,7 @@
26472649
451A97C72609FDE50059D135 /* Packages */ = {
26482650
isa = PBXGroup;
26492651
children = (
2652+
EE5EEDE62D6F2D4000E1EC05 /* WooShippingNormalizedAddress.swift */,
26502653
CEC7D5902CDD0C1C00111B79 /* WooShippingCreatePackageResponse.swift */,
26512654
DAF367A72CE75C5B00D1B327 /* WooShippingPackagesResponse.swift */,
26522655
CE1EA4BE2CEBA0AF0039F477 /* WooShippingPackagePurchase.swift */,
@@ -5355,6 +5358,7 @@
53555358
68BFF8FC2B6767FA00B15FF2 /* ReceiptMapper.swift in Sources */,
53565359
EE105F432D671F23005AB07F /* WooShippingDestinationAddressUpdate.swift in Sources */,
53575360
74D522B62113607F00042831 /* StatGranularity.swift in Sources */,
5361+
EE5EEDE72D6F2D5400E1EC05 /* WooShippingNormalizedAddress.swift in Sources */,
53585362
02C2549A25636E1500A04423 /* ShippingLabelAddress.swift in Sources */,
53595363
03DCB786262739D200C8953D /* CouponMapper.swift in Sources */,
53605364
DAEE64282D1048A00031DCDC /* WooShippingOriginAddress.swift in Sources */,

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4215,6 +4215,45 @@ extension Networking.WooShippingDestinationAddress {
42154215
}
42164216
}
42174217

4218+
extension Networking.WooShippingNormalizedAddress {
4219+
public func copy(
4220+
company: CopiableProp<String> = .copy,
4221+
firstName: CopiableProp<String> = .copy,
4222+
lastName: CopiableProp<String> = .copy,
4223+
phone: CopiableProp<String> = .copy,
4224+
country: CopiableProp<String> = .copy,
4225+
state: CopiableProp<String> = .copy,
4226+
address1: CopiableProp<String> = .copy,
4227+
address2: CopiableProp<String> = .copy,
4228+
city: CopiableProp<String> = .copy,
4229+
postcode: CopiableProp<String> = .copy
4230+
) -> Networking.WooShippingNormalizedAddress {
4231+
let company = company ?? self.company
4232+
let firstName = firstName ?? self.firstName
4233+
let lastName = lastName ?? self.lastName
4234+
let phone = phone ?? self.phone
4235+
let country = country ?? self.country
4236+
let state = state ?? self.state
4237+
let address1 = address1 ?? self.address1
4238+
let address2 = address2 ?? self.address2
4239+
let city = city ?? self.city
4240+
let postcode = postcode ?? self.postcode
4241+
4242+
return Networking.WooShippingNormalizedAddress(
4243+
company: company,
4244+
firstName: firstName,
4245+
lastName: lastName,
4246+
phone: phone,
4247+
country: country,
4248+
state: state,
4249+
address1: address1,
4250+
address2: address2,
4251+
city: city,
4252+
postcode: postcode
4253+
)
4254+
}
4255+
}
4256+
42184257
extension Networking.WooShippingOriginAddress {
42194258
public func copy(
42204259
id: CopiableProp<String> = .copy,
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import Foundation
2+
import Codegen
3+
4+
/// Represents a normalized address for the WooCommerce Shipping extension.
5+
///
6+
public struct WooShippingNormalizedAddress: Equatable, GeneratedFakeable, GeneratedCopiable {
7+
/// The name of the company at the address.
8+
public let company: String
9+
10+
/// The first name of the sender/receiver at the address.
11+
public let firstName: String
12+
13+
/// The last name of the sender/receiver at the address.
14+
public let lastName: String
15+
16+
/// The contact phone number at the address.
17+
public let phone: String
18+
19+
/// The country the address is in (ISO code).
20+
public let country: String
21+
22+
/// The state the address is in (ISO code).
23+
public let state: String
24+
25+
/// The first line of address (street, number, floor, etc.).
26+
public let address1: String
27+
28+
/// The second line of address, empty if the address is only one line.
29+
public let address2: String
30+
31+
/// The city the address is in.
32+
public let city: String
33+
34+
/// Postal code of the address.
35+
public let postcode: String
36+
37+
public init(company: String,
38+
firstName: String,
39+
lastName: String,
40+
phone: String,
41+
country: String,
42+
state: String,
43+
address1: String,
44+
address2: String,
45+
city: String,
46+
postcode: String) {
47+
self.company = company
48+
self.firstName = firstName
49+
self.lastName = lastName
50+
self.phone = phone
51+
self.country = country
52+
self.state = state
53+
self.address1 = address1
54+
self.address2 = address2
55+
self.city = city
56+
self.postcode = postcode
57+
}
58+
}
59+
60+
// MARK: Codable
61+
extension WooShippingNormalizedAddress: Decodable {
62+
public init(from decoder: Decoder) throws {
63+
let container = try decoder.container(keyedBy: CodingKeys.self)
64+
let firstName = try container.decodeIfPresent(String.self, forKey: .firstName) ?? ""
65+
let lastName = try container.decodeIfPresent(String.self, forKey: .lastName) ?? ""
66+
let company = try container.decode(String.self, forKey: .company)
67+
let phone = try container.decode(String.self, forKey: .phone)
68+
let country = try container.decode(String.self, forKey: .country)
69+
let state = try container.decode(String.self, forKey: .state)
70+
let address1 = try container.decodeIfPresent(String.self, forKey: .address1) ?? container.decode(String.self, forKey: .alternateAddress1)
71+
let address2 = try container.decode(String.self, forKey: .address2)
72+
let city = try container.decode(String.self, forKey: .city)
73+
let postcode = try container.decode(String.self, forKey: .postcode)
74+
75+
self.init(company: company,
76+
firstName: firstName,
77+
lastName: lastName,
78+
phone: phone,
79+
country: country,
80+
state: state,
81+
address1: address1,
82+
address2: address2,
83+
city: city,
84+
postcode: postcode)
85+
}
86+
87+
private enum CodingKeys: String, CodingKey {
88+
case company
89+
case firstName = "first_name"
90+
case lastName = "last_name"
91+
case phone
92+
case country
93+
case state
94+
case address1 = "address"
95+
case alternateAddress1 = "address_1"
96+
case address2 = "address_2"
97+
case city
98+
case postcode
99+
}
100+
}

Networking/Networking/Model/ShippingLabel/VerifyDestinationAddress/WooShippingVerifyDestinationAddressResponse.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
internal struct WooShippingVerifyDestinationAddressResponse: Equatable {
1010
let result: Result<WooShippingVerifyDestinationAddressSuccess, WooShippingAddressValidationError>
1111

12-
init(normalizedAddress: WooShippingAddress?,
12+
init(normalizedAddress: WooShippingNormalizedAddress?,
1313
isTrivialNormalization: Bool?,
1414
isVerified: Bool?,
1515
errors: WooShippingAddressValidationError?) {
@@ -31,7 +31,7 @@ internal struct WooShippingVerifyDestinationAddressResponse: Equatable {
3131
extension WooShippingVerifyDestinationAddressResponse: Decodable {
3232
init(from decoder: Decoder) throws {
3333
let container = try decoder.container(keyedBy: CodingKeys.self)
34-
let normalizedAddress = try container.decodeIfPresent(WooShippingAddress.self, forKey: .normalized)
34+
let normalizedAddress = try container.decodeIfPresent(WooShippingNormalizedAddress.self, forKey: .normalized)
3535
let isTrivialNormalization = try container.decodeIfPresent(Bool.self, forKey: .isTrivialNormalization)
3636
let isVerified = try container.decodeIfPresent(Bool.self, forKey: .isVerified)
3737
let errors = try container.decodeIfPresent(WooShippingAddressValidationError.self, forKey: .errors)

Networking/Networking/Model/ShippingLabel/VerifyDestinationAddress/WooShippingVerifyDestinationAddressSuccess.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Codegen
44
/// Represents Shipping Label Destination Address that has been verified by the WooCommerce Shipping extension.
55
///
66
public struct WooShippingVerifyDestinationAddressSuccess: Equatable {
7-
public let normalizedAddress: WooShippingAddress
7+
public let normalizedAddress: WooShippingNormalizedAddress
88

99
/// Optional property - We will receive this property in response only when the address is not already verified.
1010
///
@@ -17,7 +17,7 @@ public struct WooShippingVerifyDestinationAddressSuccess: Equatable {
1717

1818
public let isVerified: Bool
1919

20-
public init(normalizedAddress: WooShippingAddress,
20+
public init(normalizedAddress: WooShippingNormalizedAddress,
2121
isTrivialNormalization: Bool?,
2222
isVerified: Bool) {
2323
self.normalizedAddress = normalizedAddress

Networking/Networking/Model/ShippingLabel/WooShippingAddressValidationResponse.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
internal struct WooShippingAddressValidationResponse: Equatable {
1010
let result: Result<WooShippingAddressValidationSuccess, WooShippingAddressValidationError>
1111

12-
init(normalizedAddress: WooShippingAddress?,
12+
init(normalizedAddress: WooShippingNormalizedAddress?,
1313
originalAddress: WooShippingAddress?,
1414
isTrivialNormalization: Bool?,
1515
errors: WooShippingAddressValidationError?) {
@@ -30,7 +30,7 @@ internal struct WooShippingAddressValidationResponse: Equatable {
3030
extension WooShippingAddressValidationResponse: Decodable {
3131
init(from decoder: Decoder) throws {
3232
let container = try decoder.container(keyedBy: CodingKeys.self)
33-
let normalizedAddress = try container.decodeIfPresent(WooShippingAddress.self, forKey: .normalized)
33+
let normalizedAddress = try container.decodeIfPresent(WooShippingNormalizedAddress.self, forKey: .normalized)
3434
let originalAddress = try container.decodeIfPresent(WooShippingAddress.self, forKey: .original)
3535
let isTrivialNormalization = try container.decodeIfPresent(Bool.self, forKey: .isTrivialNormalization)
3636
let errors = try container.decodeIfPresent(WooShippingAddressValidationError.self, forKey: .errors)

Networking/Networking/Model/ShippingLabel/WooShippingAddressValidationSuccess.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Codegen
55
/// Represents Shipping Label Address that has been validated by the WooCommerce Shipping extension.
66
///
77
public struct WooShippingAddressValidationSuccess: Equatable {
8-
public let normalizedAddress: WooShippingAddress
8+
public let normalizedAddress: WooShippingNormalizedAddress
99
public let originalAddress: WooShippingAddress
1010

1111
/// When sending an address to normalize to the server, if the response has the is_trivial_normalization property set to true,
@@ -15,7 +15,7 @@ public struct WooShippingAddressValidationSuccess: Equatable {
1515
///
1616
public let isTrivialNormalization: Bool
1717

18-
public init(normalizedAddress: WooShippingAddress, originalAddress: WooShippingAddress, isTrivialNormalization: Bool) {
18+
public init(normalizedAddress: WooShippingNormalizedAddress, originalAddress: WooShippingAddress, isTrivialNormalization: Bool) {
1919
self.normalizedAddress = normalizedAddress
2020
self.originalAddress = originalAddress
2121
self.isTrivialNormalization = isTrivialNormalization

Networking/Networking/Remote/WooShippingRemote.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ public final class WooShippingRemote: Remote, WooShippingRemoteProtocol {
213213
ParameterKey.destinationAddress: try destinationAddress.toDictionary(),
214214
ParameterKey.packages: [ try package.toDictionary() ],
215215
ParameterKey.selectedRate: try package.encodedShipmentRate(),
216+
// TODO: `selected_rate_options` will be updated while adding UPS support PaJDVv-2Gf-p2
217+
ParameterKey.selectedRateOptions: [:],
216218
ParameterKey.hazmat: package.encodedHazmat(),
217219
ParameterKey.customs: try package.encodedCustomsForm(),
218220
]
@@ -431,6 +433,7 @@ private extension WooShippingRemote {
431433
static let packages = "packages"
432434
static let async = "async"
433435
static let selectedRate = "selected_rate"
436+
static let selectedRateOptions = "selected_rate_options"
434437
static let hazmat = "hazmat"
435438
static let customs = "customs"
436439
static let paperSize = "paper_size"

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
21.9
55
-----
6+
- [*] Product Form: Reset uploaded images upon discarding changes [https://github.com/woocommerce/woocommerce-ios/pull/15265]
67

78

89
21.8

0 commit comments

Comments
 (0)