-
Notifications
You must be signed in to change notification settings - Fork 0
/
MIAUser.swift
61 lines (56 loc) · 1.93 KB
/
MIAUser.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
//
// User.swift
// Show Prode
//
// Created by Matias Camiletti on 11/3/18.
// Copyright © 2018 Matias Camiletti. All rights reserved.
//
import Foundation
import RealmSwift
open class MIAUser : Object, Decodable {
@objc open dynamic var id = 0;
@objc open dynamic var app_id = 0;
@objc open dynamic var access_token = "";
@objc open dynamic var email = "";
@objc open dynamic var firstname = "";
@objc open dynamic var lastname = "";
@objc open dynamic var photo = "";
@objc open dynamic var phone = "";
@objc open dynamic var created_at = "";
open var fullname: String { // read-only properties are automatically ignored
return "\(firstname) \(lastname)"
}
open override static func primaryKey() -> String? {
return "id"
}
enum MIAUserEnum: String, CodingKey {
case id
case app_id
case email
case firstname
case lastname
case photo
case phone
case created_at
}
open required convenience init(from decoder: Decoder) throws {
self.init();
let container = try decoder.container(keyedBy: MIAUserEnum.self);
do{
id = try container.decode(Int.self, forKey: .id)
}catch{
id = Int(try container.decode(String.self, forKey: .id))!;
}
do{
app_id = try container.decode(Int.self, forKey: .app_id)
}catch{
app_id = Int(try container.decode(String.self, forKey: .app_id))!;
}
email = try container.decode(String.self, forKey: .email)
firstname = try container.decode(String.self, forKey: .firstname)
lastname = try container.decode(String.self, forKey: .lastname)
photo = try container.decode(String.self, forKey: .photo)
phone = try container.decode(String.self, forKey: .phone)
created_at = try container.decode(String.self, forKey: .created_at)
}
}