Skip to content

Commit 263dc79

Browse files
committed
Update WCAnalyticsCustomer with siteID param
1 parent e57ddbc commit 263dc79

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Fakes/Fakes/Networking.generated.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,7 @@ extension WCAnalyticsCustomer {
17001700
///
17011701
public static func fake() -> WCAnalyticsCustomer {
17021702
.init(
1703+
siteID: .fake(),
17031704
userID: .fake(),
17041705
name: .fake()
17051706
)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,13 +1953,16 @@ extension TopEarnerStatsItem {
19531953

19541954
extension WCAnalyticsCustomer {
19551955
public func copy(
1956+
siteID: CopiableProp<Int64> = .copy,
19561957
userID: CopiableProp<Int64> = .copy,
19571958
name: NullableCopiableProp<String> = .copy
19581959
) -> WCAnalyticsCustomer {
1960+
let siteID = siteID ?? self.siteID
19591961
let userID = userID ?? self.userID
19601962
let name = name ?? self.name
19611963

19621964
return WCAnalyticsCustomer(
1965+
siteID: siteID,
19631966
userID: userID,
19641967
name: name
19651968
)

Networking/Networking/Model/WCAnalyticsCustomer.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import Foundation
22
import Codegen
33

44
public struct WCAnalyticsCustomer: Codable, GeneratedCopiable, GeneratedFakeable {
5+
/// The siteID for the WCAnalyticsCustomer
6+
public let siteID: Int64
57

68
/// Unique identifier for the user
79
public let userID: Int64
@@ -11,20 +13,25 @@ public struct WCAnalyticsCustomer: Codable, GeneratedCopiable, GeneratedFakeable
1113

1214
/// WCAnalyticsCustomer struct Initializer
1315
///
14-
public init(userID: Int64, name: String?) {
16+
public init(siteID: Int64, userID: Int64, name: String?) {
17+
self.siteID = siteID
1518
self.userID = userID
1619
self.name = name
1720
}
1821

1922
/// Public initializer for WCAnalyticsCustomer
2023
///
2124
public init(from decoder: Decoder) throws {
25+
guard let siteID = decoder.userInfo[.siteID] as? Int64 else {
26+
throw WCAnalyticsCustomerDecodingError.missingSiteID
27+
}
28+
2229
let container = try decoder.container(keyedBy: CodingKeys.self)
2330

2431
let userID = try container.decode(Int64.self, forKey: .userID)
2532
let name = try container.decode(String.self, forKey: .name)
2633

27-
self.init(userID: userID, name: name)
34+
self.init(siteID: siteID, userID: userID, name: name)
2835
}
2936
}
3037

@@ -33,4 +40,8 @@ extension WCAnalyticsCustomer {
3340
case userID = "user_id"
3441
case name = "name"
3542
}
43+
44+
enum WCAnalyticsCustomerDecodingError: Error {
45+
case missingSiteID
46+
}
3647
}

0 commit comments

Comments
 (0)