Showing
1 changed file
with
60 additions
and
4 deletions
... | @@ -2172,12 +2172,20 @@ public class swiftApi { | ... | @@ -2172,12 +2172,20 @@ public class swiftApi { |
2172 | 2172 | ||
2173 | public class PacingDetails { | 2173 | public class PacingDetails { |
2174 | private var steps: PacingInner | 2174 | private var steps: PacingInner |
2175 | - private var meters: PacingDetailsInner | 2175 | + private var meters: PacingInner |
2176 | 2176 | ||
2177 | 2177 | ||
2178 | public init() { | 2178 | public init() { |
2179 | self.steps = PacingInner() | 2179 | self.steps = PacingInner() |
2180 | - self.meters = PacingDetailsInner() | 2180 | + self.meters = PacingInner() |
2181 | + } | ||
2182 | + | ||
2183 | + public init(dictionary: [String: Any]) { | ||
2184 | + let pacingDataSteps = (dictionary["steps"] as? [String: Any] ?? [String: Any]()) | ||
2185 | + let pacingDataMeters = (dictionary["meters"] as? [String: Any] ?? [String: Any]()) | ||
2186 | + | ||
2187 | + self.steps = PacingInner(dictionary: pacingDataSteps) | ||
2188 | + self.meters = PacingInner(dictionary: pacingDataMeters) | ||
2181 | } | 2189 | } |
2182 | 2190 | ||
2183 | public var _steps: PacingInner { | 2191 | public var _steps: PacingInner { |
... | @@ -2189,7 +2197,7 @@ public class swiftApi { | ... | @@ -2189,7 +2197,7 @@ public class swiftApi { |
2189 | } | 2197 | } |
2190 | } | 2198 | } |
2191 | 2199 | ||
2192 | - public var _meters: PacingDetailsInner { | 2200 | + public var _meters: PacingInner { |
2193 | get { // getter | 2201 | get { // getter |
2194 | return self.meters | 2202 | return self.meters |
2195 | } | 2203 | } |
... | @@ -2212,6 +2220,33 @@ public class swiftApi { | ... | @@ -2212,6 +2220,33 @@ public class swiftApi { |
2212 | self.week = PacingDetailsInner() | 2220 | self.week = PacingDetailsInner() |
2213 | self.day = PacingDetailsInner() | 2221 | self.day = PacingDetailsInner() |
2214 | } | 2222 | } |
2223 | + | ||
2224 | + public init(dictionary: [String: Any]) { | ||
2225 | + | ||
2226 | + if let stepsTotal = dictionary["total"] as? [String: Any] { | ||
2227 | + self.total = PacingDetailsInner(dictionary: stepsTotal) | ||
2228 | + } else { | ||
2229 | + self.total = PacingDetailsInner() | ||
2230 | + } | ||
2231 | + | ||
2232 | + if let stepsMonth = dictionary["month"] as? [String: Any] { | ||
2233 | + self.month = PacingDetailsInner(dictionary: stepsMonth) | ||
2234 | + } else { | ||
2235 | + self.month = PacingDetailsInner() | ||
2236 | + } | ||
2237 | + | ||
2238 | + if let stepsWeek = dictionary["week"] as? [String: Any] { | ||
2239 | + self.week = PacingDetailsInner(dictionary: stepsWeek) | ||
2240 | + } else { | ||
2241 | + self.week = PacingDetailsInner() | ||
2242 | + } | ||
2243 | + | ||
2244 | + if let stepsDay = dictionary["day"] as? [String: Any] { | ||
2245 | + self.day = PacingDetailsInner(dictionary: stepsDay) | ||
2246 | + } else { | ||
2247 | + self.day = PacingDetailsInner() | ||
2248 | + } | ||
2249 | + } | ||
2215 | 2250 | ||
2216 | public var _total: PacingDetailsInner { | 2251 | public var _total: PacingDetailsInner { |
2217 | get { // getter | 2252 | get { // getter |
... | @@ -2263,6 +2298,22 @@ public class swiftApi { | ... | @@ -2263,6 +2298,22 @@ public class swiftApi { |
2263 | 2298 | ||
2264 | } | 2299 | } |
2265 | 2300 | ||
2301 | + public init(dictionary: [String: Any]) { | ||
2302 | + self.goal = dictionary["goal"] as? Float ?? 0.0 | ||
2303 | + self.value = dictionary["value"] as? Float ?? 0.0 | ||
2304 | + | ||
2305 | + if let perDay = dictionary["per_day"] as? [[String: Any]] { | ||
2306 | + var tempPerDayArray: Array<PacingDetailsDay> = [] | ||
2307 | + for item in perDay { | ||
2308 | + let newPerDayItem = PacingDetailsDay(dictionary: item) | ||
2309 | + tempPerDayArray.append(newPerDayItem) | ||
2310 | + } | ||
2311 | + self.per_day = tempPerDayArray | ||
2312 | + } else { | ||
2313 | + self.per_day = [] | ||
2314 | + } | ||
2315 | + } | ||
2316 | + | ||
2266 | public var _goal: Float { | 2317 | public var _goal: Float { |
2267 | get { // getter | 2318 | get { // getter |
2268 | return self.goal | 2319 | return self.goal |
... | @@ -2299,7 +2350,11 @@ public class swiftApi { | ... | @@ -2299,7 +2350,11 @@ public class swiftApi { |
2299 | public init() { | 2350 | public init() { |
2300 | self.day = "" | 2351 | self.day = "" |
2301 | self.value = 0.0 | 2352 | self.value = 0.0 |
2302 | - | 2353 | + } |
2354 | + | ||
2355 | + public init(dictionary: [String: Any]) { | ||
2356 | + self.day = dictionary["day"] as? String ?? "" | ||
2357 | + self.value = dictionary["value"] as? Double ?? 0.0 | ||
2303 | } | 2358 | } |
2304 | 2359 | ||
2305 | public var _day: String { | 2360 | public var _day: String { |
... | @@ -2321,4 +2376,5 @@ public class swiftApi { | ... | @@ -2321,4 +2376,5 @@ public class swiftApi { |
2321 | } | 2376 | } |
2322 | } | 2377 | } |
2323 | 2378 | ||
2379 | + | ||
2324 | } | 2380 | } | ... | ... |
-
Please register or login to post a comment