Skip to content

Commit 3107322

Browse files
authored
Merge branch 'trunk' into merge/release-21.8-into-trunk
2 parents b2dc723 + a41a5ce commit 3107322

File tree

17 files changed

+479
-32
lines changed

17 files changed

+479
-32
lines changed

Fakes/Fakes/Networking.generated.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,6 +2827,26 @@ extension Networking.WooShippingCustomPackage {
28272827
)
28282828
}
28292829
}
2830+
extension Networking.WooShippingDestinationAddress {
2831+
/// Returns a "ready to use" type filled with fake values.
2832+
///
2833+
public static func fake() -> Networking.WooShippingDestinationAddress {
2834+
.init(
2835+
company: .fake(),
2836+
address1: .fake(),
2837+
address2: .fake(),
2838+
city: .fake(),
2839+
state: .fake(),
2840+
postcode: .fake(),
2841+
country: .fake(),
2842+
phone: .fake(),
2843+
name: .fake(),
2844+
firstName: .fake(),
2845+
lastName: .fake(),
2846+
email: .fake()
2847+
)
2848+
}
2849+
}
28302850
extension Networking.WooShippingOriginAddress {
28312851
/// Returns a "ready to use" type filled with fake values.
28322852
///

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,10 @@
11741174
EE1042B12D65CF9D005AB07F /* WooShippingVerifyDestinationAddressSuccess.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1042B02D65CF9A005AB07F /* WooShippingVerifyDestinationAddressSuccess.swift */; };
11751175
EE1042B42D65DF9B005AB07F /* wooshipping-verify-destination-success.json in Resources */ = {isa = PBXBuildFile; fileRef = EE1042B32D65DF9B005AB07F /* wooshipping-verify-destination-success.json */; };
11761176
EE1042B52D65DF9B005AB07F /* wooshipping-verify-destination-error.json in Resources */ = {isa = PBXBuildFile; fileRef = EE1042B22D65DF9B005AB07F /* wooshipping-verify-destination-error.json */; };
1177+
EE105F412D671EDB005AB07F /* WooShippingDestinationAddressUpdateMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE105F402D671ED3005AB07F /* WooShippingDestinationAddressUpdateMapper.swift */; };
1178+
EE105F432D671F23005AB07F /* WooShippingDestinationAddressUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE105F422D671F1D005AB07F /* WooShippingDestinationAddressUpdate.swift */; };
1179+
EE105F452D671F57005AB07F /* WooShippingDestinationAddress.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE105F442D671F57005AB07F /* WooShippingDestinationAddress.swift */; };
1180+
EE105F472D672AB2005AB07F /* wooshipping-update-destination-success.json in Resources */ = {isa = PBXBuildFile; fileRef = EE105F462D672AB2005AB07F /* wooshipping-update-destination-success.json */; };
11771181
EE1217DC2AFE04A500E6CAB1 /* ProductVariationEncoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1217DB2AFE04A500E6CAB1 /* ProductVariationEncoderTests.swift */; };
11781182
EE1CB9002B4BC85B00AD24D5 /* BlazeTargetOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1CB8FC2B4BC85B00AD24D5 /* BlazeTargetOptions.swift */; };
11791183
EE1CB9012B4BC85B00AD24D5 /* CreateBlazeCampaign.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE1CB8FD2B4BC85B00AD24D5 /* CreateBlazeCampaign.swift */; };
@@ -2392,6 +2396,10 @@
23922396
EE1042B02D65CF9A005AB07F /* WooShippingVerifyDestinationAddressSuccess.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooShippingVerifyDestinationAddressSuccess.swift; sourceTree = "<group>"; };
23932397
EE1042B22D65DF9B005AB07F /* wooshipping-verify-destination-error.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "wooshipping-verify-destination-error.json"; sourceTree = "<group>"; };
23942398
EE1042B32D65DF9B005AB07F /* wooshipping-verify-destination-success.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "wooshipping-verify-destination-success.json"; sourceTree = "<group>"; };
2399+
EE105F402D671ED3005AB07F /* WooShippingDestinationAddressUpdateMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooShippingDestinationAddressUpdateMapper.swift; sourceTree = "<group>"; };
2400+
EE105F422D671F1D005AB07F /* WooShippingDestinationAddressUpdate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooShippingDestinationAddressUpdate.swift; sourceTree = "<group>"; };
2401+
EE105F442D671F57005AB07F /* WooShippingDestinationAddress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WooShippingDestinationAddress.swift; sourceTree = "<group>"; };
2402+
EE105F462D672AB2005AB07F /* wooshipping-update-destination-success.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "wooshipping-update-destination-success.json"; sourceTree = "<group>"; };
23952403
EE1217DB2AFE04A500E6CAB1 /* ProductVariationEncoderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductVariationEncoderTests.swift; sourceTree = "<group>"; };
23962404
EE1CB8FC2B4BC85B00AD24D5 /* BlazeTargetOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlazeTargetOptions.swift; sourceTree = "<group>"; };
23972405
EE1CB8FD2B4BC85B00AD24D5 /* CreateBlazeCampaign.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateBlazeCampaign.swift; sourceTree = "<group>"; };
@@ -2639,6 +2647,8 @@
26392647
CE1EA4BE2CEBA0AF0039F477 /* WooShippingPackagePurchase.swift */,
26402648
DAEE64272D1048930031DCDC /* WooShippingOriginAddress.swift */,
26412649
CED9BCCC2D3FE1E600C063B8 /* WooShippingOriginAddressUpdate.swift */,
2650+
EE105F442D671F57005AB07F /* WooShippingDestinationAddress.swift */,
2651+
EE105F422D671F1D005AB07F /* WooShippingDestinationAddressUpdate.swift */,
26422652
451A97C82609FF050059D135 /* ShippingLabelPackagesResponse.swift */,
26432653
451A97CC260A01A40059D135 /* ShippingLabelStoreOptions.swift */,
26442654
CCAAD10E2683974000909664 /* ShippingLabelPackagePurchase.swift */,
@@ -3155,6 +3165,7 @@
31553165
B559EBA820A0B5B100836CD4 /* Responses */ = {
31563166
isa = PBXGroup;
31573167
children = (
3168+
EE105F462D672AB2005AB07F /* wooshipping-update-destination-success.json */,
31583169
DE8BEF0C2D151396008B3A3F /* notification-settings.json */,
31593170
EED25B1C2CF74B9800503657 /* media-upload.json */,
31603171
EE6C6B6F2C6A190500632BDA /* systemStatus-inconsistent-page-id-data-type.json */,
@@ -3735,6 +3746,7 @@
37353746
DAF367A12CE75B9D00D1B327 /* WooShippingPackagesMapper.swift */,
37363747
DAEE64292D104B720031DCDC /* WooShippingOriginAddressesMapper.swift */,
37373748
CED9BCCA2D3FE0E400C063B8 /* WooShippingOriginAddressMapper.swift */,
3749+
EE105F402D671ED3005AB07F /* WooShippingDestinationAddressUpdateMapper.swift */,
37383750
CED9BCC42D3EBD0D00C063B8 /* WooShippingAddressValidationSuccessMapper.swift */,
37393751
EE1042AC2D65CE5E005AB07F /* WooShippingVerifyDestinationAddressMapper.swift */,
37403752
CE90E99D2CEFCB100068D852 /* WooShippingStatusMapper.swift */,
@@ -4826,6 +4838,7 @@
48264838
314EDF2B27C02CD300A56B6F /* stripe-account-complete-null-descriptor.json in Resources */,
48274839
B9CB14DE2A42DE60005912C2 /* products-sku-search-non-purchasable.json in Resources */,
48284840
31054720262E2F9D00C5C02B /* wcpay-payment-intent-processing.json in Resources */,
4841+
EE105F472D672AB2005AB07F /* wooshipping-update-destination-success.json in Resources */,
48294842
0239306D291A973F00B2632F /* domain-suggestions.json in Resources */,
48304843
);
48314844
runOnlyForDeploymentPostprocessing = 0;
@@ -5159,6 +5172,7 @@
51595172
DE74F29A27E08F5A0002FE59 /* SiteSettingMapper.swift in Sources */,
51605173
CC33754E29C884000006A538 /* ProductCompositeComponent.swift in Sources */,
51615174
DAA259AF2CECF4AF0035F028 /* WooShippingAccountSettings.swift in Sources */,
5175+
EE105F412D671EDB005AB07F /* WooShippingDestinationAddressUpdateMapper.swift in Sources */,
51625176
450106852399A7CB00E24722 /* TaxClass.swift in Sources */,
51635177
DE2004572BF5C22600660A72 /* ProductStockListMapper.swift in Sources */,
51645178
68BFF8FA2B67679700B15FF2 /* ReceiptRemote.swift in Sources */,
@@ -5329,6 +5343,7 @@
53295343
93D8BBFD226BBEE800AD2EB3 /* AccountSettingsMapper.swift in Sources */,
53305344
31D27C8726028CE9002EDB1D /* SitePluginsMapper.swift in Sources */,
53315345
68BFF8FC2B6767FA00B15FF2 /* ReceiptMapper.swift in Sources */,
5346+
EE105F432D671F23005AB07F /* WooShippingDestinationAddressUpdate.swift in Sources */,
53325347
74D522B62113607F00042831 /* StatGranularity.swift in Sources */,
53335348
02C2549A25636E1500A04423 /* ShippingLabelAddress.swift in Sources */,
53345349
03DCB786262739D200C8953D /* CouponMapper.swift in Sources */,
@@ -5434,6 +5449,7 @@
54345449
68CB800C28D87BC800E169F8 /* Customer.swift in Sources */,
54355450
EE1CB90A2B4BC8C500AD24D5 /* CreateBlazeCampaignMapper.swift in Sources */,
54365451
264541B72CA64522006C13A2 /* WooShippingRemote.swift in Sources */,
5452+
EE105F452D671F57005AB07F /* WooShippingDestinationAddress.swift in Sources */,
54375453
B96158FC2BF63B4F0080E52A /* String+MinMaxQuantities.swift in Sources */,
54385454
DE50295D28C6068B00551736 /* JetpackUserMapper.swift in Sources */,
54395455
B524194121AC60A700D6FC0A /* DotcomDevice.swift in Sources */,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Foundation
2+
3+
struct WooShippingDestinationAddressUpdateMapper: Mapper {
4+
/// (Attempts) to convert a dictionary into a WooShippingDestinationAddressUpdate.
5+
///
6+
func map(response: Data) throws -> WooShippingDestinationAddressUpdate {
7+
let decoder = JSONDecoder()
8+
if hasDataEnvelope(in: response) {
9+
return try decoder.decode(WooShippingDestinationAddressUpdateMapperEnvelope.self, from: response).data
10+
} else {
11+
return try decoder.decode(WooShippingDestinationAddressUpdate.self, from: response)
12+
}
13+
}
14+
}
15+
16+
/// WooShippingDestinationAddressUpdateMapperEnvelope Disposable Entity:
17+
/// `Woo Shipping Update Destination Address` endpoint returns the updated data in the `data` key.
18+
/// This entity allows us to do parse all the things with JSONDecoder.
19+
///
20+
private struct WooShippingDestinationAddressUpdateMapperEnvelope: Decodable {
21+
let data: WooShippingDestinationAddressUpdate
22+
23+
private enum CodingKeys: String, CodingKey {
24+
case data = "data"
25+
}
26+
}

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4131,6 +4131,51 @@ extension Networking.WooShippingCustomPackage {
41314131
}
41324132
}
41334133

