//
// Generated by SwagGen
// https://github.com/yonaskolb/SwagGen
//

import Foundation

extension TVDB.Updates {

    /** Returns an array of valid query keys for the `/updated/query/params` route. */
    public enum GetUpdatedQueryParams {

        public static let service = APIService<Response>(id: "getUpdatedQueryParams", tag: "Updates", method: "GET", path: "/updated/query/params", hasBody: false, securityRequirement: SecurityRequirement(type: "jwtToken", scopes: []))

        public final class Request: APIRequest<Response> {

            public init() {
                super.init(service: GetUpdatedQueryParams.service)
            }
        }

        public enum Response: APIResponseValue, CustomStringConvertible, CustomDebugStringConvertible {
            public typealias SuccessType = TVDBUpdateDataQueryParams

            /** An array of Update objects that match the given timeframe. */
            case status200(TVDBUpdateDataQueryParams)

            /** Returned if your JWT token is missing or expired */
            case status401(TVDBNotAuthorized)

            /** Returned if no records exist for the given timespan */
            case status404(TVDBNotFound)

            public var success: TVDBUpdateDataQueryParams? {
                switch self {
                case .status200(let response): return response
                default: return nil
                }
            }

            public var response: Any {
                switch self {
                case .status200(let response): return response
                case .status401(let response): return response
                case .status404(let response): return response
                }
            }

            public var statusCode: Int {
                switch self {
                case .status200: return 200
                case .status401: return 401
                case .status404: return 404
                }
            }

            public var successful: Bool {
                switch self {
                case .status200: return true
                case .status401: return false
                case .status404: return false
                }
            }

            public init(statusCode: Int, data: Data, decoder: ResponseDecoder) throws {
                switch statusCode {
                case 200: self = try .status200(decoder.decode(TVDBUpdateDataQueryParams.self, from: data))
                case 401: self = try .status401(decoder.decode(TVDBNotAuthorized.self, from: data))
                case 404: self = try .status404(decoder.decode(TVDBNotFound.self, from: data))
                default: throw APIClientError.unexpectedStatusCode(statusCode: statusCode, data: data)
                }
            }

            public var description: String {
                return "\(statusCode) \(successful ? "success" : "failure")"
            }

            public var debugDescription: String {
                var string = description
                let responseString = "\(response)"
                if responseString != "()" {
                    string += "\n\(responseString)"
                }
                return string
            }
        }
    }
}
