This repository was archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathPreference.swift
306 lines (300 loc) · 13.1 KB
/
Preference.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
//
// Preference.swift
// reddift
//
// Created by sonson on 2015/11/10.
// Copyright © 2015年 sonson. All rights reserved.
//
import Foundation
/**
*/
public enum PreferenceDefaultCommentSortType: String {
case confidence = "confidence"
case old = "old"
case top = "top"
case qa = "qa"
case controversial = "controversial"
case new = "new"
public init(_ value: String) {
switch value {
case "confidence":
self = .confidence
case "old":
self = .old
case "top":
self = .top
case "qa":
self = .qa
case "controversial":
self = .controversial
case "new":
self = .new
default:
self = .confidence
}
}
}
/**
*/
public enum PreferenceMediaType: String {
case on = "on"
case off = "off"
case subreddit = "subreddit"
public init(_ value: String) {
switch value {
case "on":
self = .on
case "off":
self = .off
case "subreddit":
self = .subreddit
default:
self = .on
}
}
}
/**
Preference object.
generated by https://gist.github.com/sonsongithub/09177dd82d9b3689938b
*/
public struct Preference {
let beta: Bool?
let clickgadget: Bool?
let collapseReadMessages: Bool?
let compress: Bool?
let credditAutorenew: Bool?
let defaultCommentSort: PreferenceDefaultCommentSortType?
let domainDetails: Bool?
let emailMessages: Bool?
let enableDefaultThemes: Bool?
let hideAds: Bool?
let hideDowns: Bool?
let hideFromRobots: Bool?
let hideLocationbar: Bool?
let hideUps: Bool?
let highlightControversial: Bool?
let highlightNewComments: Bool?
let ignoreSuggestedSort: Bool?
let labelNsfw: Bool?
let lang: String?
let legacySearch: Bool?
let markMessagesRead: Bool?
let media: PreferenceMediaType?
let minCommentScore: Int?
let minLinkScore: Int?
let monitorMentions: Bool?
let newwindow: Bool?
let noProfanity: Bool?
let numComments: Int?
let numsites: Int?
let organic: Bool?
let otherTheme: String?
let over18: Bool?
let privateFeeds: Bool?
let publicVotes: Bool?
let research: Bool?
let showFlair: Bool?
let showGoldExpiration: Bool?
let showLinkFlair: Bool?
let showPromote: Bool?
let showStylesheets: Bool?
let showTrending: Bool?
let storeVisits: Bool?
let themeSelector: String?
let threadedMessages: Bool?
let threadedModmail: Bool?
let useGlobalDefaults: Bool?
public func json() -> JSONDictionary {
var json: JSONDictionary = [:]
if let temp = beta { json["beta"] = temp as AnyObject }
if let temp = clickgadget { json["clickgadget"] = temp as AnyObject }
if let temp = collapseReadMessages { json["collapse_read_messages"] = temp as AnyObject }
if let temp = compress { json["compress"] = temp as AnyObject }
if let temp = credditAutorenew { json["creddit_autorenew"] = temp as AnyObject }
if let temp = defaultCommentSort { json["default_comment_sort"] = temp.rawValue as AnyObject }
if let temp = domainDetails { json["domain_details"] = temp as AnyObject }
if let temp = emailMessages { json["email_messages"] = temp as AnyObject }
if let temp = enableDefaultThemes { json["enable_default_themes"] = temp as AnyObject }
if let temp = hideAds { json["hide_ads"] = temp as AnyObject }
if let temp = hideDowns { json["hide_downs"] = temp as AnyObject }
if let temp = hideFromRobots { json["hide_from_robots"] = temp as AnyObject }
if let temp = hideLocationbar { json["hide_locationbar"] = temp as AnyObject }
if let temp = hideUps { json["hide_ups"] = temp as AnyObject }
if let temp = highlightControversial { json["highlight_controversial"] = temp as AnyObject }
if let temp = highlightNewComments { json["highlight_new_comments"] = temp as AnyObject }
if let temp = ignoreSuggestedSort { json["ignore_suggested_sort"] = temp as AnyObject }
if let temp = labelNsfw { json["label_nsfw"] = temp as AnyObject }
if let temp = lang { json["lang"] = temp as AnyObject }
if let temp = legacySearch { json["legacy_search"] = temp as AnyObject }
if let temp = markMessagesRead { json["mark_messages_read"] = temp as AnyObject }
if let temp = media { json["media"] = temp.rawValue as AnyObject }
if let temp = minCommentScore { json["min_comment_score"] = temp as AnyObject }
if let temp = minLinkScore { json["min_link_score"] = temp as AnyObject }
if let temp = monitorMentions { json["monitor_mentions"] = temp as AnyObject }
if let temp = newwindow { json["newwindow"] = temp as AnyObject }
if let temp = noProfanity { json["no_profanity"] = temp as AnyObject }
if let temp = numComments { json["num_comments"] = temp as AnyObject }
if let temp = numsites { json["numsites"] = temp as AnyObject }
if let temp = organic { json["organic"] = temp as AnyObject }
if let temp = otherTheme { json["other_theme"] = temp as AnyObject }
if let temp = over18 { json["over_18"] = temp as AnyObject }
if let temp = privateFeeds { json["private_feeds"] = temp as AnyObject }
if let temp = publicVotes { json["public_votes"] = temp as AnyObject }
if let temp = research { json["research"] = temp as AnyObject }
if let temp = showFlair { json["show_flair"] = temp as AnyObject }
if let temp = showGoldExpiration { json["show_gold_expiration"] = temp as AnyObject }
if let temp = showLinkFlair { json["show_link_flair"] = temp as AnyObject }
if let temp = showPromote { json["show_promote"] = temp as AnyObject }
if let temp = showStylesheets { json["show_stylesheets"] = temp as AnyObject }
if let temp = showTrending { json["show_trending"] = temp as AnyObject }
if let temp = storeVisits { json["store_visits"] = temp as AnyObject }
if let temp = themeSelector { json["theme_selector"] = temp as AnyObject }
if let temp = threadedMessages { json["threaded_messages"] = temp as AnyObject }
if let temp = threadedModmail { json["threaded_modmail"] = temp as AnyObject }
if let temp = useGlobalDefaults { json["use_global_defaults"] = temp as AnyObject }
return json
}
public init(json: JSONDictionary) {
self.beta = json["beta"] as? Bool
self.clickgadget = json["clickgadget"] as? Bool
self.collapseReadMessages = json["collapse_read_messages"] as? Bool
self.compress = json["compress"] as? Bool
self.credditAutorenew = json["creddit_autorenew"] as? Bool
if let temp = json["default_comment_sort"] as? String { self.defaultCommentSort = PreferenceDefaultCommentSortType(temp) } else { self.defaultCommentSort = nil }
self.domainDetails = json["domain_details"] as? Bool
self.emailMessages = json["email_messages"] as? Bool
self.enableDefaultThemes = json["enable_default_themes"] as? Bool
self.hideAds = json["hide_ads"] as? Bool
self.hideDowns = json["hide_downs"] as? Bool
self.hideFromRobots = json["hide_from_robots"] as? Bool
self.hideLocationbar = json["hide_locationbar"] as? Bool
self.hideUps = json["hide_ups"] as? Bool
self.highlightControversial = json["highlight_controversial"] as? Bool
self.highlightNewComments = json["highlight_new_comments"] as? Bool
self.ignoreSuggestedSort = json["ignore_suggested_sort"] as? Bool
self.labelNsfw = json["label_nsfw"] as? Bool
self.lang = json["lang"] as? String
self.legacySearch = json["legacy_search"] as? Bool
self.markMessagesRead = json["mark_messages_read"] as? Bool
if let temp = json["media"] as? String { self.media = PreferenceMediaType(temp) } else { self.media = nil }
self.minCommentScore = json["min_comment_score"] as? Int
self.minLinkScore = json["min_link_score"] as? Int
self.monitorMentions = json["monitor_mentions"] as? Bool
self.newwindow = json["newwindow"] as? Bool
self.noProfanity = json["no_profanity"] as? Bool
self.numComments = json["num_comments"] as? Int
self.numsites = json["numsites"] as? Int
self.organic = json["organic"] as? Bool
self.otherTheme = json["other_theme"] as? String
self.over18 = json["over_18"] as? Bool
self.privateFeeds = json["private_feeds"] as? Bool
self.publicVotes = json["public_votes"] as? Bool
self.research = json["research"] as? Bool
self.showFlair = json["show_flair"] as? Bool
self.showGoldExpiration = json["show_gold_expiration"] as? Bool
self.showLinkFlair = json["show_link_flair"] as? Bool
self.showPromote = json["show_promote"] as? Bool
self.showStylesheets = json["show_stylesheets"] as? Bool
self.showTrending = json["show_trending"] as? Bool
self.storeVisits = json["store_visits"] as? Bool
self.themeSelector = json["theme_selector"] as? String
self.threadedMessages = json["threaded_messages"] as? Bool
self.threadedModmail = json["threaded_modmail"] as? Bool
self.useGlobalDefaults = json["use_global_defaults"] as? Bool
}
public init(
beta: Bool? = nil,
clickgadget: Bool? = nil,
collapseReadMessages: Bool? = nil,
compress: Bool? = nil,
credditAutorenew: Bool? = nil,
defaultCommentSort: PreferenceDefaultCommentSortType? = nil,
domainDetails: Bool? = nil,
emailMessages: Bool? = nil,
enableDefaultThemes: Bool? = nil,
hideAds: Bool? = nil,
hideDowns: Bool? = nil,
hideFromRobots: Bool? = nil,
hideLocationbar: Bool? = nil,
hideUps: Bool? = nil,
highlightControversial: Bool? = nil,
highlightNewComments: Bool? = nil,
ignoreSuggestedSort: Bool? = nil,
labelNsfw: Bool? = nil,
lang: String? = nil,
legacySearch: Bool? = nil,
markMessagesRead: Bool? = nil,
media: PreferenceMediaType? = nil,
minCommentScore: Int? = nil,
minLinkScore: Int? = nil,
monitorMentions: Bool? = nil,
newwindow: Bool? = nil,
noProfanity: Bool? = nil,
numComments: Int? = nil,
numsites: Int? = nil,
organic: Bool? = nil,
otherTheme: String? = nil,
over18: Bool? = nil,
privateFeeds: Bool? = nil,
publicVotes: Bool? = nil,
research: Bool? = nil,
showFlair: Bool? = nil,
showGoldExpiration: Bool? = nil,
showLinkFlair: Bool? = nil,
showPromote: Bool? = nil,
showStylesheets: Bool? = nil,
showTrending: Bool? = nil,
storeVisits: Bool? = nil,
themeSelector: String? = nil,
threadedMessages: Bool? = nil,
threadedModmail: Bool? = nil,
useGlobalDefaults: Bool? = nil
) {
self.beta = beta
self.clickgadget = clickgadget
self.collapseReadMessages = collapseReadMessages
self.compress = compress
self.credditAutorenew = credditAutorenew
self.defaultCommentSort = defaultCommentSort
self.domainDetails = domainDetails
self.emailMessages = emailMessages
self.enableDefaultThemes = enableDefaultThemes
self.hideAds = hideAds
self.hideDowns = hideDowns
self.hideFromRobots = hideFromRobots
self.hideLocationbar = hideLocationbar
self.hideUps = hideUps
self.highlightControversial = highlightControversial
self.highlightNewComments = highlightNewComments
self.ignoreSuggestedSort = ignoreSuggestedSort
self.labelNsfw = labelNsfw
self.lang = lang
self.legacySearch = legacySearch
self.markMessagesRead = markMessagesRead
self.media = media
self.minCommentScore = minCommentScore
self.minLinkScore = minLinkScore
self.monitorMentions = monitorMentions
self.newwindow = newwindow
self.noProfanity = noProfanity
self.numComments = numComments
self.numsites = numsites
self.organic = organic
self.otherTheme = otherTheme
self.over18 = over18
self.privateFeeds = privateFeeds
self.publicVotes = publicVotes
self.research = research
self.showFlair = showFlair
self.showGoldExpiration = showGoldExpiration
self.showLinkFlair = showLinkFlair
self.showPromote = showPromote
self.showStylesheets = showStylesheets
self.showTrending = showTrending
self.storeVisits = storeVisits
self.themeSelector = themeSelector
self.threadedMessages = threadedMessages
self.threadedModmail = threadedModmail
self.useGlobalDefaults = useGlobalDefaults
}
}