|
| 1 | +package com.slack.api.model.kotlin_extension.block |
| 2 | + |
| 3 | +import com.slack.api.model.block.AuthProviderBlock |
| 4 | +import com.slack.api.model.block.LayoutBlock |
| 5 | +import com.slack.api.model.block.composition.PlainTextObject |
| 6 | +import com.slack.api.model.block.element.OverflowMenuElement |
| 7 | +import com.slack.api.model.kotlin_extension.block.container.MultiLayoutBlockContainer |
| 8 | +import com.slack.api.model.kotlin_extension.block.element.OverflowMenuElementBuilder |
| 9 | + |
| 10 | +@BlockLayoutBuilder |
| 11 | +class AuthProviderBlockBuilder : Builder<AuthProviderBlock> { |
| 12 | + private var blockId: String? = null |
| 13 | + private var value: String? = null |
| 14 | + private var name: PlainTextObject? = null |
| 15 | + private var isConnected: Boolean? = null |
| 16 | + private var description: PlainTextObject? = null |
| 17 | + private var iconUrl: String? = null |
| 18 | + private var authUrl: String? = null |
| 19 | + private var disconnectUrl: String? = null |
| 20 | + private var connectedIdentity: PlainTextObject? = null |
| 21 | + private var connectedContext: PlainTextObject? = null |
| 22 | + private var accessory: OverflowMenuElement? = null |
| 23 | + private var fallback: List<LayoutBlock>? = null |
| 24 | + |
| 25 | + fun blockId(id: String) { |
| 26 | + blockId = id |
| 27 | + } |
| 28 | + |
| 29 | + fun value(value: String) { |
| 30 | + this.value = value |
| 31 | + } |
| 32 | + |
| 33 | + fun name(text: String, emoji: Boolean? = null) { |
| 34 | + name = PlainTextObject(text, emoji) |
| 35 | + } |
| 36 | + |
| 37 | + fun name(textObject: PlainTextObject) { |
| 38 | + name = textObject |
| 39 | + } |
| 40 | + |
| 41 | + fun isConnected(connected: Boolean) { |
| 42 | + isConnected = connected |
| 43 | + } |
| 44 | + |
| 45 | + fun description(text: String, emoji: Boolean? = null) { |
| 46 | + description = PlainTextObject(text, emoji) |
| 47 | + } |
| 48 | + |
| 49 | + fun description(textObject: PlainTextObject) { |
| 50 | + description = textObject |
| 51 | + } |
| 52 | + |
| 53 | + fun iconUrl(url: String) { |
| 54 | + iconUrl = url |
| 55 | + } |
| 56 | + |
| 57 | + fun authUrl(url: String) { |
| 58 | + authUrl = url |
| 59 | + } |
| 60 | + |
| 61 | + fun disconnectUrl(url: String) { |
| 62 | + disconnectUrl = url |
| 63 | + } |
| 64 | + |
| 65 | + fun connectedIdentity(text: String, emoji: Boolean? = null) { |
| 66 | + connectedIdentity = PlainTextObject(text, emoji) |
| 67 | + } |
| 68 | + |
| 69 | + fun connectedIdentity(textObject: PlainTextObject) { |
| 70 | + connectedIdentity = textObject |
| 71 | + } |
| 72 | + |
| 73 | + fun connectedContext(text: String, emoji: Boolean? = null) { |
| 74 | + connectedContext = PlainTextObject(text, emoji) |
| 75 | + } |
| 76 | + |
| 77 | + fun connectedContext(textObject: PlainTextObject) { |
| 78 | + connectedContext = textObject |
| 79 | + } |
| 80 | + |
| 81 | + fun accessory(builder: OverflowMenuElementBuilder.() -> Unit) { |
| 82 | + accessory = OverflowMenuElementBuilder().apply(builder).build() |
| 83 | + } |
| 84 | + |
| 85 | + fun fallback(builder: MultiLayoutBlockContainer.() -> Unit) { |
| 86 | + fallback = MultiLayoutBlockContainer().apply(builder).underlying |
| 87 | + } |
| 88 | + |
| 89 | + override fun build(): AuthProviderBlock { |
| 90 | + return AuthProviderBlock.builder() |
| 91 | + .blockId(blockId) |
| 92 | + .value(value) |
| 93 | + .name(name) |
| 94 | + .isConnected(isConnected) |
| 95 | + .description(description) |
| 96 | + .iconUrl(iconUrl) |
| 97 | + .authUrl(authUrl) |
| 98 | + .disconnectUrl(disconnectUrl) |
| 99 | + .connectedIdentity(connectedIdentity) |
| 100 | + .connectedContext(connectedContext) |
| 101 | + .accessory(accessory) |
| 102 | + .fallback(fallback) |
| 103 | + .build() |
| 104 | + } |
| 105 | +} |
0 commit comments