diff --git a/WordPressKit.podspec b/WordPressKit.podspec index c68cd9f1..ab83aa36 100644 --- a/WordPressKit.podspec +++ b/WordPressKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressKit" - s.version = "3.2.1" + s.version = "3.2.2.beta-1" s.summary = "WordPressKit offers a clean and simple WordPress.com and WordPress.org API." s.description = <<-DESC diff --git a/WordPressKit/Time Interval/StatsTopClicksTimeIntervalData.swift b/WordPressKit/Time Interval/StatsTopClicksTimeIntervalData.swift index 72ef8fa9..fffa71af 100644 --- a/WordPressKit/Time Interval/StatsTopClicksTimeIntervalData.swift +++ b/WordPressKit/Time Interval/StatsTopClicksTimeIntervalData.swift @@ -49,14 +49,13 @@ extension StatsTopClicksTimeIntervalData: StatsTimeIntervalData { public init?(date: Date, period: StatsPeriodUnit, jsonDictionary: [String : AnyObject]) { guard let unwrappedDays = type(of: self).unwrapDaysDictionary(jsonDictionary: jsonDictionary), - let totalClicks = unwrappedDays["total_clicks"] as? Int, - let otherClicks = unwrappedDays["other_clicks"] as? Int, let clicks = unwrappedDays["clicks"] as? [[String: AnyObject]] else { return nil } - + let totalClicks = unwrappedDays["total_clicks"] as? Int ?? 0 + let otherClicks = unwrappedDays["other_clicks"] as? Int ?? 0 self.period = period self.periodEndDate = date diff --git a/WordPressKit/Time Interval/StatsTopCountryTimeIntervalData.swift b/WordPressKit/Time Interval/StatsTopCountryTimeIntervalData.swift index 1e1c0c71..1865169c 100644 --- a/WordPressKit/Time Interval/StatsTopCountryTimeIntervalData.swift +++ b/WordPressKit/Time Interval/StatsTopCountryTimeIntervalData.swift @@ -41,15 +41,16 @@ extension StatsTopCountryTimeIntervalData: StatsTimeIntervalData { public init?(date: Date, period: StatsPeriodUnit, jsonDictionary: [String : AnyObject]) { guard - let countryInfo = jsonDictionary["country-info"] as? [String: AnyObject], let unwrappedDays = type(of: self).unwrapDaysDictionary(jsonDictionary: jsonDictionary), - let totalViews = unwrappedDays["total_views"] as? Int, - let otherViews = unwrappedDays["other_views"] as? Int, let countriesViews = unwrappedDays["views"] as? [[String: AnyObject]] else { return nil } + let countryInfo = jsonDictionary["country-info"] as? [String: AnyObject] ?? [:] + let totalViews = unwrappedDays["total_views"] as? Int ?? 0 + let otherViews = unwrappedDays["other_views"] as? Int ?? 0 + self.periodEndDate = date self.period = period diff --git a/WordPressKit/Time Interval/StatsTopPostsTimeIntervalData.swift b/WordPressKit/Time Interval/StatsTopPostsTimeIntervalData.swift index d3e8eab8..0443c8e0 100644 --- a/WordPressKit/Time Interval/StatsTopPostsTimeIntervalData.swift +++ b/WordPressKit/Time Interval/StatsTopPostsTimeIntervalData.swift @@ -27,13 +27,14 @@ extension StatsTopPostsTimeIntervalData: StatsTimeIntervalData { public init?(date: Date, period: StatsPeriodUnit, jsonDictionary: [String : AnyObject]) { guard let unwrappedDays = type(of: self).unwrapDaysDictionary(jsonDictionary: jsonDictionary), - let posts = unwrappedDays["postviews"] as? [[String: AnyObject]], - let totalViews = unwrappedDays["total_views"] as? Int, - let otherViews = unwrappedDays["other_views"] as? Int + let posts = unwrappedDays["postviews"] as? [[String: AnyObject]] else { return nil } + let totalViews = unwrappedDays["total_views"] as? Int ?? 0 + let otherViews = unwrappedDays["other_views"] as? Int ?? 0 + self.periodEndDate = date self.period = period self.totalViewsCount = totalViews diff --git a/WordPressKit/Time Interval/StatsTopReferrersTimeIntervalData.swift b/WordPressKit/Time Interval/StatsTopReferrersTimeIntervalData.swift index aa358051..46e168ef 100644 --- a/WordPressKit/Time Interval/StatsTopReferrersTimeIntervalData.swift +++ b/WordPressKit/Time Interval/StatsTopReferrersTimeIntervalData.swift @@ -49,13 +49,14 @@ extension StatsTopReferrersTimeIntervalData: StatsTimeIntervalData { public init?(date: Date, period: StatsPeriodUnit, jsonDictionary: [String : AnyObject]) { guard let unwrappedDays = type(of: self).unwrapDaysDictionary(jsonDictionary: jsonDictionary), - let totalClicks = unwrappedDays["total_views"] as? Int, - let otherClicks = unwrappedDays["other_views"] as? Int, let referrers = unwrappedDays["groups"] as? [[String: AnyObject]] else { return nil } + let totalClicks = unwrappedDays["total_views"] as? Int ?? 0 + let otherClicks = unwrappedDays["other_views"] as? Int ?? 0 + self.period = period self.periodEndDate = date self.totalReferrerViewsCount = totalClicks