-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathExtensions.swift
63 lines (57 loc) · 1.64 KB
/
Extensions.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
//
// Extensions.swift
// truecaller_sdk
//
// Created by Sreedeepkesav M S on 02/03/22.
//
import Foundation
import TrueSDK
extension TCTrueProfileResponse {
var toDict: [String: AnyHashable] {
var dict = [String: AnyHashable]()
dict["payload"] = payload
dict["signature"] = signature
dict["signatureAlgorithm"] = signatureAlgorithm
dict["requestNonce"] = requestNonce
return dict
}
}
extension TCTrueProfile {
var toDict: [String: AnyHashable] {
var dict = [String: AnyHashable]()
dict["firstName"] = firstName
dict["lastName"] = lastName
dict["isVerified"] = isVerified
dict["isAmbassador"] = isAmbassador
dict["phoneNumber"] = phoneNumber
dict["countryCode"] = countryCode
dict["street"] = street
dict["city"] = city
dict["facebookID"] = facebookID
dict["twitterID"] = twitterID
dict["email"] = email
dict["url"] = url
dict["avatarURL"] = avatarURL
dict["jobTitle"] = jobTitle
dict["companyName"] = companyName
dict["requestTime"] = requestTime
dict["genderValue"] = gender.rawValue
return dict
}
}
extension TCError {
var toDict: [String: AnyHashable] {
var dict = [String: AnyHashable]()
dict["code"] = getCode().rawValue
dict["message"] = description
return dict
}
}
extension Dictionary {
var tojsonString: String? {
guard let data = try? JSONSerialization.data(withJSONObject: self) else {
return nil
}
return String(data: data, encoding: .utf8)
}
}