diff --git a/dist/slackme.classes.slackmessage.d.ts b/dist/slackme.classes.slackmessage.d.ts index 9a47a0e..3e18058 100644 --- a/dist/slackme.classes.slackmessage.d.ts +++ b/dist/slackme.classes.slackmessage.d.ts @@ -1,3 +1,8 @@ +export interface IAttachmentField { + title: string; + value: string; + short?: boolean; +} export interface IMessageOptions { /** * "Required plain-text summary of the attachment." @@ -11,24 +16,35 @@ export interface IMessageOptions { * a message to show above */ pretext?: string; - "author_name"?: "Bobby Tables"; - "author_link"?: "http://flickr.com/bobby/"; - "author_icon"?: "http://flickr.com/icons/bobby.jpg"; - "title"?: "Slack API Documentation"; - "title_link"?: "https://api.slack.com/"; + /** + * author name of the attachment + */ + author_name?: string; + /** + * a link to the author + */ + author_link?: string; + /** + * a string to the author + */ + author_icon?: string; + /** + * a title for the attachment + */ + title?: string; + /** + * a link for the title + */ + title_link?: string; /** * the main text of the message */ text?: string; - "fields"?: [{ - "title"?: "Priority"; - "value"?: "High"; - "short"?: false; - }]; - "image_url"?: "http://my-website.com/path/to/image.jpg"; - "thumb_url"?: "http://example.com/path/to/thumb.png"; - "footer"?: "Slack API"; - "footer_icon"?: "https://platform.slack-edge.com/img/default_application_icon.png"; + fields?: IAttachmentField[]; + image_url?: string; + thumb_url?: string; + footer?: string; + footer_icon?: string; /** * timestamp as epoch time */ diff --git a/dist/slackme.classes.slackmessage.js b/dist/slackme.classes.slackmessage.js index 64b32cc..f8badc4 100644 --- a/dist/slackme.classes.slackmessage.js +++ b/dist/slackme.classes.slackmessage.js @@ -6,4 +6,4 @@ class SlackMessage { } } exports.SlackMessage = SlackMessage; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhY2ttZS5jbGFzc2VzLnNsYWNrbWVzc2FnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NsYWNrbWUuY2xhc3Nlcy5zbGFja21lc3NhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUF5Q0E7SUFFRSxZQUFZLGNBQStCO1FBQ3pDLElBQUksQ0FBQyxjQUFjLEdBQUcsY0FBYyxDQUFBO0lBQ3RDLENBQUM7Q0FDRjtBQUxELG9DQUtDIn0= \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xhY2ttZS5jbGFzc2VzLnNsYWNrbWVzc2FnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NsYWNrbWUuY2xhc3Nlcy5zbGFja21lc3NhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUF3REE7SUFFRSxZQUFZLGNBQStCO1FBQ3pDLElBQUksQ0FBQyxjQUFjLEdBQUcsY0FBYyxDQUFBO0lBQ3RDLENBQUM7Q0FDRjtBQUxELG9DQUtDIn0= \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index 0f0ee8b..c2b86bb 100644 --- a/test/test.ts +++ b/test/test.ts @@ -13,8 +13,23 @@ tap.test('should create a valid slackme instance', async () => { tap.test('should send a message to Slack', async () => { let slackMessage = new slackme.SlackMessage({ - text: 'hi. This is a text', - color: '#3cb371' + author_name: 'GitLab CI', + author_link: 'https://gitlab.com/', + pretext: '*Good News*: Build successfull!', + color: '#3cb371', + fields: [ + { + title: 'Branch', + value: 'Lossless Cloud', + short: true + }, + { + title: 'Product ID', + value: 'pushrocks', + short: true + } + ], + ts: (new Date()).getTime() }) testSlackme.sendMessage(slackMessage, 'random') }) diff --git a/ts/slackme.classes.slackmessage.ts b/ts/slackme.classes.slackmessage.ts index 1fbfa43..f753455 100644 --- a/ts/slackme.classes.slackmessage.ts +++ b/ts/slackme.classes.slackmessage.ts @@ -1,5 +1,11 @@ import * as plugins from './slackme.plugins' +export interface IAttachmentField { + title: string + value: string + short?: boolean +} + export interface IMessageOptions { /** * "Required plain-text summary of the attachment." @@ -13,26 +19,35 @@ export interface IMessageOptions { * a message to show above */ pretext?: string, - "author_name"?: "Bobby Tables", - "author_link"?: "http://flickr.com/bobby/", - "author_icon"?: "http://flickr.com/icons/bobby.jpg", - "title"?: "Slack API Documentation", - "title_link"?: "https://api.slack.com/", + /** + * author name of the attachment + */ + author_name?: string, + /** + * a link to the author + */ + author_link?: string, + /** + * a string to the author + */ + author_icon?: string, + /** + * a title for the attachment + */ + title?: string, + /** + * a link for the title + */ + title_link?: string, /** * the main text of the message */ text?: string, - "fields"?: [ - { - "title"?: "Priority", - "value"?: "High", - "short"?: false - } - ], - "image_url"?: "http://my-website.com/path/to/image.jpg", - "thumb_url"?: "http://example.com/path/to/thumb.png", - "footer"?: "Slack API", - "footer_icon"?: "https://platform.slack-edge.com/img/default_application_icon.png", + fields?: IAttachmentField[], + image_url?: string, + thumb_url?: string, + footer?: string, + footer_icon?: string, /** * timestamp as epoch time */