File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
BuckoNetworking/Protocols Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 66// Copyright © 2017 Teeps. All rights reserved.
77//
88
9- import Alamofire
10-
119public protocol DecodableEndpoint : Endpoint {
1210 associatedtype ResponseType : Decodable
1311}
@@ -34,4 +32,13 @@ public extension DecodableEndpoint {
3432
3533 return request
3634 }
35+
36+ public func request( ) -> Promise < ResponseType > {
37+ return Bucko . shared. requestData ( endpoint: self ) . then { data in
38+ return Promise { fullfill, _ in
39+ let result = try JSONDecoder ( ) . decode ( ResponseType . self, from: data)
40+ fullfill ( result)
41+ }
42+ }
43+ }
3744}
Original file line number Diff line number Diff line change @@ -84,4 +84,13 @@ public extension Endpoint {
8484
8585 return request
8686 }
87+
88+ public func request< T: Decodable > ( responseType: T . Type ) -> Promise < T > {
89+ return Bucko . shared. requestData ( endpoint: self ) . then { data in
90+ return Promise { fullfill, _ in
91+ let result = try JSONDecoder ( ) . decode ( T . self, from: data)
92+ fullfill ( result)
93+ }
94+ }
95+ }
8796}
You can’t perform that action at this time.
0 commit comments