Skip to content

Commit 727037a

Browse files
committed
Merge remote-tracking branch 'origin/develop' into issue/19-notification-subtype
2 parents 9e76917 + 0667f68 commit 727037a

File tree

11 files changed

+261
-57
lines changed

11 files changed

+261
-57
lines changed

Networking/Networking/Model/Site.swift

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ public struct Site: Decodable {
2121
///
2222
public let url: String
2323

24+
/// Short name for site's plan.
25+
///
26+
public let plan: String
27+
28+
/// Indicates if Jetpack is installed.
29+
///
30+
public let isJetpackInstalled: Bool
31+
2432
/// Indicates if there is a WooCommerce Store Active.
2533
///
2634
public let isWooCommerceActive: Bool
@@ -35,23 +43,41 @@ public struct Site: Decodable {
3543
public init(from decoder: Decoder) throws {
3644
let siteContainer = try decoder.container(keyedBy: SiteKeys.self)
3745

38-
siteID = try siteContainer.decode(Int.self, forKey: .siteID)
39-
name = try siteContainer.decode(String.self, forKey: .name)
40-
description = try siteContainer.decode(String.self, forKey: .description)
41-
url = try siteContainer.decode(String.self, forKey: .url)
46+
let siteID = try siteContainer.decode(Int.self, forKey: .siteID)
47+
let name = try siteContainer.decode(String.self, forKey: .name)
48+
let description = try siteContainer.decode(String.self, forKey: .description)
49+
let url = try siteContainer.decode(String.self, forKey: .url)
50+
let isJetpackInstalled = try siteContainer.decodeIfPresent(Bool.self, forKey: .jetpack) ?? false
4251

4352
let optionsContainer = try siteContainer.nestedContainer(keyedBy: OptionKeys.self, forKey: .options)
44-
isWordPressStore = try optionsContainer.decode(Bool.self, forKey: .isWordPressStore)
45-
isWooCommerceActive = try optionsContainer.decode(Bool.self, forKey: .isWooCommerceActive)
53+
let isWordPressStore = try optionsContainer.decode(Bool.self, forKey: .isWordPressStore)
54+
let isWooCommerceActive = try optionsContainer.decode(Bool.self, forKey: .isWooCommerceActive)
55+
56+
var plan = String()
57+
if siteContainer.contains(.plan) {
58+
let planContainer = try siteContainer.nestedContainer(keyedBy: PlanKeys.self, forKey: .plan)
59+
plan = try planContainer.decode(String.self, forKey: .shortName)
60+
}
61+
62+
self.init(siteID: siteID,
63+
name: name,
64+
description: description,
65+
url: url,
66+
plan: plan,
67+
isJetpackInstalled: isJetpackInstalled,
68+
isWooCommerceActive: isWooCommerceActive,
69+
isWordPressStore: isWordPressStore)
4670
}
4771

4872
/// Designated Initializer.
4973
///
50-
public init(siteID: Int, name: String, description: String, url: String, isWooCommerceActive: Bool, isWordPressStore: Bool) {
74+
public init(siteID: Int, name: String, description: String, url: String, plan: String, isJetpackInstalled: Bool, isWooCommerceActive: Bool, isWordPressStore: Bool) {
5175
self.siteID = siteID
5276
self.name = name
5377
self.description = description
5478
self.url = url
79+
self.plan = plan
80+
self.isJetpackInstalled = isJetpackInstalled
5581
self.isWordPressStore = isWordPressStore
5682
self.isWooCommerceActive = isWooCommerceActive
5783
}
@@ -66,6 +92,8 @@ extension Site: Comparable {
6692
lhs.name == rhs.name &&
6793
lhs.description == rhs.description &&
6894
lhs.url == rhs.url &&
95+
lhs.plan == rhs.plan &&
96+
lhs.isJetpackInstalled == rhs.isJetpackInstalled &&
6997
lhs.isWooCommerceActive == rhs.isWooCommerceActive &&
7098
lhs.isWordPressStore == rhs.isWordPressStore
7199
}
@@ -87,11 +115,17 @@ private extension Site {
87115
case name = "name"
88116
case description = "description"
89117
case url = "URL"
118+
case jetpack = "jetpack"
90119
case options = "options"
120+
case plan = "plan"
91121
}
92122

93123
enum OptionKeys: String, CodingKey {
94124
case isWordPressStore = "is_wpcom_store"
95125
case isWooCommerceActive = "woocommerce_is_active"
96126
}
127+
128+
enum PlanKeys: String, CodingKey {
129+
case shortName = "product_name_short"
130+
}
97131
}

Networking/NetworkingTests/Mapper/AccountMapperTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class AccountMapperTests: XCTestCase {
3232
XCTAssertEqual(first.name, "Testing Blog")
3333
XCTAssertEqual(first.description, "Testing Tagline")
3434
XCTAssertEqual(first.url, "https://some-testing-url.testing.blog")
35+
XCTAssertEqual(first.plan, "Free")
36+
XCTAssertEqual(first.isJetpackInstalled, true)
3537
XCTAssertEqual(first.isWooCommerceActive, true)
3638
XCTAssertEqual(first.isWordPressStore, true)
3739

@@ -40,6 +42,8 @@ class AccountMapperTests: XCTestCase {
4042
XCTAssertEqual(second.name, "Thoughts")
4143
XCTAssertEqual(second.description, "Your Favorite Blog")
4244
XCTAssertEqual(second.url, "https://thoughts.testing.blog")
45+
XCTAssertEqual(second.plan, "Free")
46+
XCTAssertEqual(second.isJetpackInstalled, false)
4347
XCTAssertEqual(second.isWooCommerceActive, false)
4448
XCTAssertEqual(second.isWordPressStore, false)
4549
}

Networking/NetworkingTests/Responses/sites.json

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"name": "Testing Blog",
66
"description": "Testing Tagline",
77
"URL": "https:\/\/some-testing-url.testing.blog",
8+
"jetpack": true,
89
"options": {
910
"timezone": "",
1011
"gmt_offset": 0,
@@ -129,6 +130,75 @@
129130
"is_multi_site": false,
130131
"file_mod_disabled": false
131132
},
133+
"plan": {
134+
"product_id": 1,
135+
"product_slug": "free_plan",
136+
"product_name_short": "Free",
137+
"free_trial": false,
138+
"expired": false,
139+
"user_is_owner": false,
140+
"is_free": true,
141+
"features": {
142+
"active": [
143+
"free-blog",
144+
"space",
145+
"support"
146+
],
147+
"available": {
148+
"free-blog": [
149+
"personal-bundle",
150+
"value_bundle",
151+
"business-bundle"
152+
],
153+
"custom-domain": [
154+
"personal-bundle",
155+
"value_bundle",
156+
"business-bundle"
157+
],
158+
"space": [
159+
"personal-bundle",
160+
"value_bundle",
161+
"business-bundle"
162+
],
163+
"no-adverts\/no-adverts.php": [
164+
"personal-bundle",
165+
"value_bundle",
166+
"business-bundle"
167+
],
168+
"support": [
169+
"personal-bundle",
170+
"value_bundle",
171+
"business-bundle"
172+
],
173+
"custom-design": [
174+
"value_bundle",
175+
"business-bundle"
176+
],
177+
"videopress": [
178+
"value_bundle",
179+
"business-bundle"
180+
],
181+
"unlimited_themes": [
182+
"value_bundle",
183+
"business-bundle"
184+
],
185+
"live_support": [
186+
"value_bundle",
187+
"business-bundle"
188+
],
189+
"simple-payments": [
190+
"value_bundle",
191+
"business-bundle"
192+
],
193+
"premium-themes": [
194+
"business-bundle"
195+
],
196+
"google-analytics": [
197+
"business-bundle"
198+
]
199+
}
200+
}
201+
},
132202
"updates": {
133203
"plugins": 3,
134204
"themes": 1,
@@ -142,6 +212,7 @@
142212
"name": "Thoughts",
143213
"description": "Your Favorite Blog",
144214
"URL": "https:\/\/thoughts.testing.blog",
215+
"jetpack": false,
145216
"options": {
146217
"timezone": "",
147218
"gmt_offset": 0,
@@ -213,6 +284,75 @@
213284
"woocommerce_is_active": false,
214285
"design_type": null,
215286
"site_goals": null
287+
},
288+
"plan": {
289+
"product_id": 1,
290+
"product_slug": "free_plan",
291+
"product_name_short": "Free",
292+
"free_trial": false,
293+
"expired": false,
294+
"user_is_owner": false,
295+
"is_free": true,
296+
"features": {
297+
"active": [
298+
"free-blog",
299+
"space",
300+
"support"
301+
],
302+
"available": {
303+
"free-blog": [
304+
"personal-bundle",
305+
"value_bundle",
306+
"business-bundle"
307+
],
308+
"custom-domain": [
309+
"personal-bundle",
310+
"value_bundle",
311+
"business-bundle"
312+
],
313+
"space": [
314+
"personal-bundle",
315+
"value_bundle",
316+
"business-bundle"
317+
],
318+
"no-adverts\/no-adverts.php": [
319+
"personal-bundle",
320+
"value_bundle",
321+
"business-bundle"
322+
],
323+
"support": [
324+
"personal-bundle",
325+
"value_bundle",
326+
"business-bundle"
327+
],
328+
"custom-design": [
329+
"value_bundle",
330+
"business-bundle"
331+
],
332+
"videopress": [
333+
"value_bundle",
334+
"business-bundle"
335+
],
336+
"unlimited_themes": [
337+
"value_bundle",
338+
"business-bundle"
339+
],
340+
"live_support": [
341+
"value_bundle",
342+
"business-bundle"
343+
],
344+
"simple-payments": [
345+
"value_bundle",
346+
"business-bundle"
347+
],
348+
"premium-themes": [
349+
"business-bundle"
350+
],
351+
"google-analytics": [
352+
"business-bundle"
353+
]
354+
}
355+
}
216356
}
217357
}
218358
]

Storage/Storage/Model/MIGRATIONS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ This file documents changes in the WCiOS Storage data model. Please explain any
66
- @jleandroperez 2018-11-12
77
- New `Note.subtype` property (optional type)
88

9+
- @thuycopeland 2018-11-8
10+
- Added new attribute: `isJetpackInstalled`, to site entity
11+
- Added new attribute: `plan`, to site entity
12+
913
## Model 5
1014
- @bummytime 2018-10-26
1115
- Added new entity: `Note`, to encapsulate all things notifications

Storage/Storage/Model/Site+CoreDataProperties.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ extension Site {
1111
@NSManaged public var name: String?
1212
@NSManaged public var tagline: String?
1313
@NSManaged public var url: String?
14+
@NSManaged public var plan: String?
15+
@NSManaged public var isJetpackInstalled: NSNumber?
1416
@NSManaged public var isWooCommerceActive: NSNumber?
1517
@NSManaged public var isWordPressStore: NSNumber?
1618
}

Storage/Storage/Model/WooCommerce.xcdatamodeld/Model 6.xcdatamodel/contents

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@
132132
<relationship name="stats" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="OrderStats" inverseName="items" inverseEntity="OrderStats" syncable="YES"/>
133133
</entity>
134134
<entity name="Site" representedClassName="Site" syncable="YES">
135+
<attribute name="isJetpackInstalled" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES" syncable="YES"/>
135136
<attribute name="isWooCommerceActive" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES" syncable="YES"/>
136137
<attribute name="isWordPressStore" attributeType="Double" defaultValueString="0.0" usesScalarValueType="YES" syncable="YES"/>
137138
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
139+
<attribute name="plan" optional="YES" attributeType="String" syncable="YES"/>
138140
<attribute name="siteID" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
139141
<attribute name="tagline" optional="YES" attributeType="String" syncable="YES"/>
140142
<attribute name="url" optional="YES" attributeType="String" syncable="YES"/>
@@ -181,7 +183,7 @@
181183
<element name="OrderNote" positionX="-365.16796875" positionY="630.2109375" width="128" height="118"/>
182184
<element name="OrderStats" positionX="137.859375" positionY="388.33203125" width="128" height="225"/>
183185
<element name="OrderStatsItem" positionX="321.74609375" positionY="425.51171875" width="128" height="330"/>
184-
<element name="Site" positionX="-203.6875" positionY="208.0703125" width="128" height="135"/>
186+
<element name="Site" positionX="-203.6875" positionY="208.0703125" width="128" height="165"/>
185187
<element name="SiteSetting" positionX="-362.54296875" positionY="217.9921875" width="128" height="120"/>
186188
<element name="SiteVisitStats" positionX="134.515625" positionY="224.62109375" width="128" height="90"/>
187189
<element name="SiteVisitStatsItem" positionX="308.1328125" positionY="251.91796875" width="128" height="90"/>

0 commit comments

Comments
 (0)