Skip to content

Commit 298ce4e

Browse files
authored
Add files via upload
0 parents  commit 298ce4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4007
-0
lines changed

Cartfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github "Alamofire/Alamofire" ~> 4.9.0

SwaggerClient.podspec

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'SwaggerClient'
3+
s.ios.deployment_target = '9.0'
4+
s.osx.deployment_target = '10.11'
5+
s.tvos.deployment_target = '9.0'
6+
s.version = '0.0.1'
7+
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
8+
s.authors = 'Swagger Codegen'
9+
s.license = 'Proprietary'
10+
s.source_files = 'SwaggerClient/Classes/**/*.swift'
11+
s.dependency 'Alamofire', '~> 4.9.0'
12+
end
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// APIHelper.swift
2+
//
3+
// Generated by swagger-codegen
4+
// https://github.com/swagger-api/swagger-codegen
5+
//
6+
7+
import Foundation
8+
9+
public struct APIHelper {
10+
public static func rejectNil(_ source: [String:Any?]) -> [String:Any]? {
11+
let destination = source.reduce(into: [String: Any]()) { (result, item) in
12+
if let value = item.value {
13+
result[item.key] = value
14+
}
15+
}
16+
17+
if destination.isEmpty {
18+
return nil
19+
}
20+
return destination
21+
}
22+
23+
public static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] {
24+
return source.reduce(into: [String: String]()) { (result, item) in
25+
if let collection = item.value as? Array<Any?> {
26+
result[item.key] = collection.filter({ $0 != nil }).map{ "\($0!)" }.joined(separator: ",")
27+
} else if let value: Any = item.value {
28+
result[item.key] = "\(value)"
29+
}
30+
}
31+
}
32+
33+
public static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? {
34+
guard let source = source else {
35+
return nil
36+
}
37+
38+
return source.reduce(into: [String: Any](), { (result, item) in
39+
switch item.value {
40+
case let x as Bool:
41+
result[item.key] = x.description
42+
default:
43+
result[item.key] = item.value
44+
}
45+
})
46+
}
47+
48+
49+
public static func mapValuesToQueryItems(_ source: [String:Any?]) -> [URLQueryItem]? {
50+
let destination = source.filter({ $0.value != nil}).reduce(into: [URLQueryItem]()) { (result, item) in
51+
if let collection = item.value as? Array<Any?> {
52+
let value = collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
53+
result.append(URLQueryItem(name: item.key, value: value))
54+
} else if let value = item.value {
55+
result.append(URLQueryItem(name: item.key, value: "\(value)"))
56+
}
57+
}
58+
59+
if destination.isEmpty {
60+
return nil
61+
}
62+
return destination
63+
}
64+
}
65+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// APIs.swift
2+
//
3+
// Generated by swagger-codegen
4+
// https://github.com/swagger-api/swagger-codegen
5+
//
6+
7+
import Foundation
8+
9+
open class SwaggerClientAPI {
10+
public static var basePath = "https://chompthis.com/api/v2"
11+
public static var credential: URLCredential?
12+
public static var customHeaders: [String:String] = [:]
13+
public static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
14+
}
15+
16+
open class RequestBuilder<T> {
17+
var credential: URLCredential?
18+
var headers: [String:String]
19+
public let parameters: [String:Any]?
20+
public let isBody: Bool
21+
public let method: String
22+
public let URLString: String
23+
24+
/// Optional block to obtain a reference to the request's progress instance when available.
25+
public var onProgressReady: ((Progress) -> ())?
26+
27+
required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) {
28+
self.method = method
29+
self.URLString = URLString
30+
self.parameters = parameters
31+
self.isBody = isBody
32+
self.headers = headers
33+
34+
addHeaders(SwaggerClientAPI.customHeaders)
35+
}
36+
37+
open func addHeaders(_ aHeaders:[String:String]) {
38+
for (header, value) in aHeaders {
39+
headers[header] = value
40+
}
41+
}
42+
43+
open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) { }
44+
45+
public func addHeader(name: String, value: String) -> Self {
46+
if !value.isEmpty {
47+
headers[name] = value
48+
}
49+
return self
50+
}
51+
52+
open func addCredential() -> Self {
53+
self.credential = SwaggerClientAPI.credential
54+
return self
55+
}
56+
}
57+
58+
public protocol RequestBuilderFactory {
59+
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type
60+
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type
61+
}

0 commit comments

Comments
 (0)