// Telegrammer - Telegram Bot Swift SDK.
// This file is autogenerated by API/generate_wrappers.rb script.

public extension Bot {

    /// Parameters container struct for `setChatAdministratorCustomTitle` method
    struct SetChatAdministratorCustomTitleParams: JSONEncodable {

        /// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
        var chatId: ChatId

        /// Unique identifier of the target user
        var userId: Int64

        /// New custom title for the administrator; 0-16 characters, emoji are not allowed
        var customTitle: String

        /// Custom keys for coding/decoding `SetChatAdministratorCustomTitleParams` struct
        enum CodingKeys: String, CodingKey {
            case chatId = "chat_id"
            case userId = "user_id"
            case customTitle = "custom_title"
        }

        public init(chatId: ChatId, userId: Int64, customTitle: String) {
            self.chatId = chatId
            self.userId = userId
            self.customTitle = customTitle
        }
    }

    /**
     Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.

     SeeAlso Telegram Bot API Reference:
     [SetChatAdministratorCustomTitleParams](https://core.telegram.org/bots/api#setchatadministratorcustomtitle)
     
     - Parameters:
         - params: Parameters container, see `SetChatAdministratorCustomTitleParams` struct
     - Throws: Throws on errors
     - Returns: Future of `Bool` type
     */
    @discardableResult
    func setChatAdministratorCustomTitle(params: SetChatAdministratorCustomTitleParams) throws -> Future<Bool> {
        let body = try httpBody(for: params)
        let headers = httpHeaders(for: params)
        return try client
            .request(endpoint: "setChatAdministratorCustomTitle", body: body, headers: headers)
            .flatMapThrowing { (container) -> Bool in
                return try self.processContainer(container)
        }
    }
}
