Skip to content

Commit de9ba54

Browse files
committed
Add refundedItemID property in Networking and Yosemite
1 parent 5898522 commit de9ba54

File tree

6 files changed

+28
-0
lines changed

6 files changed

+28
-0
lines changed

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@
494494
B5C6FCD420A373BB00A4F8E4 /* OrderMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6FCD320A373BA00A4F8E4 /* OrderMapper.swift */; };
495495
B5C6FCD620A3768900A4F8E4 /* order.json in Resources */ = {isa = PBXBuildFile; fileRef = B5C6FCD520A3768900A4F8E4 /* order.json */; };
496496
B5DAEFF02180DD5A0002356A /* NotificationsRemote.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5DAEFEF2180DD5A0002356A /* NotificationsRemote.swift */; };
497+
B963A5CC2853870000EFADA0 /* OrderItemRefundMetaData.swift in Sources */ = {isa = PBXBuildFile; fileRef = B963A5CB2853870000EFADA0 /* OrderItemRefundMetaData.swift */; };
497498
BAB373722795A1FB00837B4A /* OrderTaxLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAB373712795A1FB00837B4A /* OrderTaxLine.swift */; };
498499
CC07865F267799EE00BA9AC1 /* ShippingLabelPurchase.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC07865E267799EE00BA9AC1 /* ShippingLabelPurchase.swift */; };
499500
CC0786612677B2DA00BA9AC1 /* ShippingLabelPurchaseMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC0786602677B2DA00BA9AC1 /* ShippingLabelPurchaseMapper.swift */; };
@@ -1173,6 +1174,7 @@
11731174
B5C6FCD320A373BA00A4F8E4 /* OrderMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderMapper.swift; sourceTree = "<group>"; };
11741175
B5C6FCD520A3768900A4F8E4 /* order.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = order.json; sourceTree = "<group>"; };
11751176
B5DAEFEF2180DD5A0002356A /* NotificationsRemote.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationsRemote.swift; sourceTree = "<group>"; };
1177+
B963A5CB2853870000EFADA0 /* OrderItemRefundMetaData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderItemRefundMetaData.swift; sourceTree = "<group>"; };
11761178
BAB373712795A1FB00837B4A /* OrderTaxLine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderTaxLine.swift; sourceTree = "<group>"; };
11771179
BD9439D9B8F2C1ED2EADAA51 /* Pods-NetworkingTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NetworkingTests.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-NetworkingTests/Pods-NetworkingTests.debug.xcconfig"; sourceTree = "<group>"; };
11781180
C8F9A8CC6F90A8C9B5EF2EE2 /* Pods-Networking.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Networking.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Networking/Pods-Networking.release.xcconfig"; sourceTree = "<group>"; };
@@ -1458,6 +1460,7 @@
14581460
CE43066923465F340073CBFF /* Refund.swift */,
14591461
CE43066B2347C5F90073CBFF /* OrderItemRefund.swift */,
14601462
CE43066D2347CBA70073CBFF /* OrderItemTaxRefund.swift */,
1463+
B963A5CB2853870000EFADA0 /* OrderItemRefundMetaData.swift */,
14611464
);
14621465
path = Refund;
14631466
sourceTree = "<group>";
@@ -2927,6 +2930,7 @@
29272930
77CE40602514CB3E003FF69D /* ProductDownloadDragAndDrop.swift in Sources */,
29282931
2685C0FE263B5D8900D9EE97 /* AddOnGroupRemote.swift in Sources */,
29292932
450106912399B2C800E24722 /* TaxClassListMapper.swift in Sources */,
2933+
B963A5CC2853870000EFADA0 /* OrderItemRefundMetaData.swift in Sources */,
29302934
0329CF9B27A82E19008AFF91 /* WCPayCharge.swift in Sources */,
29312935
74749B97224134FF005C4CF2 /* ProductMapper.swift in Sources */,
29322936
26455E2A25F669F0008A1D32 /* ProductAttributeTermMapper.swift in Sources */,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ extension OrderItemRefund {
451451
name: CopiableProp<String> = .copy,
452452
productID: CopiableProp<Int64> = .copy,
453453
variationID: CopiableProp<Int64> = .copy,
454+
refundedItemID: CopiableProp<Int64> = .copy,
454455
quantity: CopiableProp<Decimal> = .copy,
455456
price: CopiableProp<NSDecimalNumber> = .copy,
456457
sku: NullableCopiableProp<String> = .copy,
@@ -465,6 +466,7 @@ extension OrderItemRefund {
465466
let name = name ?? self.name
466467
let productID = productID ?? self.productID
467468
let variationID = variationID ?? self.variationID
469+
let refundedItemID = refundedItemID ?? self.refundedItemID
468470
let quantity = quantity ?? self.quantity
469471
let price = price ?? self.price
470472
let sku = sku ?? self.sku
@@ -480,6 +482,7 @@ extension OrderItemRefund {
480482
name: name,
481483
productID: productID,
482484
variationID: variationID,
485+
refundedItemID: refundedItemID,
483486
quantity: quantity,
484487
price: price,
485488
sku: sku,

Networking/Networking/Model/Refund/OrderItemRefund.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public struct OrderItemRefund: Codable, Equatable, GeneratedFakeable, GeneratedC
88
public let name: String
99
public let productID: Int64
1010
public let variationID: Int64
11+
public let refundedItemID: Int64?
1112
public let quantity: Decimal
1213

1314
/// Price is a currency.
@@ -30,6 +31,7 @@ public struct OrderItemRefund: Codable, Equatable, GeneratedFakeable, GeneratedC
3031
name: String,
3132
productID: Int64,
3233
variationID: Int64,
34+
refundedItemID: Int64?,
3335
quantity: Decimal,
3436
price: NSDecimalNumber,
3537
sku: String?,
@@ -43,6 +45,7 @@ public struct OrderItemRefund: Codable, Equatable, GeneratedFakeable, GeneratedC
4345
self.name = name
4446
self.productID = productID
4547
self.variationID = variationID
48+
self.refundedItemID = refundedItemID
4649
self.quantity = quantity
4750
self.price = price
4851
self.sku = sku
@@ -76,11 +79,20 @@ public struct OrderItemRefund: Codable, Equatable, GeneratedFakeable, GeneratedC
7679
let total = try container.decode(String.self, forKey: .total)
7780
let totalTax = try container.decode(String.self, forKey: .totalTax)
7881

82+
let metaData = try? container.decode(OrderItemRefundMetaData.self, forKey: .metadata)
83+
84+
var refundedItemID: Int64?
85+
if let metaData = metaData,
86+
metaData.key == "_refunded_item_id" {
87+
refundedItemID = Int64(metaData.value)
88+
}
89+
7990
// initialize the struct
8091
self.init(itemID: itemID,
8192
name: name,
8293
productID: productID,
8394
variationID: variationID,
95+
refundedItemID: refundedItemID,
8496
quantity: quantity,
8597
price: price,
8698
sku: sku,
@@ -131,6 +143,7 @@ private extension OrderItemRefund {
131143
case total
132144
case totalTax = "total_tax"
133145
case taxes
146+
case metadata = "meta_data"
134147
}
135148

136149
enum EncodingKeys: String, CodingKey {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
import Foundation
3+
4+
typealias OrderItemRefundMetaData = OrderMetaData

WooCommerce/Classes/ViewRelated/Orders/Order Details/Issue Refunds/UseCases/RefundCreationUseCase.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct RefundCreationUseCase {
5858
name: "",
5959
productID: .min,
6060
variationID: .min,
61+
refundedItemID: nil,
6162
quantity: Decimal(refundable.quantity),
6263
price: .zero,
6364
sku: nil,
@@ -87,6 +88,7 @@ struct RefundCreationUseCase {
8788
name: "",
8889
productID: .min,
8990
variationID: .min,
91+
refundedItemID: nil,
9092
quantity: .zero,
9193
price: .zero,
9294
sku: nil,
@@ -106,6 +108,7 @@ struct RefundCreationUseCase {
106108
name: "",
107109
productID: .min,
108110
variationID: .min,
111+
refundedItemID: nil,
109112
quantity: .zero,
110113
price: .zero,
111114
sku: nil,

Yosemite/Yosemite/Model/Storage/OrderItemRefund+ReadOnlyConvertible.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extension Storage.OrderItemRefund: ReadOnlyConvertible {
3232
name: name ?? "",
3333
productID: productID,
3434
variationID: variationID,
35+
refundedItemID: refundedItemID,
3536
quantity: quantity?.decimalValue ?? Decimal.zero,
3637
price: price ?? NSDecimalNumber(integerLiteral: 0),
3738
sku: sku,

0 commit comments

Comments
 (0)