Skip to content

Commit f0435e6

Browse files
committed
Merge remote-tracking branch 'origin/develop' into issue/90-load-sites-remote
2 parents 6f92335 + d877b7f commit f0435e6

Some content is hidden

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

48 files changed

+1605
-3194
lines changed

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
/* Begin PBXBuildFile section */
1010
21DB5B99C4107CF69C0A57EC /* Pods_NetworkingTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 69314EDE650855CAF927057E /* Pods_NetworkingTests.framework */; };
1111
6647C0161DAC6AB6570C53A7 /* Pods_Networking.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3F25DC15EC1D7C631169CB5 /* Pods_Networking.framework */; };
12+
741B950120EBC8A700DD6E2D /* OrderCouponLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741B950020EBC8A700DD6E2D /* OrderCouponLine.swift */; };
13+
74C8F06420EEB44800B6EDC9 /* OrderNote.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C8F06320EEB44800B6EDC9 /* OrderNote.swift */; };
14+
74C8F06620EEB76400B6EDC9 /* order-notes.json in Resources */ = {isa = PBXBuildFile; fileRef = 74C8F06520EEB76400B6EDC9 /* order-notes.json */; };
15+
74C8F06820EEB7BD00B6EDC9 /* OrderNotesMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C8F06720EEB7BC00B6EDC9 /* OrderNotesMapper.swift */; };
16+
74C8F06A20EEBC8C00B6EDC9 /* OrderMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C8F06920EEBC8C00B6EDC9 /* OrderMapperTests.swift */; };
17+
74C8F06C20EEBD5D00B6EDC9 /* broken-order.json in Resources */ = {isa = PBXBuildFile; fileRef = 74C8F06B20EEBD5D00B6EDC9 /* broken-order.json */; };
18+
74C8F06E20EEC1E800B6EDC9 /* OrderNotesMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C8F06D20EEC1E700B6EDC9 /* OrderNotesMapperTests.swift */; };
19+
74C8F07020EEC3A800B6EDC9 /* broken-notes.json in Resources */ = {isa = PBXBuildFile; fileRef = 74C8F06F20EEC3A800B6EDC9 /* broken-notes.json */; };
1220
B505F6CD20BEE37E00BB1B69 /* AccountMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505F6CC20BEE37E00BB1B69 /* AccountMapper.swift */; };
1321
B505F6CF20BEE38B00BB1B69 /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505F6CE20BEE38B00BB1B69 /* Account.swift */; };
1422
B505F6D120BEE39600BB1B69 /* AccountRemote.swift in Sources */ = {isa = PBXBuildFile; fileRef = B505F6D020BEE39600BB1B69 /* AccountRemote.swift */; };
@@ -51,7 +59,7 @@
5159
B5C6FCCF20A3592900A4F8E4 /* OrderItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6FCCE20A3592900A4F8E4 /* OrderItem.swift */; };
5260
B5C6FCD420A373BB00A4F8E4 /* OrderMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C6FCD320A373BA00A4F8E4 /* OrderMapper.swift */; };
5361
B5C6FCD620A3768900A4F8E4 /* order.json in Resources */ = {isa = PBXBuildFile; fileRef = B5C6FCD520A3768900A4F8E4 /* order.json */; };
54-
CE20179320E3EFA7005B4C18 /* broken-order.json in Resources */ = {isa = PBXBuildFile; fileRef = CE20179220E3EFA7005B4C18 /* broken-order.json */; };
62+
CE20179320E3EFA7005B4C18 /* broken-orders.json in Resources */ = {isa = PBXBuildFile; fileRef = CE20179220E3EFA7005B4C18 /* broken-orders.json */; };
5563
/* End PBXBuildFile section */
5664

5765
/* Begin PBXContainerItemProxy section */
@@ -66,6 +74,14 @@
6674

