Class: SlackNotifiee::Notification
- Inherits:
-
Object
- Object
- SlackNotifiee::Notification
- Defined in:
- lib/slack_notifiee/notification.rb
Instance Attribute Summary collapse
-
#attachments ⇒ Object
readonly
Returns the value of attribute attachments.
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#datetime ⇒ Object
readonly
Returns the value of attribute datetime.
-
#icon_emoji ⇒ Object
readonly
Returns the value of attribute icon_emoji.
-
#icon_url ⇒ Object
readonly
Returns the value of attribute icon_url.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#webhook_url ⇒ Object
readonly
Returns the value of attribute webhook_url.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(**attributes) ⇒ Notification
constructor
A new instance of Notification.
Constructor Details
#initialize(**attributes) ⇒ Notification
Returns a new instance of Notification.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/slack_notifiee/notification.rb', line 27 def initialize(**attributes) @webhook_url = attributes[:webhook_url] @username = attributes[:username] @channel = attributes[:channel] @attachments = attributes[:attachments] @blocks = attributes[:blocks] @text = attributes[:text] @icon_emoji = attributes[:icon_emoji] @icon_url = attributes[:icon_url] @datetime = attributes[:datetime] end |
Instance Attribute Details
#attachments ⇒ Object (readonly)
Returns the value of attribute attachments.
9 10 11 |
# File 'lib/slack_notifiee/notification.rb', line 9 def @attachments end |
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
9 10 11 |
# File 'lib/slack_notifiee/notification.rb', line 9 def blocks @blocks end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
9 10 11 |
# File 'lib/slack_notifiee/notification.rb', line 9 def channel @channel end |
#datetime ⇒ Object (readonly)
Returns the value of attribute datetime.
9 10 11 |
# File 'lib/slack_notifiee/notification.rb', line 9 def datetime @datetime end |
#icon_emoji ⇒ Object (readonly)
Returns the value of attribute icon_emoji.
9 10 11 |
# File 'lib/slack_notifiee/notification.rb', line 9 def icon_emoji @icon_emoji end |
#icon_url ⇒ Object (readonly)
Returns the value of attribute icon_url.
9 10 11 |
# File 'lib/slack_notifiee/notification.rb', line 9 def icon_url @icon_url end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
9 10 11 |
# File 'lib/slack_notifiee/notification.rb', line 9 def text @text end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
9 10 11 |
# File 'lib/slack_notifiee/notification.rb', line 9 def username @username end |
#webhook_url ⇒ Object (readonly)
Returns the value of attribute webhook_url.
9 10 11 |
# File 'lib/slack_notifiee/notification.rb', line 9 def webhook_url @webhook_url end |
Class Method Details
.build_from_json(json) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/slack_notifiee/notification.rb', line 11 def self.build_from_json(json) attributes = ::JSON.parse(json) new( webhook_url: ::URI.parse(attributes['webhook_url']), username: attributes['username'], channel: attributes['channel'], attachments: attributes['attachments'], blocks: attributes['blocks'], text: attributes['text'], icon_emoji: attributes['icon_emoji'], icon_url: attributes['icon_url'].nil? ? nil : ::URI.parse(attributes['icon_url']), datetime: ::Time.parse(attributes['datetime']) ) end |
Instance Method Details
#attributes ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/slack_notifiee/notification.rb', line 39 def attributes { webhook_url: webhook_url, username: username, channel: channel, attachments: , blocks: blocks, text: text, icon_emoji: icon_emoji, icon_url: icon_url, datetime: datetime } end |