-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add support for message attachments
- Loading branch information
1 parent
c0c60d8
commit 9d9ebd9
Showing
39 changed files
with
289 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const { Bit } = require('./base'); | ||
const { SlackDto } = require('../utility/lib'); | ||
const { BuilderHelper } = require('../utility/helpers'); | ||
const { props } = require('../utility/constants'); | ||
|
||
class AttachmentDto extends SlackDto { | ||
constructor(params) { | ||
super(); | ||
|
||
this.color = params.color; | ||
this.blocks = params.blocks; | ||
|
||
this.pruneAndFreeze(); | ||
} | ||
} | ||
|
||
class Attachment extends Bit { | ||
constructor(params = {}) { | ||
super(); | ||
|
||
this.props.color = params.color; | ||
|
||
this.finalizeConstruction(); | ||
} | ||
|
||
/** | ||
* Sets the color of the border to the left of the block quote for the Attachment | ||
* | ||
* {@link https://api.slack.com/reference/messaging/attachments|View in Slack API Documentation} | ||
* | ||
* @param {string} string | ||
* @return {this} The instance on which the method is called | ||
*/ | ||
|
||
color(string) { | ||
return this.set(string, props.color); | ||
} | ||
|
||
/** | ||
* Adds Blocks to the Attachment object | ||
* | ||
* {@link https://api.slack.com/reference/messaging/attachments|View in Slack API Documentation} | ||
* | ||
* @param {...Block|Array<Block>} blocks Accepts multiple arguments or Array | ||
* @return {this} The instance on which the method is called | ||
*/ | ||
|
||
blocks(...blocks) { | ||
return this.append(blocks.flat(), props.blocks); | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
|
||
build() { | ||
const augmentedProps = { | ||
blocks: BuilderHelper.getBuilderResults(this.props.blocks), | ||
}; | ||
|
||
return this.getResult(AttachmentDto, augmentedProps); | ||
} | ||
} | ||
|
||
module.exports = { | ||
Attachment, | ||
AttachmentDto, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.