6775
/* Begin PBXFileReference section */
6876
69314EDE650855CAF927057E /* Pods_NetworkingTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NetworkingTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
77+
741B950020EBC8A700DD6E2D /* OrderCouponLine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCouponLine.swift; sourceTree = "<group>"; };
78+
74C8F06320EEB44800B6EDC9 /* OrderNote.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderNote.swift; sourceTree = "<group>"; };
79+
74C8F06520EEB76400B6EDC9 /* order-notes.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "order-notes.json"; sourceTree = "<group>"; };
80+
74C8F06720EEB7BC00B6EDC9 /* OrderNotesMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderNotesMapper.swift; sourceTree = "<group>"; };
81+
74C8F06920EEBC8C00B6EDC9 /* OrderMapperTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderMapperTests.swift; sourceTree = "<group>"; };
82+
74C8F06B20EEBD5D00B6EDC9 /* broken-order.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "broken-order.json"; sourceTree = "<group>"; };
83+
74C8F06D20EEC1E700B6EDC9 /* OrderNotesMapperTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderNotesMapperTests.swift; sourceTree = "<group>"; };
84+
74C8F06F20EEC3A800B6EDC9 /* broken-notes.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "broken-notes.json"; sourceTree = "<group>"; };
6985
753D6504FF01F09F6A33B73E /* Pods-Networking.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Networking.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-Networking/Pods-Networking.debug.xcconfig"; sourceTree = "<group>"; };
7086
B505F6CC20BEE37E00BB1B69 /* AccountMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountMapper.swift; sourceTree = "<group>"; };
7187
B505F6CE20BEE38B00BB1B69 /* Account.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Account.swift; sourceTree = "<group>"; };
@@ -114,7 +130,7 @@
114130
B5C6FCD520A3768900A4F8E4 /* order.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = order.json; sourceTree = "<group>"; };
115131
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>"; };
116132
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>"; };
117-
CE20179220E3EFA7005B4C18 /* broken-order.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "broken-order.json"; sourceTree = "<group>"; };
133+
CE20179220E3EFA7005B4C18 /* broken-orders.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "broken-orders.json"; sourceTree = "<group>"; };
118134
F3F25DC15EC1D7C631169CB5 /* Pods_Networking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Networking.framework; sourceTree = BUILT_PRODUCTS_DIR; };
119135
F6CEE1CA2AD376C0C28AE9F6 /* Pods-NetworkingTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NetworkingTests.release.xcconfig"; path = "../Pods/Target Support Files/Pods-NetworkingTests/Pods-NetworkingTests.release.xcconfig"; sourceTree = "<group>"; };
120136
/* End PBXFileReference section */
@@ -284,8 +300,10 @@
284300
B505F6CE20BEE38B00BB1B69 /* Account.swift */,
285301
B5BB1D0F20A237FB00112D92 /* Address.swift */,
286302
B557DA1C20979E7D005962F4 /* Order.swift */,
287-
B5BB1D1120A255EC00112D92 /* OrderStatus.swift */,
303+
741B950020EBC8A700DD6E2D /* OrderCouponLine.swift */,
288304
B5C6FCCE20A3592900A4F8E4 /* OrderItem.swift */,
305+
74C8F06320EEB44800B6EDC9 /* OrderNote.swift */,
306+
B5BB1D1120A255EC00112D92 /* OrderStatus.swift */,
289307
B56C1EB720EA76F500D749F9 /* Site.swift */,
290308
);
291309
path = Model;
@@ -297,7 +315,10 @@
297315
B505F6D420BEE4E600BB1B69 /* me.json */,
298316
B559EBA920A0B5CD00836CD4 /* orders-load-all.json */,
299317
B5C6FCD520A3768900A4F8E4 /* order.json */,
300-
CE20179220E3EFA7005B4C18 /* broken-order.json */,
318+
CE20179220E3EFA7005B4C18 /* broken-orders.json */,
319+
74C8F06B20EEBD5D00B6EDC9 /* broken-order.json */,
320+
74C8F06520EEB76400B6EDC9 /* order-notes.json */,
321+
74C8F06F20EEC3A800B6EDC9 /* broken-notes.json */,
301322
B56C1EB920EA7D2C00D749F9 /* sites.json */,
302323
);
303324
path = Responses;
@@ -311,6 +332,7 @@
311332
B5C6FCD320A373BA00A4F8E4 /* OrderMapper.swift */,
312333
B567AF2A20A0FA4200AB6C62 /* OrderListMapper.swift */,
313334
B56C1EB520EA757B00D749F9 /* SiteListMapper.swift */,
335+
74C8F06720EEB7BC00B6EDC9 /* OrderNotesMapper.swift */,
314336
);
315337
path = Mapper;
316338
sourceTree = "<group>";
@@ -336,6 +358,8 @@
336358
children = (
337359
B505F6D220BEE3A500BB1B69 /* AccountMapperTests.swift */,
338360
B5C6FCCC20A34B8300A4F8E4 /* OrderListMapperTests.swift */,
361+
74C8F06920EEBC8C00B6EDC9 /* OrderMapperTests.swift */,
362+
74C8F06D20EEC1E700B6EDC9 /* OrderNotesMapperTests.swift */,
339363
);
340364
path = Mapper;
341365
sourceTree = "<group>";
@@ -453,11 +477,14 @@
453477
isa = PBXResourcesBuildPhase;
454478
buildActionMask = 2147483647;
455479
files = (
480+
74C8F06620EEB76400B6EDC9 /* order-notes.json in Resources */,
481+
74C8F06C20EEBD5D00B6EDC9 /* broken-order.json in Resources */,
456482
B505F6D520BEE4E700BB1B69 /* me.json in Resources */,
457483
B5C6FCD620A3768900A4F8E4 /* order.json in Resources */,
458484
B559EBAA20A0B5CD00836CD4 /* orders-load-all.json in Resources */,
459485
B56C1EBA20EA7D2C00D749F9 /* sites.json in Resources */,
460-
CE20179320E3EFA7005B4C18 /* broken-order.json in Resources */,
486+
CE20179320E3EFA7005B4C18 /* broken-orders.json in Resources */,
487+
74C8F07020EEC3A800B6EDC9 /* broken-notes.json in Resources */,
461488
);
462489
runOnlyForDeploymentPostprocessing = 0;
463490
};
@@ -529,6 +556,8 @@
529556
files = (
530557
B56C1EB620EA757B00D749F9 /* SiteListMapper.swift in Sources */,
531558
B557DA1A20979D66005962F4 /* Settings.swift in Sources */,
559+
741B950120EBC8A700DD6E2D /* OrderCouponLine.swift in Sources */,
560+
74C8F06420EEB44800B6EDC9 /* OrderNote.swift in Sources */,
532561
B5BB1D0C20A2050300112D92 /* DateFormatter+Woo.swift in Sources */,
533562
B567AF2520A0CCA300AB6C62 /* AuthenticatedRequest.swift in Sources */,
534563
B505F6EA20BEFC3700BB1B69 /* MockupNetwork.swift in Sources */,
@@ -545,6 +574,7 @@
545574
B5C6FCCF20A3592900A4F8E4 /* OrderItem.swift in Sources */,
546575
B505F6EC20BEFDC200BB1B69 /* Loader.swift in Sources */,
547576
B5BB1D1220A255EC00112D92 /* OrderStatus.swift in Sources */,
577+
74C8F06820EEB7BD00B6EDC9 /* OrderNotesMapper.swift in Sources */,
548578
B5BB1D1020A237FB00112D92 /* Address.swift in Sources */,
549579
B557DA0420975500005962F4 /* OrdersRemote.swift in Sources */,
550580
B5C6FCD420A373BB00A4F8E4 /* OrderMapper.swift in Sources */,
@@ -562,10 +592,12 @@
562592
files = (
563593
B505F6D320BEE3A500BB1B69 /* AccountMapperTests.swift in Sources */,
564594
B5C6FCC820A32E4800A4F8E4 /* DateFormatterWooTests.swift in Sources */,
595+
74C8F06A20EEBC8C00B6EDC9 /* OrderMapperTests.swift in Sources */,
565596
B567AF3120A0FB8F00AB6C62 /* JetpackRequestTests.swift in Sources */,
566597
B505F6D720BEE58800BB1B69 /* AccountRemoteTests.swift in Sources */,
567598
B518662A20A09C6F00037A38 /* OrdersRemoteTests.swift in Sources */,
568599
B5969E1520A47F99005E9DF1 /* RemoteTests.swift in Sources */,
600+
74C8F06E20EEC1E800B6EDC9 /* OrderNotesMapperTests.swift in Sources */,
569601
B567AF2F20A0FB8F00AB6C62 /* AuthenticatedRequestTests.swift in Sources */,
570602
B5C6FCCD20A34B8300A4F8E4 /* OrderListMapperTests.swift in Sources */,
571603
B518663520A0A2E800037A38 /* Constants.swift in Sources */,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Foundation
2+
3+
4+
/// Mapper: OrderNotes
5+
///
6+
class OrderNotesMapper: Mapper {
7+
8+
/// (Attempts) to convert a dictionary into [OrderNote].
9+
///
10+
func map(response: Data) throws -> [OrderNote] {
11+
let decoder = JSONDecoder()
12+
decoder.dateDecodingStrategy = .formatted(DateFormatter.Defaults.dateTimeFormatter)
13+
14+
return try decoder.decode(OrderNotesEnvelope.self, from: response).orderNotes
15+
}
16+
}
17+
18+
19+
/// OrderNote Disposable Entity:
20+
/// `Load Order Notes` endpoint returns all of its notes within the `data` key. This entity
21+
/// allows us to do parse all the things with JSONDecoder.
22+
///
23+
private struct OrderNotesEnvelope: Decodable {
24+
let orderNotes: [OrderNote]
25+
26+
private enum CodingKeys: String, CodingKey {
27+
case orderNotes = "data"
28+
}
29+
}

Networking/Networking/Model/Order.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ public struct Order: Decodable {
2323
public let shippingTax: String
2424
public let total: String
2525
public let totalTax: String
26+
public let paymentMethodTitle: String
2627

2728
public let items: [OrderItem]
2829
public let billingAddress: Address
2930
public let shippingAddress: Address
31+
public let coupons: [OrderCouponLine]
3032

3133
/// Order struct initializer.
3234
///
33-
init(orderID: Int, parentID: Int, customerID: Int, number: String, status: OrderStatus, currency: String, customerNote: String?, dateCreated: Date, dateModified: Date, datePaid: Date?, discountTotal: String, discountTax: String, shippingTotal: String, shippingTax: String, total: String, totalTax: String, items: [OrderItem], billingAddress: Address, shippingAddress: Address) {
35+
init(orderID: Int, parentID: Int, customerID: Int, number: String, status: OrderStatus, currency: String, customerNote: String?, dateCreated: Date, dateModified: Date, datePaid: Date?, discountTotal: String, discountTax: String, shippingTotal: String, shippingTax: String, total: String, totalTax: String, paymentMethodTitle: String, items: [OrderItem], billingAddress: Address, shippingAddress: Address, coupons: [OrderCouponLine]) {
36+
3437
self.orderID = orderID
3538
self.parentID = parentID
3639
self.customerID = customerID
@@ -50,10 +53,12 @@ public struct Order: Decodable {
5053
self.shippingTax = shippingTax
5154
self.total = total
5255
self.totalTax = totalTax
56+
self.paymentMethodTitle = paymentMethodTitle
5357

5458
self.items = items
5559
self.billingAddress = billingAddress
5660
self.shippingAddress = shippingAddress
61+
self.coupons = coupons
5762
}
5863

5964

@@ -80,12 +85,14 @@ public struct Order: Decodable {
8085
let shippingTotal = try container.decode(String.self, forKey: .shippingTotal)
8186
let total = try container.decode(String.self, forKey: .total)
8287
let totalTax = try container.decode(String.self, forKey: .totalTax)
88+
let paymentMethodTitle = try container.decode(String.self, forKey: .paymentMethodTitle)
8389

8490
let items = try container.decode([OrderItem].self, forKey: .items)
8591
let shippingAddress = try container.decode(Address.self, forKey: .shippingAddress)
8692
let billingAddress = try container.decode(Address.self, forKey: .billingAddress)
93+
let coupons = try container.decode([OrderCouponLine].self, forKey: .couponLines)
8794

88-
self.init(orderID: orderID, parentID: parentID, customerID: customerID, number: number, status: status, currency: currency, customerNote: customerNote, dateCreated: dateCreated, dateModified: dateModified, datePaid: datePaid, discountTotal: discountTotal, discountTax: discountTax, shippingTotal: shippingTotal, shippingTax: shippingTax, total: total, totalTax: totalTax, items: items, billingAddress: billingAddress, shippingAddress: shippingAddress) // initialize the struct
95+
self.init(orderID: orderID, parentID: parentID, customerID: customerID, number: number, status: status, currency: currency, customerNote: customerNote, dateCreated: dateCreated, dateModified: dateModified, datePaid: datePaid, discountTotal: discountTotal, discountTax: discountTax, shippingTotal: shippingTotal, shippingTax: shippingTax, total: total, totalTax: totalTax, paymentMethodTitle: paymentMethodTitle, items: items, billingAddress: billingAddress, shippingAddress: shippingAddress, coupons: coupons) // initialize the struct
8996
}
9097
}
9198

@@ -114,10 +121,12 @@ private extension Order {
114121
case shippingTax = "shipping_tax"
115122
case total = "total"
116123
case totalTax = "total_tax"
124+
case paymentMethodTitle = "payment_method_title"
117125

118126
case items = "line_items"
119127
case shippingAddress = "shipping"
120128
case billingAddress = "billing"
129+
case couponLines = "coupon_lines"
121130
}
122131
}
123132

@@ -140,8 +149,10 @@ extension Order: Comparable {
140149
lhs.shippingTax == rhs.shippingTax &&
141150
lhs.total == rhs.total &&
142151
lhs.totalTax == rhs.totalTax &&
152+
lhs.paymentMethodTitle == rhs.paymentMethodTitle &&
143153
lhs.billingAddress == rhs.billingAddress &&
144154
lhs.shippingAddress == rhs.shippingAddress &&
155+
lhs.coupons == rhs.coupons &&
145156
lhs.items.count == rhs.items.count &&
146157
lhs.items.sorted() == rhs.items.sorted()
147158
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import Foundation
2+
3+
4+
/// Represents a CouponLine Entity within an Order.
5+
///
6+
public struct OrderCouponLine: Decodable {
7+
public let couponID: Int
8+
public let code: String
9+
public let discount: String
10+
public let discountTax: String
11+
}
12+
13+
14+
/// Defines all of the CouponLine's CodingKeys.
15+
///
16+
private extension OrderCouponLine {
17+
18+
enum CodingKeys: String, CodingKey {
19+
case couponID = "id"
20+
case code = "code"
21+
case discount = "discount"
22+
case discountTax = "discount_tax"
23+
}
24+
}
25+
26+
27+
// MARK: - Comparable Conformance
28+
//
29+
extension OrderCouponLine: Comparable {
30+
public static func == (lhs: OrderCouponLine, rhs: OrderCouponLine) -> Bool {
31+
return lhs.couponID == rhs.couponID &&
32+
lhs.code == rhs.code &&
33+
lhs.discount == rhs.discount &&
34+
lhs.discountTax == rhs.discountTax
35+
}
36+
37+
public static func < (lhs: OrderCouponLine, rhs: OrderCouponLine) -> Bool {
38+
return lhs.couponID < rhs.couponID ||
39+
(lhs.couponID == rhs.couponID && lhs.code < rhs.code) ||
40+
(lhs.couponID == rhs.couponID && lhs.code == rhs.code && lhs.discount < rhs.discount)
41+
}
42+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import Foundation
2+
3+
4+
/// Represents an Order's Note Entity.
5+
///
6+
public struct OrderNote: Decodable {
7+
public let noteId: Int
8+
public let dateCreated: Date
9+
public let note: String
10+
public let isCustomerNote: Bool
11+
12+
/// Order struct initializer.
13+
///
14+
init(noteId: Int, dateCreated: Date, note: String, isCustomerNote: Bool) {
15+
self.noteId = noteId
16+
self.dateCreated = dateCreated
17+
self.note = note
18+
self.isCustomerNote = isCustomerNote
19+
}
20+
21+
/// The public initializer for OrderNote.
22+
///
23+
public init(from decoder: Decoder) throws {
24+
let container = try decoder.container(keyedBy: CodingKeys.self)
25+
let noteId = try container.decode(Int.self, forKey: .noteId)
26+
let dateCreated = try container.decodeIfPresent(Date.self, forKey: .dateCreated) ?? Date()
27+
let note = try container.decode(String.self, forKey: .note)
28+
let isCustomerNote = try container.decode(Bool.self, forKey: .isCustomerNote)
29+
30+
self.init(noteId: noteId, dateCreated: dateCreated, note: note, isCustomerNote: isCustomerNote) // initialize the struct
31+
}
32+
}
33+
34+
35+
/// Defines all of the OrderNote's CodingKeys.
36+
///
37+
private extension OrderNote {
38+
39+
enum CodingKeys: String, CodingKey {
40+
case noteId = "id"
41+
case dateCreated = "date_created_gmt"
42+
case note = "note"
43+
case isCustomerNote = "customer_note"
44+
}
45+
}
46+
47+
48+
// MARK: - Comparable Conformance
49+
//
50+
extension OrderNote: Comparable {
51+
public static func == (lhs: OrderNote, rhs: OrderNote) -> Bool {
52+
return lhs.noteId == rhs.noteId &&
53+
lhs.dateCreated == rhs.dateCreated &&
54+
lhs.note == rhs.note &&
55+
lhs.isCustomerNote == rhs.isCustomerNote
56+
}
57+
58+
public static func < (lhs: OrderNote, rhs: OrderNote) -> Bool {
59+
return lhs.noteId < rhs.noteId ||
60+
(lhs.noteId == rhs.noteId && lhs.dateCreated < rhs.dateCreated) ||
61+
(lhs.noteId == rhs.noteId && lhs.dateCreated == rhs.dateCreated && lhs.note < rhs.note)
62+
}
63+
}

0 commit comments

Comments
 (0)