Skip to content

Commit

Permalink
Default to 0 and update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoSoto committed Sep 7, 2023
1 parent c388c4e commit c24be7f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
6 changes: 6 additions & 0 deletions Sources/Misc/Codable/DefaultDecodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ enum DefaultDecodable {
static var defaultValue: String { "" }
}

enum Zero: DefaultValueProvider {
static var defaultValue: Int { 0 }
}

enum EmptyArray<T: List>: DefaultValueProvider {
static var defaultValue: T { [] }
}
Expand Down Expand Up @@ -226,6 +230,7 @@ enum DefaultDecodable {
* @DefaultDecodable.EmptyArray var values: [String]
* @DefaultDecodable.EmptyDictionary var dictionary: [String: Int]
* @DefaultDecodable.Now var date: Date
* @DefaultDecodable.Zero var number: Int
* }
* ```
*/
Expand All @@ -237,5 +242,6 @@ extension DefaultDecodable {
typealias EmptyArray<T: List> = DefaultValue<Sources.EmptyArray<T>>
typealias EmptyDictionary<T: Map> = DefaultValue<Sources.EmptyDictionary<T>>
typealias Now = DefaultValue<Sources.Now>
typealias Zero = DefaultValue<Sources.Zero>

}
14 changes: 9 additions & 5 deletions Sources/Paywalls/PaywallData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//
// Created by Nacho Soto on 7/10/23.

// swiftlint:disable file_length
// swiftlint:disable file_length identifier_name

import Foundation

Expand All @@ -32,7 +32,13 @@ public struct PaywallData {
public var assetBaseURL: URL

/// The revision identifier for this paywall.
public var revision: Int
var revision: Int {
get { return self._revision }
set { self._revision = newValue }
}

@DefaultDecodable.Zero
internal private(set) var _revision: Int = 0

@EnsureNonEmptyCollectionDecodable
internal private(set) var localization: [String: LocalizedConfiguration]
Expand Down Expand Up @@ -63,8 +69,6 @@ public protocol PaywallLocalizedConfiguration {

}

// swiftlint:disable identifier_name

extension PaywallData {

/// Defines the necessary localized information for a paywall.
Expand Down Expand Up @@ -435,7 +439,7 @@ extension PaywallData: Codable {
case config
case localization = "localizedStrings"
case assetBaseURL = "assetBaseUrl"
case revision
case _revision = "revision"
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"title" : "Ignite your child's curiosity"
}
},
"revision" : 1,
"template_name" : "1"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"title" : "Ignite your child's curiosity"
}
},
"revision" : 3,
"template_name" : "2"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@
"dark": null
}
},
"asset_base_url": "https://rc-paywalls.s3.amazonaws.com",
"revision": 1
"asset_base_url": "https://rc-paywalls.s3.amazonaws.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@
"dark": null
}
},
"asset_base_url": "https://rc-paywalls.s3.amazonaws.com",
"revision": 1
"asset_base_url": "https://rc-paywalls.s3.amazonaws.com"
}

0 comments on commit c24be7f

Please sign in to comment.