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

import Foundation

extension API.Users {

    /**  (Auth policies: UserLoginMatchingRequired) */
    public enum UsrSendActivationCode {

        public static let service = APIService<Response>(id: "UsrSendActivationCode", tag: "Users", method: "POST", path: "/mfa/user/{tntAlias}/{usrAlias}/send-activation-code", hasBody: true, securityRequirements: [SecurityRequirement(type: "Bearer", scopes: [])])

        public final class Request: APIRequest<Response> {

            public struct Options {

                public var tntAlias: String

                public var usrAlias: String

                public init(tntAlias: String, usrAlias: String) {
                    self.tntAlias = tntAlias
                    self.usrAlias = usrAlias
                }
            }

            public var options: Options

            public var body: SendActivationCodeRequestEntity?

            public init(body: SendActivationCodeRequestEntity?, options: Options, encoder: RequestEncoder? = nil) {
                self.body = body
                self.options = options
                super.init(service: UsrSendActivationCode.service) { defaultEncoder in
                    return try (encoder ?? defaultEncoder).encode(body)
                }
            }

            /// convenience initialiser so an Option doesn't have to be created
            public convenience init(tntAlias: String, usrAlias: String, body: SendActivationCodeRequestEntity? = nil) {
                let options = Options(tntAlias: tntAlias, usrAlias: usrAlias)
                self.init(body: body, options: options)
            }

            public override var path: String {
                return super.path.replacingOccurrences(of: "{" + "tntAlias" + "}", with: "\(self.options.tntAlias)").replacingOccurrences(of: "{" + "usrAlias" + "}", with: "\(self.options.usrAlias)")
            }
        }

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

            /** Success */
            case status200(BoolResponseSendActivationCodeErrorsApiResponseEntity)

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

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

            public var statusCode: Int {
                switch self {
                case .status200: return 200
                }
            }

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

            public init(statusCode: Int, data: Data, decoder: ResponseDecoder) throws {
                switch statusCode {
                case 200: self = try .status200(decoder.decode(BoolResponseSendActivationCodeErrorsApiResponseEntity.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
            }
        }
    }
}
