Skip to content

Commit 31329a6

Browse files
authored
Merge pull request #6121 from woocommerce/issue/6057-inbox-storage-layer
Updated the Storage layer for introducing `InboxNote` and `InboxAction` entities
2 parents 565b02c + b785782 commit 31329a6

File tree

17 files changed

+1048
-15
lines changed

17 files changed

+1048
-15
lines changed

Fakes/Fakes/Networking.generated.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ extension InboxNote {
213213
actions: .fake(),
214214
title: .fake(),
215215
content: .fake(),
216-
isDeleted: .fake(),
216+
isRemoved: .fake(),
217217
isRead: .fake(),
218218
dateCreated: .fake()
219219
)

InboxAction+CoreDataClass.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Foundation
2+
import CoreData
3+
4+
@objc(InboxAction)
5+
public class InboxAction: NSManagedObject {
6+
7+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Foundation
2+
import CoreData
3+
4+
5+
extension InboxAction {
6+
7+
@nonobjc public class func fetchRequest() -> NSFetchRequest<InboxAction> {
8+
return NSFetchRequest<InboxAction>(entityName: "InboxAction")
9+
}
10+
11+
@NSManaged public var id: Int64
12+
@NSManaged public var label: String?
13+
@NSManaged public var name: String?
14+
@NSManaged public var status: String?
15+
@NSManaged public var url: String?
16+
@NSManaged public var inboxNote: InboxNote
17+
18+
}
19+
20+
extension InboxAction: Identifiable {
21+
22+
}

InboxNote+CoreDataClass.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Foundation
2+
import CoreData
3+
4+
@objc(InboxNote)
5+
public class InboxNote: NSManagedObject {
6+
7+
}

InboxNote+CoreDataProperties.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Foundation
2+
import CoreData
3+
4+
5+
extension InboxNote {
6+
7+
@nonobjc public class func fetchRequest() -> NSFetchRequest<InboxNote> {
8+
return NSFetchRequest<InboxNote>(entityName: "InboxNote")
9+
}
10+
11+
@NSManaged public var content: String?
12+
@NSManaged public var isRemoved: Bool
13+
@NSManaged public var id: Int64
14+
@NSManaged public var name: String?
15+
@NSManaged public var isRead: Bool
16+
@NSManaged public var siteID: Int64
17+
@NSManaged public var status: String?
18+
@NSManaged public var title: String?
19+
@NSManaged public var type: String?
20+
@NSManaged public var dateCreated: Date?
21+
@NSManaged public var actions: Set<InboxAction>?
22+
23+
}
24+
25+
// MARK: Generated accessors for actions
26+
extension InboxNote {
27+
28+
@objc(addActionsObject:)
29+
@NSManaged public func addToActions(_ value: InboxAction)
30+
31+
@objc(removeActionsObject:)
32+
@NSManaged public func removeFromActions(_ value: InboxAction)
33+
34+
@objc(addActions:)
35+
@NSManaged public func addToActions(_ values: NSSet)
36+
37+
@objc(removeActions:)
38+
@NSManaged public func removeFromActions(_ values: NSSet)
39+
40+
}
41+
42+
extension InboxNote: Identifiable {
43+
44+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ extension InboxNote {
203203
actions: CopiableProp<[InboxAction]> = .copy,
204204
title: CopiableProp<String> = .copy,
205205
content: CopiableProp<String> = .copy,
206-
isDeleted: CopiableProp<Bool> = .copy,
206+
isRemoved: CopiableProp<Bool> = .copy,
207207
isRead: CopiableProp<Bool> = .copy,
208208
dateCreated: CopiableProp<Date> = .copy
209209
) -> InboxNote {
@@ -215,7 +215,7 @@ extension InboxNote {
215215
let actions = actions ?? self.actions
216216
let title = title ?? self.title
217217
let content = content ?? self.content
218-
let isDeleted = isDeleted ?? self.isDeleted
218+
let isRemoved = isRemoved ?? self.isRemoved
219219
let isRead = isRead ?? self.isRead
220220
let dateCreated = dateCreated ?? self.dateCreated
221221

@@ -228,7 +228,7 @@ extension InboxNote {
228228
actions: actions,
229229
title: title,
230230
content: content,
231-
isDeleted: isDeleted,
231+
isRemoved: isRemoved,
232232
isRead: isRead,
233233
dateCreated: dateCreated
234234
)

Networking/Networking/Model/InboxNote.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public struct InboxNote: GeneratedCopiable, GeneratedFakeable, Equatable {
4141

4242
/// Registers whether the note is deleted or not.
4343
///
44-
public let isDeleted: Bool
44+
public let isRemoved: Bool
4545

4646
/// Registers whether the note is read or not.
4747
///
@@ -60,7 +60,7 @@ public struct InboxNote: GeneratedCopiable, GeneratedFakeable, Equatable {
6060
actions: [InboxAction],
6161
title: String,
6262
content: String,
63-
isDeleted: Bool,
63+
isRemoved: Bool,
6464
isRead: Bool,
6565
dateCreated: Date) {
6666
self.siteID = siteID
@@ -71,7 +71,7 @@ public struct InboxNote: GeneratedCopiable, GeneratedFakeable, Equatable {
7171
self.actions = actions
7272
self.title = title
7373
self.content = content
74-
self.isDeleted = isDeleted
74+
self.isRemoved = isRemoved
7575
self.isRead = isRead
7676
self.dateCreated = dateCreated
7777
}
@@ -96,7 +96,7 @@ extension InboxNote: Codable {
9696
let actions = try container.decode([InboxAction].self, forKey: .actions)
9797
let title = try container.decode(String.self, forKey: .title)
9898
let content = try container.decode(String.self, forKey: .content)
99-
let isDeleted = try container.decode(Bool.self, forKey: .isDeleted)
99+
let isRemoved = try container.decode(Bool.self, forKey: .isRemoved)
100100
let isRead = try container.decode(Bool.self, forKey: .isRead)
101101
let dateCreated = try container.decode(Date.self, forKey: .dateCreated)
102102

@@ -108,7 +108,7 @@ extension InboxNote: Codable {
108108
actions: actions,
109109
title: title,
110110
content: content,
111-
isDeleted: isDeleted,
111+
isRemoved: isRemoved,
112112
isRead: isRead,
113113
dateCreated: dateCreated)
114114
}
@@ -121,7 +121,7 @@ extension InboxNote: Codable {
121121
case actions
122122
case title
123123
case content
124-
case isDeleted = "is_deleted"
124+
case isRemoved = "is_deleted"
125125
case isRead = "is_read"
126126
case dateCreated = "date_created_gmt"
127127
}

Networking/NetworkingTests/Mapper/InboxNoteListMapperTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class InboxNoteListMapperTests: XCTestCase {
4848
url: url)],
4949
title: "Ready to launch your store?",
5050
content: content,
51-
isDeleted: false,
51+
isRemoved: false,
5252
isRead: false,
5353
dateCreated: dateFormatter.date(from: "2022-01-26T14:32:08")!)
5454

Networking/NetworkingTests/Mapper/InboxNoteMapperTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class InboxNoteMapperTests: XCTestCase {
4343
url: url)],
4444
title: "WooCommerce Bookings subscription expired",
4545
content: content,
46-
isDeleted: true,
46+
isRemoved: true,
4747
isRead: false,
4848
dateCreated: dateFormatter.date(from: "2022-01-31T14:25:32")!)
4949

Storage/Storage.xcodeproj/project.pbxproj

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
31D9C8C926684AEC000AC134 /* PaymentGatewayAccount+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D9C8C726684AEC000AC134 /* PaymentGatewayAccount+CoreDataProperties.swift */; };
6363
450106892399AC7400E24722 /* TaxClass+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 450106882399AC7400E24722 /* TaxClass+CoreDataClass.swift */; };
6464
4501068B2399AC9B00E24722 /* TaxClass+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4501068A2399AC9B00E24722 /* TaxClass+CoreDataProperties.swift */; };
65+
452C23B427B4129300822986 /* InboxAction+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452C23B027B4129300822986 /* InboxAction+CoreDataClass.swift */; };
66+
452C23B527B4129300822986 /* InboxAction+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452C23B127B4129300822986 /* InboxAction+CoreDataProperties.swift */; };
67+
452C23B627B4129300822986 /* InboxNote+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452C23B227B4129300822986 /* InboxNote+CoreDataClass.swift */; };
68+
452C23B727B4129300822986 /* InboxNote+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452C23B327B4129300822986 /* InboxNote+CoreDataProperties.swift */; };
6569
454005AA24AE4D350087FDD1 /* WooCommerceModelV28toV29.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = 454005A924AE4D350087FDD1 /* WooCommerceModelV28toV29.xcmappingmodel */; };
6670
455C0C9025DD6D93007B6F38 /* AccountSettings+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455C0C8E25DD6D93007B6F38 /* AccountSettings+CoreDataClass.swift */; };
6771
455C0C9125DD6D93007B6F38 /* AccountSettings+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 455C0C8F25DD6D93007B6F38 /* AccountSettings+CoreDataProperties.swift */; };
@@ -288,9 +292,14 @@
288292
31D9C8C726684AEC000AC134 /* PaymentGatewayAccount+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "PaymentGatewayAccount+CoreDataProperties.swift"; path = "../../../PaymentGatewayAccount+CoreDataProperties.swift"; sourceTree = "<group>"; };
289293
450106882399AC7400E24722 /* TaxClass+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TaxClass+CoreDataClass.swift"; sourceTree = "<group>"; };
290294
4501068A2399AC9B00E24722 /* TaxClass+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TaxClass+CoreDataProperties.swift"; sourceTree = "<group>"; };
295+
452C23B027B4129300822986 /* InboxAction+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "InboxAction+CoreDataClass.swift"; path = "../../../InboxAction+CoreDataClass.swift"; sourceTree = "<group>"; };
296+
452C23B127B4129300822986 /* InboxAction+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "InboxAction+CoreDataProperties.swift"; path = "../../../InboxAction+CoreDataProperties.swift"; sourceTree = "<group>"; };
297+
452C23B227B4129300822986 /* InboxNote+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "InboxNote+CoreDataClass.swift"; path = "../../../InboxNote+CoreDataClass.swift"; sourceTree = "<group>"; };
298+
452C23B327B4129300822986 /* InboxNote+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "InboxNote+CoreDataProperties.swift"; path = "../../../InboxNote+CoreDataProperties.swift"; sourceTree = "<group>"; };
291299
454005A924AE4D350087FDD1 /* WooCommerceModelV28toV29.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = WooCommerceModelV28toV29.xcmappingmodel; sourceTree = "<group>"; };
292300
455C0C8E25DD6D93007B6F38 /* AccountSettings+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccountSettings+CoreDataClass.swift"; sourceTree = "<group>"; };
293301
455C0C8F25DD6D93007B6F38 /* AccountSettings+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccountSettings+CoreDataProperties.swift"; sourceTree = "<group>"; };
302+
459E342327B4069E0054FF01 /* Model 64.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 64.xcdatamodel"; sourceTree = "<group>"; };
294303
45E1862D2370450C009241F3 /* ShippingLine+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ShippingLine+CoreDataClass.swift"; sourceTree = "<group>"; };
295304
45E1862F23704519009241F3 /* ShippingLine+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ShippingLine+CoreDataProperties.swift"; sourceTree = "<group>"; };
296305
45E462032684BCEE00011BF2 /* StateOfACountry+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StateOfACountry+CoreDataProperties.swift"; sourceTree = "<group>"; };
@@ -816,6 +825,10 @@
816825
DE26B5252775C5F000A2EA0A /* Coupon+CoreDataProperties.swift */,
817826
DE00132B279FDC2200EB0350 /* CouponSearchResult+CoreDataClass.swift */,
818827
DE00132C279FDC2200EB0350 /* CouponSearchResult+CoreDataProperties.swift */,
828+
452C23B027B4129300822986 /* InboxAction+CoreDataClass.swift */,
829+
452C23B127B4129300822986 /* InboxAction+CoreDataProperties.swift */,
830+
452C23B227B4129300822986 /* InboxNote+CoreDataClass.swift */,
831+
452C23B327B4129300822986 /* InboxNote+CoreDataProperties.swift */,
819832
45E462042684BCEE00011BF2 /* StateOfACountry+CoreDataClass.swift */,
820833
45E462032684BCEE00011BF2 /* StateOfACountry+CoreDataProperties.swift */,
821834
74F009BE2183B99B002B4566 /* Note+CoreDataClass.swift */,
@@ -1185,6 +1198,7 @@
11851198
02EAB6D72480A86D00FD873C /* CrashLogger.swift in Sources */,
11861199
746A9D21214078080013F6FF /* TopEarnerStats+CoreDataClass.swift in Sources */,
11871200
262B27092621411C00A421CF /* ProductAddOn+CoreDataClass.swift in Sources */,
1201+
452C23B527B4129300822986 /* InboxAction+CoreDataProperties.swift in Sources */,
11881202
5707FBC425B5FE2200B7C1A6 /* CoreDataIterativeMigrator+MigrationStep.swift in Sources */,
11891203
262B27132621412700A421CF /* ProductAddOnOption+CoreDataClass.swift in Sources */,
11901204
2685C109263C88B000D9EE97 /* AddOnGroup+CoreDataProperties.swift in Sources */,
@@ -1195,6 +1209,7 @@
11951209
454005AA24AE4D350087FDD1 /* WooCommerceModelV28toV29.xcmappingmodel in Sources */,
11961210
7471A517216CF0FE00219F7E /* SiteVisitStats+CoreDataProperties.swift in Sources */,
11971211
26EA01D124EC3AEA00176A57 /* FeedbackType.swift in Sources */,
1212+
452C23B427B4129300822986 /* InboxAction+CoreDataClass.swift in Sources */,
11981213
7426A05420F69DA4002A4E07 /* OrderItem+CoreDataClass.swift in Sources */,
11991214
028296F4237D404F00E84012 /* GenericAttribute+CoreDataClass.swift in Sources */,
12001215
262B270E2621412000A421CF /* ProductAddOn+CoreDataProperties.swift in Sources */,
@@ -1218,6 +1233,7 @@
12181233
02C254EB2563B12E00A04423 /* ShippingLabelSettings+CoreDataClass.swift in Sources */,
12191234
5736878E24AAADAE00B528FE /* ManagedObjectModelsInventory.swift in Sources */,
12201235
31D9C8C926684AEC000AC134 /* PaymentGatewayAccount+CoreDataProperties.swift in Sources */,
1236+
452C23B627B4129300822986 /* InboxNote+CoreDataClass.swift in Sources */,
12211237
CE12FBE32220515600C59248 /* WooCommerceModelV9toV10.xcmappingmodel in Sources */,
12221238
747453A62242C85E00E0B5EE /* ProductDefaultAttribute+CoreDataProperties.swift in Sources */,
12231239
028296F3237D404F00E84012 /* ProductVariation+CoreDataProperties.swift in Sources */,
@@ -1270,6 +1286,7 @@
12701286
7499FA44221C7A60004EC0B4 /* ShipmentTracking+CoreDataClass.swift in Sources */,
12711287
D87F61532265AA230031A13B /* FileStorage.swift in Sources */,
12721288
DE00132E279FDC2200EB0350 /* CouponSearchResult+CoreDataClass.swift in Sources */,
1289+
452C23B727B4129300822986 /* InboxNote+CoreDataProperties.swift in Sources */,
12731290
CE4FD4482350EB7600A16B31 /* OrderItemRefund+CoreDataProperties.swift in Sources */,
12741291
D8FBFF5622D66A06006E3336 /* OrderStatsV4Interval+CoreDataProperties.swift in Sources */,
12751292
261CF1C4255B291F0090D8D3 /* PaymentGateway+CoreDataClass.swift in Sources */,
@@ -1722,6 +1739,7 @@
17221739
DEC51AA4275B41BE009F3DF4 /* WooCommerce.xcdatamodeld */ = {
17231740
isa = XCVersionGroup;
17241741
children = (
1742+
459E342327B4069E0054FF01 /* Model 64.xcdatamodel */,
17251743
0345DB4527A8122700B02D0C /* Model 63.xcdatamodel */,
17261744
DE001324279FD7D900EB0350 /* Model 62.xcdatamodel */,
17271745
BAB373732796310100837B4A /* Model 61.xcdatamodel */,
@@ -1786,7 +1804,7 @@
17861804
DEC51ADE275B41BE009F3DF4 /* Model 47.xcdatamodel */,
17871805
DEC51ADF275B41BE009F3DF4 /* Model 19.xcdatamodel */,
17881806
);
1789-
currentVersion = 0345DB4527A8122700B02D0C /* Model 63.xcdatamodel */;
1807+
currentVersion = 459E342327B4069E0054FF01 /* Model 64.xcdatamodel */;
17901808
path = WooCommerce.xcdatamodeld;
17911809
sourceTree = "<group>";
17921810
versionGroupType = wrapper.xcdatamodel;

0 commit comments

Comments
 (0)