// Generated by Create API
// https://github.com/CreateAPI/CreateAPI

import Foundation
import Get
import URLQueryEncoder

extension Paths.V2.External.Oauth.Alexa {
    public var skillAccountLinked: SkillAccountLinked {
        SkillAccountLinked(path: path + "/skill-account-linked")
    }

    public struct SkillAccountLinked {
        /// Path: `/api/v2/external/oauth/alexa/skill-account-linked`
        public let path: String

        /// Alexa Skill Account Linked
        ///
        /// Handles the Alexa skill account linking event and self-healing requests.
        /// 
        /// This endpoint is called by the Alexa skill Lambda function when:
        /// 1. A user links their Suno account to their Alexa account
        /// 2. Alexa performs self-healing to ensure catalogs are synchronized
        /// 
        /// If previous_sync_token is provided, this is a self-healing request.
        public func post(parameters: PostParameters) -> Request<[String: AnyJSON]> {
            Request(path: path, method: "POST", query: parameters.asQuery, id: "studio_api_bots_external_api_alexa_skill_account_linked")
        }

        public struct PostParameters {
            public var alexaUserId: String
            public var alexaApiEndpoint: String?
            public var previousSyncToken: String?

            public init(alexaUserId: String, alexaApiEndpoint: String? = nil, previousSyncToken: String? = nil) {
                self.alexaUserId = alexaUserId
                self.alexaApiEndpoint = alexaApiEndpoint
                self.previousSyncToken = previousSyncToken
            }

            public var asQuery: [(String, String?)] {
                let encoder = URLQueryEncoder()
                encoder.encode(alexaUserId, forKey: "alexa_user_id")
                encoder.encode(alexaApiEndpoint, forKey: "alexa_api_endpoint")
                encoder.encode(previousSyncToken, forKey: "previous_sync_token")
                return encoder.items
            }
        }
    }
}
