@@ -11,58 +11,58 @@ import Foundation
11
11
// MARK: - Service.Router
12
12
13
13
extension Service {
14
- enum Router {
15
- case geoLocation( ipAddress: String )
16
- case ASN( asn: String )
17
- case batch( withFilter: Bool )
18
- }
14
+ enum Router {
15
+ case geoLocation( ipAddress: String )
16
+ case ASN( asn: String )
17
+ case batch( withFilter: Bool )
18
+ }
19
19
}
20
20
21
21
extension Service . Router {
22
- var endPoint : String {
23
- switch self {
24
- case . geoLocation( let ipAddress) :
25
- " \( Service . shared. ipInfoURL) / \( ipAddress) /json "
26
- case . ASN( let asn) :
27
- " \( Service . shared. ipInfoURL) / \( asn) /json "
28
- case . batch( let withFilter) :
29
- " \( Service . shared. ipInfoURL) /batch " + ( withFilter ? " &filter=1 " : " " )
30
- }
31
- }
22
+ var endPoint : String {
23
+ switch self {
24
+ case . geoLocation( let ipAddress) :
25
+ " \( Service . shared. ipInfoURL) / \( ipAddress) /json "
26
+ case . ASN( let asn) :
27
+ " \( Service . shared. ipInfoURL) / \( asn) /json "
28
+ case . batch( let withFilter) :
29
+ " \( Service . shared. ipInfoURL) /batch " + ( withFilter ? " &filter=1 " : " " )
30
+ }
31
+ }
32
32
}
33
33
34
34
// MARK: - Service
35
35
36
36
class Service {
37
-
38
- // MARK: Lifecycle
39
-
40
- private init ( ) { }
41
-
42
- // MARK: Internal
43
-
44
- static let shared = Service ( )
45
-
46
- var ipInfoURL = " https://ipinfo.io "
47
- let headers : HTTPHeaders = [
48
- " Authorization " : " Bearer \( Constants . ACCESS_TOKEN) " ,
49
- ]
50
-
51
- func requestAPI(
52
- URL: Service . Router ,
53
- method: HTTPMethod ,
54
- params: Parameters ? = nil ,
55
- completion: @escaping ( _ status: Response , _ data: Data , _ msg: String ) -> Void ) {
56
-
57
- AF . request ( URL . endPoint , method: method, parameters: params , encoding: JSONEncoding . default, headers: headers)
58
- . response { response in
59
- switch response. result {
60
- case . success( let value) :
61
- completion ( . success, value ?? Data ( ) , " Success " )
62
- case . failure( let err) :
63
- completion ( . failure, Data ( ) , err. localizedDescription)
64
- break
65
- }
66
- }
67
- }
37
+
38
+ // MARK: Lifecycle
39
+
40
+ private init ( ) { }
41
+
42
+ // MARK: Internal
43
+
44
+ static let shared = Service ( )
45
+
46
+ var ipInfoURL = " https://ipinfo.io "
47
+ let headers : HTTPHeaders = [
48
+ " Authorization " : " Bearer \( Constants . ACCESS_TOKEN) " ,
49
+ ]
50
+
51
+ func requestAPI(
52
+ URL: Service . Router ,
53
+ method: HTTPMethod ,
54
+ params: Parameters ? = nil ,
55
+ completion: @escaping ( _ status: Response , _ data: Data , _ msg: String ) -> Void ) {
56
+
57
+ AF . request ( URL . endPoint , method: method, parameters: params , encoding: JSONEncoding . default, headers: headers)
58
+ . response { response in
59
+ switch response. result {
60
+ case . success( let value) :
61
+ completion ( . success, value ?? Data ( ) , " Success " )
62
+ case . failure( let err) :
63
+ completion ( . failure, Data ( ) , err. localizedDescription)
64
+ break
65
+ }
66
+ }
67
+ }
68
68
}
0 commit comments