// --------------------------------------------------------------------------
// 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

/// A location represented as a latitude and longitude.
public struct LatLongPair: Codable, Swift.Error {
    // MARK: Properties

    /// Latitude property
    public let latitude: Double?
    /// Longitude property
    public let longitude: Double?

    // MARK: Initializers

    /// Initialize a `LatLongPair` structure.
    /// - Parameters:
    ///   - latitude: Latitude property
    ///   - longitude: Longitude property
    public init(
        latitude: Double? = nil, longitude: Double? = nil
    ) {
        self.latitude = latitude
        self.longitude = longitude
    }

    // MARK: Codable

    enum CodingKeys: String, CodingKey {
        case latitude = "latitude"
        case longitude = "longitude"
    }

    /// Initialize a `LatLongPair` structure from decoder
    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        self.latitude = try? container.decode(Double.self, forKey: .latitude)
        self.longitude = try? container.decode(Double.self, forKey: .longitude)
    }

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