diff --git a/swift/.gitignore b/swift/.gitignore new file mode 100644 index 0000000..5e5d5ce --- /dev/null +++ b/swift/.gitignore @@ -0,0 +1,63 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots diff --git a/swift/.swagger-codegen-ignore b/swift/.swagger-codegen-ignore new file mode 100644 index 0000000..c5fa491 --- /dev/null +++ b/swift/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/swift/Cartfile b/swift/Cartfile new file mode 100644 index 0000000..3d90db1 --- /dev/null +++ b/swift/Cartfile @@ -0,0 +1 @@ +github "Alamofire/Alamofire" >= 3.1.0 diff --git a/swift/LICENSE b/swift/LICENSE new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/swift/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/swift/SwaggerClient.podspec b/swift/SwaggerClient.podspec new file mode 100644 index 0000000..b628ffd --- /dev/null +++ b/swift/SwaggerClient.podspec @@ -0,0 +1,11 @@ +Pod::Spec.new do |s| + s.name = 'SwaggerClient' + s.ios.deployment_target = '8.0' + s.osx.deployment_target = '10.9' + s.version = '0.0.1' + s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' } + s.authors = 'Swagger Codegen' + s.license = 'Apache License, Version 2.0' + s.source_files = 'SwaggerClient/Classes/Swaggers/**/*.swift' + s.dependency 'Alamofire', '~> 3.1.5' +end diff --git a/swift/SwaggerClient/Classes/Swaggers/APIHelper.swift b/swift/SwaggerClient/Classes/Swaggers/APIHelper.swift new file mode 100644 index 0000000..23e727b --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/APIHelper.swift @@ -0,0 +1,40 @@ +// APIHelper.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +class APIHelper { + static func rejectNil(source: [String:AnyObject?]) -> [String:AnyObject]? { + var destination = [String:AnyObject]() + for (key, nillableValue) in source { + if let value: AnyObject = nillableValue { + destination[key] = value + } + } + + if destination.isEmpty { + return nil + } + return destination + } + + static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject]? { + guard let source = source else { + return nil + } + var destination = [String:AnyObject]() + let theTrue = NSNumber(bool: true) + let theFalse = NSNumber(bool: false) + for (key, value) in source { + switch value { + case let x where x === theTrue || x === theFalse: + destination[key] = "\(value as! Bool)" + default: + destination[key] = value + } + } + return destination + } + +} diff --git a/swift/SwaggerClient/Classes/Swaggers/APIs.swift b/swift/SwaggerClient/Classes/Swaggers/APIs.swift new file mode 100644 index 0000000..eb68491 --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/APIs.swift @@ -0,0 +1,76 @@ +// APIs.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + +public class SwaggerClientAPI { + public static var basePath = "https://api.openalpr.com/v2" + public static var credential: NSURLCredential? + public static var customHeaders: [String:String] = [:] + static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory() +} + +public class APIBase { + func toParameters(encodable: JSONEncodable?) -> [String: AnyObject]? { + let encoded: AnyObject? = encodable?.encodeToJSON() + + if encoded! is [AnyObject] { + var dictionary = [String:AnyObject]() + for (index, item) in (encoded as! [AnyObject]).enumerate() { + dictionary["\(index)"] = item + } + return dictionary + } else { + return encoded as? [String:AnyObject] + } + } +} + +public class RequestBuilder { + var credential: NSURLCredential? + var headers: [String:String] = [:] + let parameters: [String:AnyObject]? + let isBody: Bool + let method: String + let URLString: String + + /// Optional block to obtain a reference to the request's progress instance when available. + public var onProgressReady: ((NSProgress) -> ())? + + required public init(method: String, URLString: String, parameters: [String:AnyObject]?, isBody: Bool) { + self.method = method + self.URLString = URLString + self.parameters = parameters + self.isBody = isBody + + addHeaders(SwaggerClientAPI.customHeaders) + } + + public func addHeaders(aHeaders:[String:String]) { + for (header, value) in aHeaders { + headers[header] = value + } + } + + public func execute(completion: (response: Response?, error: ErrorType?) -> Void) { } + + public func addHeader(name name: String, value: String) -> Self { + if !value.isEmpty { + headers[name] = value + } + return self + } + + public func addCredential() -> Self { + self.credential = SwaggerClientAPI.credential + return self + } +} + +protocol RequestBuilderFactory { + func getBuilder() -> RequestBuilder.Type +} + diff --git a/swift/SwaggerClient/Classes/Swaggers/APIs/DefaultAPI.swift b/swift/SwaggerClient/Classes/Swaggers/APIs/DefaultAPI.swift new file mode 100644 index 0000000..4a9a82a --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/APIs/DefaultAPI.swift @@ -0,0 +1,330 @@ +// +// DefaultAPI.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Alamofire + + + +public class DefaultAPI: APIBase { + /** + + - parameter imageBytes: (body) The image file that you wish to analyze encoded in base64 + - parameter secretKey: (query) The secret key used to authenticate your account. You can view your secret key by visiting https://cloud.openalpr.com/ + - parameter country: (query) Defines the training data used by OpenALPR. \"us\" analyzes North-American style plates. \"eu\" analyzes European-style plates. This field is required if using the \"plate\" task You may use multiple datasets by using commas between the country codes. For example, 'au,auwide' would analyze using both the Australian plate styles. A full list of supported country codes can be found here https://github.com/openalpr/openalpr/tree/master/runtime_data/config + - parameter recognizeVehicle: (query) If set to 1, the vehicle will also be recognized in the image This requires an additional credit per request (optional, default to 0) + - parameter state: (query) Corresponds to a US state or EU country code used by OpenALPR pattern recognition. For example, using \"md\" matches US plates against the Maryland plate patterns. Using \"fr\" matches European plates against the French plate patterns. (optional, default to ) + - parameter returnImage: (query) If set to 1, the image you uploaded will be encoded in base64 and sent back along with the response (optional, default to 0) + - parameter topn: (query) The number of results you would like to be returned for plate candidates and vehicle classifications (optional, default to 10) + - parameter prewarp: (query) Prewarp configuration is used to calibrate the analyses for the angle of a particular camera. More information is available here http://doc.openalpr.com/accuracy_improvements.html#calibration (optional, default to ) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func recognizeBytes(imageBytes imageBytes: String, secretKey: String, country: String, recognizeVehicle: Int32? = nil, state: String? = nil, returnImage: Int32? = nil, topn: Int32? = nil, prewarp: String? = nil, completion: ((data: InlineResponse200?, error: ErrorType?) -> Void)) { + recognizeBytesWithRequestBuilder(imageBytes: imageBytes, secretKey: secretKey, country: country, recognizeVehicle: recognizeVehicle, state: state, returnImage: returnImage, topn: topn, prewarp: prewarp).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + + /** + - POST /recognize_bytes + - Send an image for OpenALPR to analyze and provide metadata back The image is sent as base64 encoded bytes. + - responseHeaders: [X-RateLimit-Limit(Int32), X-Ratelimit-Remaining(Int32), X-Ratelimit-Reset(Int32)] + - responseHeaders: [X-RateLimit-Limit(Int32), X-Ratelimit-Remaining(Int32), X-Ratelimit-Reset(Int32)] + - responseHeaders: [X-RateLimit-Limit(Int32), X-Ratelimit-Remaining(Int32), X-Ratelimit-Reset(Int32)] + - examples: [{contentType=application/json, example={ + "credits_monthly_used" : "", + "processing_time" : { + "total" : 1.3579000000000001069366817318950779736042022705078125, + "plates" : 1.3579000000000001069366817318950779736042022705078125, + "vehicles" : 1.3579000000000001069366817318950779736042022705078125 + }, + "regions_of_interest" : [ "" ], + "credits_monthly_total" : "", + "img_width" : "", + "img_height" : "", + "credit_cost" : "", + "data_type" : "aeiou", + "results" : [ { + "candidates" : [ { + "confidence" : 1.3579000000000001069366817318950779736042022705078125, + "plate" : "aeiou", + "matches_template" : "" + } ], + "processing_time_ms" : 1.3579000000000001069366817318950779736042022705078125, + "region_confidence" : 1.3579000000000001069366817318950779736042022705078125, + "requested_topn" : "", + "confidence" : 1.3579000000000001069366817318950779736042022705078125, + "coordinates" : [ { + "x" : "", + "y" : "" + } ], + "plate" : "aeiou", + "matches_template" : "", + "region" : "aeiou", + "vehicle_region" : { + "x" : "", + "width" : "", + "y" : "", + "height" : "" + }, + "vehicle" : { + "color" : [ { + "confidence" : 1.3579000000000001069366817318950779736042022705078125, + "name" : "aeiou" + } ], + "body_type" : [ "" ], + "make" : [ "" ], + "make_model" : [ "" ] + } + } ], + "epoch_time" : 1.3579000000000001069366817318950779736042022705078125, + "version" : "" +}}] + + - parameter imageBytes: (body) The image file that you wish to analyze encoded in base64 + - parameter secretKey: (query) The secret key used to authenticate your account. You can view your secret key by visiting https://cloud.openalpr.com/ + - parameter country: (query) Defines the training data used by OpenALPR. \"us\" analyzes North-American style plates. \"eu\" analyzes European-style plates. This field is required if using the \"plate\" task You may use multiple datasets by using commas between the country codes. For example, 'au,auwide' would analyze using both the Australian plate styles. A full list of supported country codes can be found here https://github.com/openalpr/openalpr/tree/master/runtime_data/config + - parameter recognizeVehicle: (query) If set to 1, the vehicle will also be recognized in the image This requires an additional credit per request (optional, default to 0) + - parameter state: (query) Corresponds to a US state or EU country code used by OpenALPR pattern recognition. For example, using \"md\" matches US plates against the Maryland plate patterns. Using \"fr\" matches European plates against the French plate patterns. (optional, default to ) + - parameter returnImage: (query) If set to 1, the image you uploaded will be encoded in base64 and sent back along with the response (optional, default to 0) + - parameter topn: (query) The number of results you would like to be returned for plate candidates and vehicle classifications (optional, default to 10) + - parameter prewarp: (query) Prewarp configuration is used to calibrate the analyses for the angle of a particular camera. More information is available here http://doc.openalpr.com/accuracy_improvements.html#calibration (optional, default to ) + + - returns: RequestBuilder + */ + public class func recognizeBytesWithRequestBuilder(imageBytes imageBytes: String, secretKey: String, country: String, recognizeVehicle: Int32? = nil, state: String? = nil, returnImage: Int32? = nil, topn: Int32? = nil, prewarp: String? = nil) -> RequestBuilder { + let path = "/recognize_bytes" + let URLString = SwaggerClientAPI.basePath + path + let parameters = imageBytes.encodeToJSON() as? [String:AnyObject] + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: false) + } + + /** + + - parameter image: (form) The image file that you wish to analyze + - parameter secretKey: (query) The secret key used to authenticate your account. You can view your secret key by visiting https://cloud.openalpr.com/ + - parameter country: (query) Defines the training data used by OpenALPR. \"us\" analyzes North-American style plates. \"eu\" analyzes European-style plates. This field is required if using the \"plate\" task You may use multiple datasets by using commas between the country codes. For example, 'au,auwide' would analyze using both the Australian plate styles. A full list of supported country codes can be found here https://github.com/openalpr/openalpr/tree/master/runtime_data/config + - parameter recognizeVehicle: (query) If set to 1, the vehicle will also be recognized in the image This requires an additional credit per request (optional, default to 0) + - parameter state: (query) Corresponds to a US state or EU country code used by OpenALPR pattern recognition. For example, using \"md\" matches US plates against the Maryland plate patterns. Using \"fr\" matches European plates against the French plate patterns. (optional, default to ) + - parameter returnImage: (query) If set to 1, the image you uploaded will be encoded in base64 and sent back along with the response (optional, default to 0) + - parameter topn: (query) The number of results you would like to be returned for plate candidates and vehicle classifications (optional, default to 10) + - parameter prewarp: (query) Prewarp configuration is used to calibrate the analyses for the angle of a particular camera. More information is available here http://doc.openalpr.com/accuracy_improvements.html#calibration (optional, default to ) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func recognizeFile(image image: NSURL, secretKey: String, country: String, recognizeVehicle: Int32? = nil, state: String? = nil, returnImage: Int32? = nil, topn: Int32? = nil, prewarp: String? = nil, completion: ((data: InlineResponse200?, error: ErrorType?) -> Void)) { + recognizeFileWithRequestBuilder(image: image, secretKey: secretKey, country: country, recognizeVehicle: recognizeVehicle, state: state, returnImage: returnImage, topn: topn, prewarp: prewarp).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + + /** + - POST /recognize + - Send an image for OpenALPR to analyze and provide metadata back The image is sent as a file using a form data POST + - responseHeaders: [X-RateLimit-Limit(Int32), X-Ratelimit-Remaining(Int32), X-Ratelimit-Reset(Int32)] + - responseHeaders: [X-RateLimit-Limit(Int32), X-Ratelimit-Remaining(Int32), X-Ratelimit-Reset(Int32)] + - responseHeaders: [X-RateLimit-Limit(Int32), X-Ratelimit-Remaining(Int32), X-Ratelimit-Reset(Int32)] + - examples: [{contentType=application/json, example={ + "credits_monthly_used" : "", + "processing_time" : { + "total" : 1.3579000000000001069366817318950779736042022705078125, + "plates" : 1.3579000000000001069366817318950779736042022705078125, + "vehicles" : 1.3579000000000001069366817318950779736042022705078125 + }, + "regions_of_interest" : [ "" ], + "credits_monthly_total" : "", + "img_width" : "", + "img_height" : "", + "credit_cost" : "", + "data_type" : "aeiou", + "results" : [ { + "candidates" : [ { + "confidence" : 1.3579000000000001069366817318950779736042022705078125, + "plate" : "aeiou", + "matches_template" : "" + } ], + "processing_time_ms" : 1.3579000000000001069366817318950779736042022705078125, + "region_confidence" : 1.3579000000000001069366817318950779736042022705078125, + "requested_topn" : "", + "confidence" : 1.3579000000000001069366817318950779736042022705078125, + "coordinates" : [ { + "x" : "", + "y" : "" + } ], + "plate" : "aeiou", + "matches_template" : "", + "region" : "aeiou", + "vehicle_region" : { + "x" : "", + "width" : "", + "y" : "", + "height" : "" + }, + "vehicle" : { + "color" : [ { + "confidence" : 1.3579000000000001069366817318950779736042022705078125, + "name" : "aeiou" + } ], + "body_type" : [ "" ], + "make" : [ "" ], + "make_model" : [ "" ] + } + } ], + "epoch_time" : 1.3579000000000001069366817318950779736042022705078125, + "version" : "" +}}] + + - parameter image: (form) The image file that you wish to analyze + - parameter secretKey: (query) The secret key used to authenticate your account. You can view your secret key by visiting https://cloud.openalpr.com/ + - parameter country: (query) Defines the training data used by OpenALPR. \"us\" analyzes North-American style plates. \"eu\" analyzes European-style plates. This field is required if using the \"plate\" task You may use multiple datasets by using commas between the country codes. For example, 'au,auwide' would analyze using both the Australian plate styles. A full list of supported country codes can be found here https://github.com/openalpr/openalpr/tree/master/runtime_data/config + - parameter recognizeVehicle: (query) If set to 1, the vehicle will also be recognized in the image This requires an additional credit per request (optional, default to 0) + - parameter state: (query) Corresponds to a US state or EU country code used by OpenALPR pattern recognition. For example, using \"md\" matches US plates against the Maryland plate patterns. Using \"fr\" matches European plates against the French plate patterns. (optional, default to ) + - parameter returnImage: (query) If set to 1, the image you uploaded will be encoded in base64 and sent back along with the response (optional, default to 0) + - parameter topn: (query) The number of results you would like to be returned for plate candidates and vehicle classifications (optional, default to 10) + - parameter prewarp: (query) Prewarp configuration is used to calibrate the analyses for the angle of a particular camera. More information is available here http://doc.openalpr.com/accuracy_improvements.html#calibration (optional, default to ) + + - returns: RequestBuilder + */ + public class func recognizeFileWithRequestBuilder(image image: NSURL, secretKey: String, country: String, recognizeVehicle: Int32? = nil, state: String? = nil, returnImage: Int32? = nil, topn: Int32? = nil, prewarp: String? = nil) -> RequestBuilder { + let path = "/recognize" + let URLString = SwaggerClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [ + "secret_key": secretKey, + "recognize_vehicle": recognizeVehicle?.encodeToJSON(), + "country": country, + "state": state, + "return_image": returnImage?.encodeToJSON(), + "topn": topn?.encodeToJSON(), + "prewarp": prewarp + ] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: falsefalse) + } + + /** + + - parameter imageUrl: (query) A URL to an image that you wish to analyze + - parameter secretKey: (query) The secret key used to authenticate your account. You can view your secret key by visiting https://cloud.openalpr.com/ + - parameter country: (query) Defines the training data used by OpenALPR. \"us\" analyzes North-American style plates. \"eu\" analyzes European-style plates. This field is required if using the \"plate\" task You may use multiple datasets by using commas between the country codes. For example, 'au,auwide' would analyze using both the Australian plate styles. A full list of supported country codes can be found here https://github.com/openalpr/openalpr/tree/master/runtime_data/config + - parameter recognizeVehicle: (query) If set to 1, the vehicle will also be recognized in the image This requires an additional credit per request (optional, default to 0) + - parameter state: (query) Corresponds to a US state or EU country code used by OpenALPR pattern recognition. For example, using \"md\" matches US plates against the Maryland plate patterns. Using \"fr\" matches European plates against the French plate patterns. (optional, default to ) + - parameter returnImage: (query) If set to 1, the image you uploaded will be encoded in base64 and sent back along with the response (optional, default to 0) + - parameter topn: (query) The number of results you would like to be returned for plate candidates and vehicle classifications (optional, default to 10) + - parameter prewarp: (query) Prewarp configuration is used to calibrate the analyses for the angle of a particular camera. More information is available here http://doc.openalpr.com/accuracy_improvements.html#calibration (optional, default to ) + - parameter completion: completion handler to receive the data and the error objects + */ + public class func recognizeUrl(imageUrl imageUrl: String, secretKey: String, country: String, recognizeVehicle: Int32? = nil, state: String? = nil, returnImage: Int32? = nil, topn: Int32? = nil, prewarp: String? = nil, completion: ((data: InlineResponse200?, error: ErrorType?) -> Void)) { + recognizeUrlWithRequestBuilder(imageUrl: imageUrl, secretKey: secretKey, country: country, recognizeVehicle: recognizeVehicle, state: state, returnImage: returnImage, topn: topn, prewarp: prewarp).execute { (response, error) -> Void in + completion(data: response?.body, error: error); + } + } + + + /** + - POST /recognize_url + - Send an image for OpenALPR to analyze and provide metadata back The image is sent as a URL. The OpenALPR service will download the image and process it + - responseHeaders: [X-RateLimit-Limit(Int32), X-Ratelimit-Remaining(Int32), X-Ratelimit-Reset(Int32)] + - responseHeaders: [X-RateLimit-Limit(Int32), X-Ratelimit-Remaining(Int32), X-Ratelimit-Reset(Int32)] + - responseHeaders: [X-RateLimit-Limit(Int32), X-Ratelimit-Remaining(Int32), X-Ratelimit-Reset(Int32)] + - examples: [{contentType=application/json, example={ + "credits_monthly_used" : "", + "processing_time" : { + "total" : 1.3579000000000001069366817318950779736042022705078125, + "plates" : 1.3579000000000001069366817318950779736042022705078125, + "vehicles" : 1.3579000000000001069366817318950779736042022705078125 + }, + "regions_of_interest" : [ "" ], + "credits_monthly_total" : "", + "img_width" : "", + "img_height" : "", + "credit_cost" : "", + "data_type" : "aeiou", + "results" : [ { + "candidates" : [ { + "confidence" : 1.3579000000000001069366817318950779736042022705078125, + "plate" : "aeiou", + "matches_template" : "" + } ], + "processing_time_ms" : 1.3579000000000001069366817318950779736042022705078125, + "region_confidence" : 1.3579000000000001069366817318950779736042022705078125, + "requested_topn" : "", + "confidence" : 1.3579000000000001069366817318950779736042022705078125, + "coordinates" : [ { + "x" : "", + "y" : "" + } ], + "plate" : "aeiou", + "matches_template" : "", + "region" : "aeiou", + "vehicle_region" : { + "x" : "", + "width" : "", + "y" : "", + "height" : "" + }, + "vehicle" : { + "color" : [ { + "confidence" : 1.3579000000000001069366817318950779736042022705078125, + "name" : "aeiou" + } ], + "body_type" : [ "" ], + "make" : [ "" ], + "make_model" : [ "" ] + } + } ], + "epoch_time" : 1.3579000000000001069366817318950779736042022705078125, + "version" : "" +}}] + + - parameter imageUrl: (query) A URL to an image that you wish to analyze + - parameter secretKey: (query) The secret key used to authenticate your account. You can view your secret key by visiting https://cloud.openalpr.com/ + - parameter country: (query) Defines the training data used by OpenALPR. \"us\" analyzes North-American style plates. \"eu\" analyzes European-style plates. This field is required if using the \"plate\" task You may use multiple datasets by using commas between the country codes. For example, 'au,auwide' would analyze using both the Australian plate styles. A full list of supported country codes can be found here https://github.com/openalpr/openalpr/tree/master/runtime_data/config + - parameter recognizeVehicle: (query) If set to 1, the vehicle will also be recognized in the image This requires an additional credit per request (optional, default to 0) + - parameter state: (query) Corresponds to a US state or EU country code used by OpenALPR pattern recognition. For example, using \"md\" matches US plates against the Maryland plate patterns. Using \"fr\" matches European plates against the French plate patterns. (optional, default to ) + - parameter returnImage: (query) If set to 1, the image you uploaded will be encoded in base64 and sent back along with the response (optional, default to 0) + - parameter topn: (query) The number of results you would like to be returned for plate candidates and vehicle classifications (optional, default to 10) + - parameter prewarp: (query) Prewarp configuration is used to calibrate the analyses for the angle of a particular camera. More information is available here http://doc.openalpr.com/accuracy_improvements.html#calibration (optional, default to ) + + - returns: RequestBuilder + */ + public class func recognizeUrlWithRequestBuilder(imageUrl imageUrl: String, secretKey: String, country: String, recognizeVehicle: Int32? = nil, state: String? = nil, returnImage: Int32? = nil, topn: Int32? = nil, prewarp: String? = nil) -> RequestBuilder { + let path = "/recognize_url" + let URLString = SwaggerClientAPI.basePath + path + + let nillableParameters: [String:AnyObject?] = [ + "image_url": imageUrl, + "secret_key": secretKey, + "recognize_vehicle": recognizeVehicle?.encodeToJSON(), + "country": country, + "state": state, + "return_image": returnImage?.encodeToJSON(), + "topn": topn?.encodeToJSON(), + "prewarp": prewarp + ] + + let parameters = APIHelper.rejectNil(nillableParameters) + + let convertedParameters = APIHelper.convertBoolToString(parameters) + + let requestBuilder: RequestBuilder.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder() + + return requestBuilder.init(method: "POST", URLString: URLString, parameters: convertedParameters, isBody: false) + } + +} diff --git a/swift/SwaggerClient/Classes/Swaggers/AlamofireImplementations.swift b/swift/SwaggerClient/Classes/Swaggers/AlamofireImplementations.swift new file mode 100644 index 0000000..cabf675 --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/AlamofireImplementations.swift @@ -0,0 +1,148 @@ +// AlamofireImplementations.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Alamofire + +class AlamofireRequestBuilderFactory: RequestBuilderFactory { + func getBuilder() -> RequestBuilder.Type { + return AlamofireRequestBuilder.self + } +} + +// Store manager to retain its reference +private var managerStore: [String: Alamofire.Manager] = [:] + +class AlamofireRequestBuilder: RequestBuilder { + required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) { + super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody) + } + + override func execute(completion: (response: Response?, error: ErrorType?) -> Void) { + let managerId = NSUUID().UUIDString + // Create a new manager for each request to customize its request header + let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() + configuration.HTTPAdditionalHeaders = buildHeaders() + let manager = Alamofire.Manager(configuration: configuration) + managerStore[managerId] = manager + + let encoding = isBody ? Alamofire.ParameterEncoding.JSON : Alamofire.ParameterEncoding.URL + let xMethod = Alamofire.Method(rawValue: method) + let fileKeys = parameters == nil ? [] : parameters!.filter { $1.isKindOfClass(NSURL) } + .map { $0.0 } + + if fileKeys.count > 0 { + manager.upload( + xMethod!, URLString, headers: nil, + multipartFormData: { mpForm in + for (k, v) in self.parameters! { + switch v { + case let fileURL as NSURL: + mpForm.appendBodyPart(fileURL: fileURL, name: k) + break + case let string as NSString: + mpForm.appendBodyPart(data: string.dataUsingEncoding(NSUTF8StringEncoding)!, name: k) + break + case let number as NSNumber: + mpForm.appendBodyPart(data: number.stringValue.dataUsingEncoding(NSUTF8StringEncoding)!, name: k) + break + default: + fatalError("Unprocessable value \(v) with key \(k)") + break + } + } + }, + encodingMemoryThreshold: Manager.MultipartFormDataEncodingMemoryThreshold, + encodingCompletion: { encodingResult in + switch encodingResult { + case .Success(let uploadRequest, _, _): + if let onProgressReady = self.onProgressReady { + onProgressReady(uploadRequest.progress) + } + self.processRequest(uploadRequest, managerId, completion) + case .Failure(let encodingError): + completion(response: nil, error: encodingError) + } + } + ) + } else { + let request = manager.request(xMethod!, URLString, parameters: parameters, encoding: encoding) + if let onProgressReady = self.onProgressReady { + onProgressReady(request.progress) + } + processRequest(request, managerId, completion) + } + + } + + private func processRequest(request: Request, _ managerId: String, _ completion: (response: Response?, error: ErrorType?) -> Void) { + if let credential = self.credential { + request.authenticate(usingCredential: credential) + } + + let cleanupRequest = { + managerStore.removeValueForKey(managerId) + } + + let validatedRequest = request.validate() + + switch T.self { + case is NSData.Type: + validatedRequest.responseData({ (dataResponse) in + cleanupRequest() + + if (dataResponse.result.isFailure) { + completion( + response: nil, + error: dataResponse.result.error + ) + return + } + + completion( + response: Response( + response: dataResponse.response!, + body: dataResponse.data as! T + ), + error: nil + ) + }) + default: + validatedRequest.responseJSON(options: .AllowFragments) { response in + cleanupRequest() + + if response.result.isFailure { + completion(response: nil, error: response.result.error) + return + } + + if () is T { + completion(response: Response(response: response.response!, body: () as! T), error: nil) + return + } + if let json: AnyObject = response.result.value { + let body = Decoders.decode(clazz: T.self, source: json) + completion(response: Response(response: response.response!, body: body), error: nil) + return + } else if "" is T { + // swagger-parser currently doesn't support void, which will be fixed in future swagger-parser release + // https://github.com/swagger-api/swagger-parser/pull/34 + completion(response: Response(response: response.response!, body: "" as! T), error: nil) + return + } + + completion(response: nil, error: NSError(domain: "localhost", code: 500, userInfo: ["reason": "unreacheable code"])) + } + } + } + + private func buildHeaders() -> [String: AnyObject] { + var httpHeaders = Manager.defaultHTTPHeaders + for (key, value) in self.headers { + httpHeaders[key] = value + } + return httpHeaders + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Extensions.swift b/swift/SwaggerClient/Classes/Swaggers/Extensions.swift new file mode 100644 index 0000000..c974cc4 --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Extensions.swift @@ -0,0 +1,86 @@ +// Extensions.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Alamofire + +extension Bool: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +extension Float: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +extension Int: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +extension Int32: JSONEncodable { + func encodeToJSON() -> AnyObject { return NSNumber(int: self) } +} + +extension Int64: JSONEncodable { + func encodeToJSON() -> AnyObject { return NSNumber(longLong: self) } +} + +extension Double: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +extension String: JSONEncodable { + func encodeToJSON() -> AnyObject { return self } +} + +private func encodeIfPossible(object: T) -> AnyObject { + if object is JSONEncodable { + return (object as! JSONEncodable).encodeToJSON() + } else { + return object as! AnyObject + } +} + +extension Array: JSONEncodable { + func encodeToJSON() -> AnyObject { + return self.map(encodeIfPossible) + } +} + +extension Dictionary: JSONEncodable { + func encodeToJSON() -> AnyObject { + var dictionary = [NSObject:AnyObject]() + for (key, value) in self { + dictionary[key as! NSObject] = encodeIfPossible(value) + } + return dictionary + } +} + +extension NSData: JSONEncodable { + func encodeToJSON() -> AnyObject { + return self.base64EncodedStringWithOptions(NSDataBase64EncodingOptions()) + } +} + +private let dateFormatter: NSDateFormatter = { + let fmt = NSDateFormatter() + fmt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + fmt.locale = NSLocale(localeIdentifier: "en_US_POSIX") + return fmt +}() + +extension NSDate: JSONEncodable { + func encodeToJSON() -> AnyObject { + return dateFormatter.stringFromDate(self) + } +} + +extension NSUUID: JSONEncodable { + func encodeToJSON() -> AnyObject { + return self.UUIDString + } +} + + diff --git a/swift/SwaggerClient/Classes/Swaggers/Models.swift b/swift/SwaggerClient/Classes/Swaggers/Models.swift new file mode 100644 index 0000000..ce9eb2c --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models.swift @@ -0,0 +1,289 @@ +// Models.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + +protocol JSONEncodable { + func encodeToJSON() -> AnyObject +} + +public class Response { + public let statusCode: Int + public let header: [String: String] + public let body: T + + public init(statusCode: Int, header: [String: String], body: T) { + self.statusCode = statusCode + self.header = header + self.body = body + } + + public convenience init(response: NSHTTPURLResponse, body: T) { + let rawHeader = response.allHeaderFields + var header = [String:String]() + for (key, value) in rawHeader { + header[key as! String] = value as? String + } + self.init(statusCode: response.statusCode, header: header, body: body) + } +} + +private var once = dispatch_once_t() +class Decoders { + static private var decoders = Dictionary AnyObject)>() + + static func addDecoder(clazz clazz: T.Type, decoder: ((AnyObject) -> T)) { + let key = "\(T.self)" + decoders[key] = { decoder($0) as! AnyObject } + } + + static func decode(clazz clazz: [T].Type, source: AnyObject) -> [T] { + let array = source as! [AnyObject] + return array.map { Decoders.decode(clazz: T.self, source: $0) } + } + + static func decode(clazz clazz: [Key:T].Type, source: AnyObject) -> [Key:T] { + let sourceDictionary = source as! [Key: AnyObject] + var dictionary = [Key:T]() + for (key, value) in sourceDictionary { + dictionary[key] = Decoders.decode(clazz: T.self, source: value) + } + return dictionary + } + + static func decode(clazz clazz: T.Type, source: AnyObject) -> T { + initialize() + if T.self is Int32.Type && source is NSNumber { + return source.intValue as! T; + } + if T.self is Int64.Type && source is NSNumber { + return source.longLongValue as! T; + } + if T.self is NSUUID.Type && source is String { + return NSUUID(UUIDString: source as! String) as! T + } + if source is T { + return source as! T + } + if T.self is NSData.Type && source is String { + return NSData(base64EncodedString: source as! String, options: NSDataBase64DecodingOptions()) as! T + } + + let key = "\(T.self)" + if let decoder = decoders[key] { + return decoder(source) as! T + } else { + fatalError("Source \(source) is not convertible to type \(clazz): Maybe swagger file is insufficient") + } + } + + static func decodeOptional(clazz clazz: T.Type, source: AnyObject?) -> T? { + if source is NSNull { + return nil + } + return source.map { (source: AnyObject) -> T in + Decoders.decode(clazz: clazz, source: source) + } + } + + static func decodeOptional(clazz clazz: [T].Type, source: AnyObject?) -> [T]? { + if source is NSNull { + return nil + } + return source.map { (someSource: AnyObject) -> [T] in + Decoders.decode(clazz: clazz, source: someSource) + } + } + + static func decodeOptional(clazz clazz: [Key:T].Type, source: AnyObject?) -> [Key:T]? { + if source is NSNull { + return nil + } + return source.map { (someSource: AnyObject) -> [Key:T] in + Decoders.decode(clazz: clazz, source: someSource) + } + } + + static private func initialize() { + dispatch_once(&once) { + let formatters = [ + "yyyy-MM-dd", + "yyyy-MM-dd'T'HH:mm:ssZZZZZ", + "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ", + "yyyy-MM-dd'T'HH:mm:ss'Z'", + "yyyy-MM-dd'T'HH:mm:ss.SSS" + ].map { (format: String) -> NSDateFormatter in + let formatter = NSDateFormatter() + formatter.dateFormat = format + return formatter + } + // Decoder for NSDate + Decoders.addDecoder(clazz: NSDate.self) { (source: AnyObject) -> NSDate in + if let sourceString = source as? String { + for formatter in formatters { + if let date = formatter.dateFromString(sourceString) { + return date + } + } + + } + if let sourceInt = source as? Int { + // treat as a java date + return NSDate(timeIntervalSince1970: Double(sourceInt / 1000) ) + } + fatalError("formatter failed to parse \(source)") + } + + // Decoder for [Coordinate] + Decoders.addDecoder(clazz: [Coordinate].self) { (source: AnyObject) -> [Coordinate] in + return Decoders.decode(clazz: [Coordinate].self, source: source) + } + // Decoder for Coordinate + Decoders.addDecoder(clazz: Coordinate.self) { (source: AnyObject) -> Coordinate in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = Coordinate() + instance.x = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["x"]) + instance.y = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["y"]) + return instance + } + + + // Decoder for [InlineResponse200] + Decoders.addDecoder(clazz: [InlineResponse200].self) { (source: AnyObject) -> [InlineResponse200] in + return Decoders.decode(clazz: [InlineResponse200].self, source: source) + } + // Decoder for InlineResponse200 + Decoders.addDecoder(clazz: InlineResponse200.self) { (source: AnyObject) -> InlineResponse200 in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = InlineResponse200() + instance.processingTime = Decoders.decodeOptional(clazz: InlineResponse200ProcessingTime.self, source: sourceDictionary["processing_time"]) + instance.imgWidth = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["img_width"]) + instance.imgHeight = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["img_height"]) + instance.creditCost = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["credit_cost"]) + instance.creditsMonthlyUsed = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["credits_monthly_used"]) + instance.creditsMonthlyTotal = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["credits_monthly_total"]) + instance.results = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["results"]) + instance.regionsOfInterest = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["regions_of_interest"]) + instance.epochTime = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["epoch_time"]) + instance.version = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["version"]) + instance.dataType = InlineResponse200.DataType(rawValue: (sourceDictionary["data_type"] as? String) ?? "") + return instance + } + + + // Decoder for [InlineResponse200ProcessingTime] + Decoders.addDecoder(clazz: [InlineResponse200ProcessingTime].self) { (source: AnyObject) -> [InlineResponse200ProcessingTime] in + return Decoders.decode(clazz: [InlineResponse200ProcessingTime].self, source: source) + } + // Decoder for InlineResponse200ProcessingTime + Decoders.addDecoder(clazz: InlineResponse200ProcessingTime.self) { (source: AnyObject) -> InlineResponse200ProcessingTime in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = InlineResponse200ProcessingTime() + instance.total = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["total"]) + instance.plates = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["plates"]) + instance.vehicles = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["vehicles"]) + return instance + } + + + // Decoder for [InlineResponse400] + Decoders.addDecoder(clazz: [InlineResponse400].self) { (source: AnyObject) -> [InlineResponse400] in + return Decoders.decode(clazz: [InlineResponse400].self, source: source) + } + // Decoder for InlineResponse400 + Decoders.addDecoder(clazz: InlineResponse400.self) { (source: AnyObject) -> InlineResponse400 in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = InlineResponse400() + instance.error = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["error"]) + return instance + } + + + // Decoder for [PlateCandidate] + Decoders.addDecoder(clazz: [PlateCandidate].self) { (source: AnyObject) -> [PlateCandidate] in + return Decoders.decode(clazz: [PlateCandidate].self, source: source) + } + // Decoder for PlateCandidate + Decoders.addDecoder(clazz: PlateCandidate.self) { (source: AnyObject) -> PlateCandidate in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = PlateCandidate() + instance.plate = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["plate"]) + instance.confidence = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["confidence"]) + instance.matchesTemplate = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["matches_template"]) + return instance + } + + + // Decoder for [PlateDetails] + Decoders.addDecoder(clazz: [PlateDetails].self) { (source: AnyObject) -> [PlateDetails] in + return Decoders.decode(clazz: [PlateDetails].self, source: source) + } + // Decoder for PlateDetails + Decoders.addDecoder(clazz: PlateDetails.self) { (source: AnyObject) -> PlateDetails in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = PlateDetails() + instance.plate = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["plate"]) + instance.matchesTemplate = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["matches_template"]) + instance.requestedTopn = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["requested_topn"]) + instance.processingTimeMs = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["processing_time_ms"]) + instance.confidence = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["confidence"]) + instance.region = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["region"]) + instance.regionConfidence = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["region_confidence"]) + instance.coordinates = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["coordinates"]) + instance.candidates = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["candidates"]) + instance.vehicleRegion = Decoders.decodeOptional(clazz: RegionOfInterest.self, source: sourceDictionary["vehicle_region"]) + instance.vehicle = Decoders.decodeOptional(clazz: VehicleDetails.self, source: sourceDictionary["vehicle"]) + return instance + } + + + // Decoder for [RegionOfInterest] + Decoders.addDecoder(clazz: [RegionOfInterest].self) { (source: AnyObject) -> [RegionOfInterest] in + return Decoders.decode(clazz: [RegionOfInterest].self, source: source) + } + // Decoder for RegionOfInterest + Decoders.addDecoder(clazz: RegionOfInterest.self) { (source: AnyObject) -> RegionOfInterest in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = RegionOfInterest() + instance.x = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["x"]) + instance.y = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["y"]) + instance.width = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["width"]) + instance.height = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["height"]) + return instance + } + + + // Decoder for [VehicleCandidate] + Decoders.addDecoder(clazz: [VehicleCandidate].self) { (source: AnyObject) -> [VehicleCandidate] in + return Decoders.decode(clazz: [VehicleCandidate].self, source: source) + } + // Decoder for VehicleCandidate + Decoders.addDecoder(clazz: VehicleCandidate.self) { (source: AnyObject) -> VehicleCandidate in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = VehicleCandidate() + instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) + instance.confidence = Decoders.decodeOptional(clazz: Double.self, source: sourceDictionary["confidence"]) + return instance + } + + + // Decoder for [VehicleDetails] + Decoders.addDecoder(clazz: [VehicleDetails].self) { (source: AnyObject) -> [VehicleDetails] in + return Decoders.decode(clazz: [VehicleDetails].self, source: source) + } + // Decoder for VehicleDetails + Decoders.addDecoder(clazz: VehicleDetails.self) { (source: AnyObject) -> VehicleDetails in + let sourceDictionary = source as! [NSObject:AnyObject] + let instance = VehicleDetails() + instance.color = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["color"]) + instance.make = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["make"]) + instance.makeModel = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["make_model"]) + instance.bodyType = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["body_type"]) + return instance + } + } + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Models/Coordinate.swift b/swift/SwaggerClient/Classes/Swaggers/Models/Coordinate.swift new file mode 100644 index 0000000..51650a8 --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models/Coordinate.swift @@ -0,0 +1,25 @@ +// +// Coordinate.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class Coordinate: JSONEncodable { + public var x: Int32? + public var y: Int32? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["x"] = self.x?.encodeToJSON() + nillableDictionary["y"] = self.y?.encodeToJSON() + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Models/InlineResponse200.swift b/swift/SwaggerClient/Classes/Swaggers/Models/InlineResponse200.swift new file mode 100644 index 0000000..1685cbc --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models/InlineResponse200.swift @@ -0,0 +1,57 @@ +// +// InlineResponse200.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class InlineResponse200: JSONEncodable { + public enum DataType: String { + case AlprResults = "alpr_results" + case AlprGroup = "alpr_group" + case Heartbeat = "heartbeat" + } + public var processingTime: InlineResponse200ProcessingTime? + /** Width of the uploaded image in pixels */ + public var imgWidth: Int32? + /** Height of the input image in pixels */ + public var imgHeight: Int32? + /** The number of API credits that were used to process this image */ + public var creditCost: Int32? + /** The number of API credits used this month */ + public var creditsMonthlyUsed: Int32? + /** The maximum number of API credits available this month according to your plan */ + public var creditsMonthlyTotal: Int32? + public var results: [PlateDetails]? + /** Describes the areas analyzed in the input image */ + public var regionsOfInterest: [RegionOfInterest]? + /** Epoch time that the image was processed in milliseconds */ + public var epochTime: Double? + /** API format version */ + public var version: Int32? + /** Specifies the type of data in this response */ + public var dataType: DataType? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["processing_time"] = self.processingTime?.encodeToJSON() + nillableDictionary["img_width"] = self.imgWidth?.encodeToJSON() + nillableDictionary["img_height"] = self.imgHeight?.encodeToJSON() + nillableDictionary["credit_cost"] = self.creditCost?.encodeToJSON() + nillableDictionary["credits_monthly_used"] = self.creditsMonthlyUsed?.encodeToJSON() + nillableDictionary["credits_monthly_total"] = self.creditsMonthlyTotal?.encodeToJSON() + nillableDictionary["results"] = self.results?.encodeToJSON() + nillableDictionary["regions_of_interest"] = self.regionsOfInterest?.encodeToJSON() + nillableDictionary["epoch_time"] = self.epochTime + nillableDictionary["version"] = self.version?.encodeToJSON() + nillableDictionary["data_type"] = self.dataType?.rawValue + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Models/InlineResponse200ProcessingTime.swift b/swift/SwaggerClient/Classes/Swaggers/Models/InlineResponse200ProcessingTime.swift new file mode 100644 index 0000000..2ba620e --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models/InlineResponse200ProcessingTime.swift @@ -0,0 +1,30 @@ +// +// InlineResponse200ProcessingTime.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class InlineResponse200ProcessingTime: JSONEncodable { + /** Time spent processing all tasks (in milliseconds) */ + public var total: Double? + /** Time spent performing license plate recognition (in milliseconds) */ + public var plates: Double? + /** Time spent performing vehicle recognition (in milliseconds) */ + public var vehicles: Double? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["total"] = self.total + nillableDictionary["plates"] = self.plates + nillableDictionary["vehicles"] = self.vehicles + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Models/InlineResponse400.swift b/swift/SwaggerClient/Classes/Swaggers/Models/InlineResponse400.swift new file mode 100644 index 0000000..2ea953a --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models/InlineResponse400.swift @@ -0,0 +1,24 @@ +// +// InlineResponse400.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class InlineResponse400: JSONEncodable { + /** Text error message describing the invalid input */ + public var error: String? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["error"] = self.error + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Models/PlateCandidate.swift b/swift/SwaggerClient/Classes/Swaggers/Models/PlateCandidate.swift new file mode 100644 index 0000000..f764134 --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models/PlateCandidate.swift @@ -0,0 +1,30 @@ +// +// PlateCandidate.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class PlateCandidate: JSONEncodable { + /** Plate number */ + public var plate: String? + /** Confidence percentage that the plate number is correct */ + public var confidence: Double? + /** Indicates whether the plate matched a regional text pattern */ + public var matchesTemplate: Int32? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["plate"] = self.plate + nillableDictionary["confidence"] = self.confidence + nillableDictionary["matches_template"] = self.matchesTemplate?.encodeToJSON() + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Models/PlateDetails.swift b/swift/SwaggerClient/Classes/Swaggers/Models/PlateDetails.swift new file mode 100644 index 0000000..0915ceb --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models/PlateDetails.swift @@ -0,0 +1,52 @@ +// +// PlateDetails.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class PlateDetails: JSONEncodable { + /** Best plate number for this plate */ + public var plate: String? + /** Indicates whether the plate matched a regional text pattern */ + public var matchesTemplate: Int32? + /** The max number of results requested */ + public var requestedTopn: Int32? + /** Number of milliseconds to process the license plate */ + public var processingTimeMs: Double? + /** Confidence percentage that the plate number is correct */ + public var confidence: Double? + /** Specified or detected region (e.g., tx for Texas) */ + public var region: String? + /** Confidence percentage that the plate region is correct */ + public var regionConfidence: Double? + /** The X/Y coordinates of the license plate in the image Four coordinates are provided that form a polygon starting from the top-left and moving clockwise ending in the bottom left */ + public var coordinates: [Coordinate]? + /** All the top N candidates that could be the correct plate number */ + public var candidates: [PlateCandidate]? + public var vehicleRegion: RegionOfInterest? + public var vehicle: VehicleDetails? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["plate"] = self.plate + nillableDictionary["matches_template"] = self.matchesTemplate?.encodeToJSON() + nillableDictionary["requested_topn"] = self.requestedTopn?.encodeToJSON() + nillableDictionary["processing_time_ms"] = self.processingTimeMs + nillableDictionary["confidence"] = self.confidence + nillableDictionary["region"] = self.region + nillableDictionary["region_confidence"] = self.regionConfidence + nillableDictionary["coordinates"] = self.coordinates?.encodeToJSON() + nillableDictionary["candidates"] = self.candidates?.encodeToJSON() + nillableDictionary["vehicle_region"] = self.vehicleRegion?.encodeToJSON() + nillableDictionary["vehicle"] = self.vehicle?.encodeToJSON() + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Models/RegionOfInterest.swift b/swift/SwaggerClient/Classes/Swaggers/Models/RegionOfInterest.swift new file mode 100644 index 0000000..7c83aae --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models/RegionOfInterest.swift @@ -0,0 +1,29 @@ +// +// RegionOfInterest.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class RegionOfInterest: JSONEncodable { + public var x: Int32? + public var y: Int32? + public var width: Int32? + public var height: Int32? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["x"] = self.x?.encodeToJSON() + nillableDictionary["y"] = self.y?.encodeToJSON() + nillableDictionary["width"] = self.width?.encodeToJSON() + nillableDictionary["height"] = self.height?.encodeToJSON() + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Models/VehicleCandidate.swift b/swift/SwaggerClient/Classes/Swaggers/Models/VehicleCandidate.swift new file mode 100644 index 0000000..410829d --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models/VehicleCandidate.swift @@ -0,0 +1,27 @@ +// +// VehicleCandidate.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class VehicleCandidate: JSONEncodable { + /** name of value */ + public var name: String? + /** confidence of value (percent) */ + public var confidence: Double? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["name"] = self.name + nillableDictionary["confidence"] = self.confidence + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +} diff --git a/swift/SwaggerClient/Classes/Swaggers/Models/VehicleDetails.swift b/swift/SwaggerClient/Classes/Swaggers/Models/VehicleDetails.swift new file mode 100644 index 0000000..1eaba76 --- /dev/null +++ b/swift/SwaggerClient/Classes/Swaggers/Models/VehicleDetails.swift @@ -0,0 +1,29 @@ +// +// VehicleDetails.swift +// +// Generated by swagger-codegen +// https://github.com/swagger-api/swagger-codegen +// + +import Foundation + + +public class VehicleDetails: JSONEncodable { + public var color: [VehicleCandidate]? + public var make: [VehicleCandidate]? + public var makeModel: [VehicleCandidate]? + public var bodyType: [VehicleCandidate]? + + public init() {} + + // MARK: JSONEncodable + func encodeToJSON() -> AnyObject { + var nillableDictionary = [String:AnyObject?]() + nillableDictionary["color"] = self.color?.encodeToJSON() + nillableDictionary["make"] = self.make?.encodeToJSON() + nillableDictionary["make_model"] = self.makeModel?.encodeToJSON() + nillableDictionary["body_type"] = self.bodyType?.encodeToJSON() + let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] + return dictionary + } +}