// --------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// --------------------------------------------------------------------------

import AzureCore
import Foundation
// swiftlint:disable superfluous_disable_command
// swiftlint:disable identifier_name
// swiftlint:disable line_length
// swiftlint:disable cyclomatic_complexity

/// An item returned from Search Address Batch service call.
public struct SearchAddressBatchItem: Codable {
    // MARK: Properties

    /// The result of the query. SearchAddressResponse if the query completed successfully, ErrorResponse otherwise.
    public let response: SearchAddressBatchItemResponse?
    /// HTTP request status code.
    public let statusCode: Float?

    // MARK: Initializers

    /// Initialize a `SearchAddressBatchItem` structure.
    /// - Parameters:
    ///   - response: The result of the query. SearchAddressResponse if the query completed successfully, ErrorResponse otherwise.
    ///   - statusCode: HTTP request status code.
    public init(
        response: SearchAddressBatchItemResponse? = nil, statusCode: Float? = nil
    ) {
        self.response = response
        self.statusCode = statusCode
    }

    // MARK: Codable

    enum CodingKeys: String, CodingKey {
        case response = "response"
        case statusCode = "statusCode"
    }

    /// Initialize a `SearchAddressBatchItem` structure from decoder
    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        self.response = try? container.decode(SearchAddressBatchItemResponse.self, forKey: .response)
        self.statusCode = try? container.decode(Float.self, forKey: .statusCode)
    }

    /// Encode a `SearchAddressBatchItem` structure
    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        if response != nil { try? container.encode(response, forKey: .response) }
        if statusCode != nil { try? container.encode(statusCode, forKey: .statusCode) }
    }
}
