-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new timestamp field to data model Bumped version
- Loading branch information
Showing
16 changed files
with
414 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// TeslaTimeStampTransform.swift | ||
// TeslaSwift | ||
// | ||
// Created by Joao Nunes on 12/03/2017. | ||
// Copyright © 2017 Joao Nunes. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import ObjectMapper | ||
|
||
class TeslaTimeStampTransform: DateTransform { | ||
|
||
open override func transformFromJSON(_ value: Any?) -> Date? { | ||
if let timeInt = value as? Double { | ||
return Date(timeIntervalSince1970: TimeInterval(timeInt/1000)) | ||
} | ||
|
||
if let timeStr = value as? String { | ||
return Date(timeIntervalSince1970: TimeInterval(atof(timeStr))) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
open override func transformToJSON(_ value: Date?) -> Double? { | ||
if let date = value { | ||
return Double(date.timeIntervalSince1970 * 1000) | ||
} | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// VehicleConfig.swift | ||
// TeslaSwift | ||
// | ||
// Created by Joao Nunes on 12/03/2017. | ||
// Copyright © 2017 Joao Nunes. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import ObjectMapper | ||
|
||
open class VehicleConfig: Mappable { | ||
|
||
open var carSpecialType: String? | ||
open var carType: String? | ||
open var euVehicle: Bool? | ||
open var exteriorColor: String? | ||
open var hasLudicoursMode: Bool? | ||
open var motorizedChargePort: Bool? | ||
open var perfConfig: String? | ||
open var rearSeatHeaters: Bool? | ||
open var rearSeatType: Int? | ||
open var rhd: Bool? | ||
open var roofColor: String? // "None" for panoramic roof | ||
open var seatType: Int? | ||
open var spoilerType: String? | ||
open var sunRoofInstalled: Bool? | ||
open var thirdRowSeats: String? | ||
open var timeStamp: Date? | ||
open var trimBadging: String? | ||
open var wheelType: String? | ||
|
||
required public init?(map: Map) { | ||
|
||
} | ||
|
||
open func mapping(map: Map) { | ||
|
||
carSpecialType <- map["car_special_type"] | ||
carType <- map["car_type"] | ||
euVehicle <- map["eu_vehicle"] | ||
exteriorColor <- map["exterior_color"] | ||
hasLudicoursMode <- map["has_ludicrous_mode"] | ||
motorizedChargePort <- map["motorized_charge_port"] | ||
perfConfig <- map["perf_config"] | ||
rearSeatHeaters <- map["rear_seat_heaters"] | ||
rearSeatType <- map["rear_seat_type"] | ||
rhd <- map["rhd"] | ||
roofColor <- map["roof_color"] | ||
seatType <- map["seat_type"] | ||
spoilerType <- map["spoiler_type"] | ||
sunRoofInstalled <- map["sun_roof_installed"] | ||
thirdRowSeats <- map["third_row_seats"] | ||
timeStamp <- (map["timestamp"], TeslaTimeStampTransform()) | ||
trimBadging <- map["trim_badging"] | ||
wheelType <- map["wheel_type"] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// VehicleExtended.swift | ||
// TeslaSwift | ||
// | ||
// Created by Joao Nunes on 12/03/2017. | ||
// Copyright © 2017 Joao Nunes. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import ObjectMapper | ||
|
||
open class VehicleExtended: Vehicle { | ||
|
||
open var userId: Int? | ||
open var chargeState: ChargeState? | ||
open var climateState: ClimateState? | ||
open var driveState: DriveState? | ||
open var guiSettings: GuiSettings? | ||
open var vehicleConfig: VehicleConfig? | ||
open var vehicleState: VehicleState? | ||
|
||
|
||
open override func mapping(map: Map) { | ||
super.mapping(map: map) | ||
|
||
userId <- map["user_id"] | ||
chargeState <- map["charge_state"] | ||
climateState <- map["climate_state"] | ||
driveState <- map["drive_state"] | ||
guiSettings <- map["gui_settings"] | ||
vehicleConfig <- map["vehicle_config"] | ||
vehicleState <- map["vehicle_state"] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.