Skip to content

Commit

Permalink
Fix field optionality
Browse files Browse the repository at this point in the history
We should try to make fields optional or required based
on how Slack treats them.  Some exceptions are Action
where we don't want rug writer to provide a complete
Action definition but rather use helper functions to create
fully populated actions
  • Loading branch information
Tanya Romankova committed May 9, 2017
1 parent 23f53d2 commit 1b0c2ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed
- `SlackMessage` `text` field should be optional
- Add missing `author_icon` to `Attachment`
- `Attachment` `text` field should be optional
- `ActionConfirmation` fields should be optional
- Add missing `author_icon` and `callback_id` to `Attachment`

## [0.1.0]: - 2017-05-09

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"scripts": {
"test": "tsc -p . && mocha --require intelli-espower-loader --recursive build/test",
"cleantest": "rm -rf build && tsc -p . && mocha --require intelli-espower-loader --recursive build/test",
"autotest": "supervisor -q -n exit -x ./node_modules/.bin/mocha -- --require intelli-espower-loader --recursive build/test"
},
"repository": {
Expand Down
15 changes: 10 additions & 5 deletions src/SlackMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ export interface SlackMessage {
attachments?: Attachment[];
}

/** Represent slack attachment. */
/**
* Represent slack attachment.
* https://api.slack.com/docs/interactive-message-field-guide#attachment_fields
*/
export interface Attachment {
text: string;
text?: string;
fallback: string;
mrkdwn_in?: string[];
color?: string;
Expand All @@ -145,6 +148,8 @@ export interface Attachment {
footer_icon?: string;
ts?: number;
actions?: Action[];
callback_id?: string;
attachment_type?: string;
}

/** Represents slack attachment field. */
Expand All @@ -169,10 +174,10 @@ export interface Action {

/** Represents Slack action confirmation. */
export interface ActionConfirmation {
title: string;
title?: string;
text: string;
ok_text: string;
dismiss_text: string;
ok_text?: string;
dismiss_text?: string;
}

type ActionType = "button";
Expand Down

0 comments on commit 1b0c2ba

Please sign in to comment.