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

import Foundation
import Get
import URLQueryEncoder

extension Paths.V2.External.Oauth.Alexa {
    public var songCreated: SongCreated {
        SongCreated(path: path + "/song-created")
    }

    public struct SongCreated {
        /// Path: `/api/v2/external/oauth/alexa/song-created`
        public let path: String

        /// Alexa Song Created
        ///
        /// Handles notification of a newly created song that needs to be added to the Alexa catalog.
        /// 
        /// This endpoint is called by the Lambda function after a song is successfully created
        /// to update the user's Alexa music catalog with the new song.
        /// 
        /// If no AlexaUserInfo record exists, it will create one if alexa_user_id is provided.
        public func post(parameters: PostParameters) -> Request<[String: AnyJSON]> {
            Request(path: path, method: "POST", query: parameters.asQuery, id: "studio_api_bots_external_api_alexa_song_created")
        }

        public struct PostParameters {
            public var clipId: String
            public var title: String?
            public var alexaUserId: String?
            public var alexaApiEndpoint: String?

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

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