4134+
extension Networking.WooShippingDestinationAddress {
4135+
public func copy(
4136+
company: CopiableProp<String> = .copy,
4137+
address1: CopiableProp<String> = .copy,
4138+
address2: CopiableProp<String> = .copy,
4139+
city: CopiableProp<String> = .copy,
4140+
state: CopiableProp<String> = .copy,
4141+
postcode: CopiableProp<String> = .copy,
4142+
country: CopiableProp<String> = .copy,
4143+
phone: CopiableProp<String> = .copy,
4144+
name: CopiableProp<String> = .copy,
4145+
firstName: CopiableProp<String> = .copy,
4146+
lastName: CopiableProp<String> = .copy,
4147+
email: CopiableProp<String> = .copy
4148+
) -> Networking.WooShippingDestinationAddress {
4149+
let company = company ?? self.company
4150+
let address1 = address1 ?? self.address1
4151+
let address2 = address2 ?? self.address2
4152+
let city = city ?? self.city
4153+
let state = state ?? self.state
4154+
let postcode = postcode ?? self.postcode
4155+
let country = country ?? self.country
4156+
let phone = phone ?? self.phone
4157+
let name = name ?? self.name
4158+
let firstName = firstName ?? self.firstName
4159+
let lastName = lastName ?? self.lastName
4160+
let email = email ?? self.email
4161+
4162+
return Networking.WooShippingDestinationAddress(
4163+
company: company,
4164+
address1: address1,
4165+
address2: address2,
4166+
city: city,
4167+
state: state,
4168+
postcode: postcode,
4169+
country: country,
4170+
phone: phone,
4171+
name: name,
4172+
firstName: firstName,
4173+
lastName: lastName,
4174+
email: email
4175+
)
4176+
}
4177+
}
4178+
41344179
extension Networking.WooShippingOriginAddress {
41354180
public func copy(
41364181
id: CopiableProp<String> = .copy,
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import Foundation
2+
import Codegen
3+
4+
public struct WooShippingDestinationAddress: Equatable, GeneratedFakeable, GeneratedCopiable {
5+
public let company: String
6+
public let address1: String
7+
public let address2: String
8+
public let city: String
9+
public let state: String
10+
public let postcode: String
11+
public let country: String
12+
public let phone: String
13+
public let name: String
14+
public let firstName: String
15+
public let lastName: String
16+
public let email: String
17+
18+
public init(company: String,
19+
address1: String,
20+
address2: String,
21+
city: String,
22+
state: String,
23+
postcode: String,
24+
country: String,
25+
phone: String,
26+
name: String,
27+
firstName: String,
28+
lastName: String,
29+
email: String) {
30+
self.company = company
31+
self.address1 = address1
32+
self.address2 = address2
33+
self.city = city
34+
self.state = state
35+
self.postcode = postcode
36+
self.country = country
37+
self.phone = phone
38+
self.name = name
39+
self.firstName = firstName
40+
self.lastName = lastName
41+
self.email = email
42+
}
43+
}
44+
45+
// MARK: Decodable
46+
extension WooShippingDestinationAddress: Codable {
47+
public init(from decoder: Decoder) throws {
48+
let container = try decoder.container(keyedBy: CodingKeys.self)
49+
50+
let company = try container.decodeIfPresent(String.self, forKey: CodingKeys.company) ?? ""
51+
let address1 = try container.decodeIfPresent(String.self, forKey: CodingKeys.address1) ?? ""
52+
let address2 = try container.decodeIfPresent(String.self, forKey: CodingKeys.address2) ?? ""
53+
let city = try container.decodeIfPresent(String.self, forKey: CodingKeys.city) ?? ""
54+
let state = try container.decodeIfPresent(String.self, forKey: CodingKeys.state) ?? ""
55+
let postcode = try container.decodeIfPresent(String.self, forKey: CodingKeys.postcode) ?? ""
56+
let country = try container.decodeIfPresent(String.self, forKey: CodingKeys.country) ?? ""
57+
let phone = try container.decodeIfPresent(String.self, forKey: CodingKeys.phone) ?? ""
58+
let name = try container.decodeIfPresent(String.self, forKey: CodingKeys.name) ?? ""
59+
let firstName = try container.decodeIfPresent(String.self, forKey: CodingKeys.firstName) ?? ""
60+
let lastName = try container.decodeIfPresent(String.self, forKey: CodingKeys.lastName) ?? ""
61+
let email = try container.decodeIfPresent(String.self, forKey: CodingKeys.email) ?? ""
62+
63+
self.init(company: company,
64+
address1: address1,
65+
address2: address2,
66+
city: city,
67+
state: state,
68+
postcode: postcode,
69+
country: country,
70+
phone: phone,
71+
name: name,
72+
firstName: firstName,
73+
lastName: lastName,
74+
email: email)
75+
}
76+
77+
public func encode(to encoder: any Encoder) throws {
78+
var container = encoder.container(keyedBy: CodingKeys.self)
79+
try container.encode(self.company, forKey: .company)
80+
try container.encode(self.address1, forKey: .address1)
81+
try container.encode(self.address2, forKey: .address2)
82+
try container.encode(self.city, forKey: .city)
83+
try container.encode(self.state, forKey: .state)
84+
try container.encode(self.postcode, forKey: .postcode)
85+
try container.encode(self.country, forKey: .country)
86+
try container.encode(self.phone, forKey: .phone)
87+
try container.encode(self.name, forKey: .name)
88+
try container.encode(self.firstName, forKey: .firstName)
89+
try container.encode(self.lastName, forKey: .lastName)
90+
try container.encode(self.email, forKey: .email)
91+
}
92+
93+
private enum CodingKeys: String, CodingKey {
94+
case company
95+
case address1 = "address_1"
96+
case address2 = "address_2"
97+
case city
98+
case state
99+
case postcode
100+
case country
101+
case phone
102+
case name = "name"
103+
case firstName = "first_name"
104+
case lastName = "last_name"
105+
case email
106+
}
107+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import Foundation
2+
import Codegen
3+
4+
/// Represents the response when an Destination address is updated in the WooCommerce Shipping extension.
5+
public struct WooShippingDestinationAddressUpdate: Equatable {
6+
public let address: WooShippingDestinationAddress
7+
public let isVerified: Bool
8+
9+
public init(address: WooShippingDestinationAddress,
10+
isVerified: Bool) {
11+
self.address = address
12+
self.isVerified = isVerified
13+
}
14+
}
15+
16+
// MARK: Decodable
17+
extension WooShippingDestinationAddressUpdate: Decodable {
18+
public init(from decoder: Decoder) throws {
19+
let container = try decoder.container(keyedBy: CodingKeys.self)
20+
21+
let address = try container.decode(WooShippingDestinationAddress.self, forKey: .address)
22+
let isVerified = try container.decode(Bool.self, forKey: .isVerified)
23+
24+
self.init(address: address,
25+
isVerified: isVerified)
26+
}
27+
28+
private enum CodingKeys: String, CodingKey {
29+
case address
30+
case isVerified
31+
}
32+
}

0 commit comments

Comments
 (0)