|
8 | 8 |
|
9 | 9 | import Foundation |
10 | 10 |
|
11 | | -public protocol Request { |
| 11 | +protocol Request { |
12 | 12 | var url: URL { get set } |
13 | | - var method: HUHttpMethods {get set} |
| 13 | + var method: HUHttpMethods { get set } |
14 | 14 | } |
15 | 15 |
|
16 | 16 | public struct HURequest : Request { |
17 | | - public var url: URL |
18 | | - public var method: HUHttpMethods |
| 17 | + var url: URL |
| 18 | + var method: HUHttpMethods |
19 | 19 | var requestBody: Data? = nil |
20 | 20 |
|
21 | | - init(withUrl url: URL, forHttpMethod method: HUHttpMethods, requestBody: Data? = nil) { |
| 21 | + public init(withUrl url: URL, forHttpMethod method: HUHttpMethods, requestBody: Data? = nil) { |
22 | 22 | self.url = url |
23 | 23 | self.method = method |
24 | 24 | self.requestBody = requestBody != nil ? requestBody : nil |
25 | 25 | } |
26 | 26 | } |
27 | 27 |
|
28 | | -// the HUMedia will be part of next release |
29 | 28 | public struct HUMultiPartRequest : Request { |
30 | | - public var url: URL |
31 | | - public var method: HUHttpMethods |
| 29 | + |
| 30 | + var url: URL |
| 31 | + var method: HUHttpMethods |
32 | 32 | var request : Encodable |
33 | | - //var media : [HUMedia]? = nil |
34 | | -} |
35 | 33 |
|
36 | | -//public struct HUMedia |
37 | | -//{ |
38 | | -// let fileName : String // the name of the file that you want to save on the server |
39 | | -// let data: Data |
40 | | -// let mimeType: String // mime type of the file image/jpeg or image/png etc |
41 | | -// let parameterName : String // api parameter name |
42 | | -// |
43 | | -// init(withMediaData data: Data, name: String, mimeType: HUMimeType, parameterName: String) { |
44 | | -// |
45 | | -// self.data = data |
46 | | -// self.fileName = name |
47 | | -// self.mimeType = mimeType.rawValue |
48 | | -// self.parameterName = parameterName |
49 | | -// } |
50 | | -//} |
51 | | -// |
52 | | -//public enum HUMimeType : String |
53 | | -//{ |
54 | | -// // images mime type |
55 | | -// case gif = "image/gif" |
56 | | -// case jpeg = "image/jpeg" |
57 | | -// case pjpeg = "image/pjpeg" |
58 | | -// case png = "image/png" |
59 | | -// case svgxml = "image/svg+xml" |
60 | | -// case tiff = "image/tiff" |
61 | | -// case bmp = "image/bmp" |
62 | | -// |
63 | | -// // document mime type |
64 | | -// case csv = "text/csv" |
65 | | -// case wordDocument = "application/msword" |
66 | | -// case pdf = "application/pdf" |
67 | | -// case richTextFormat = "application/rtf" |
68 | | -// case plainText = "text/plain" |
69 | | -// |
70 | | -//} |
| 34 | + public init(withUrl url: URL, forHttpMethod method: HUHttpMethods, requestBody: Encodable) { |
| 35 | + self.url = url |
| 36 | + self.method = method |
| 37 | + self.request = requestBody |
| 38 | + } |
| 39 | +} |
0 commit comments