Class: Slk::Api::Dnd
- Inherits:
-
Object
- Object
- Slk::Api::Dnd
- Defined in:
- lib/slk/api/dnd.rb
Overview
Wrapper for Slack dnd.* (Do Not Disturb) API endpoints
Instance Method Summary collapse
- #end_snooze ⇒ Object
- #info ⇒ Object
-
#initialize(api_client, workspace) ⇒ Dnd
constructor
A new instance of Dnd.
-
#set_snooze(duration) ⇒ Object
rubocop:disable Naming/AccessorMethodName.
- #snooze_remaining ⇒ Object
- #snoozing? ⇒ Boolean
Constructor Details
#initialize(api_client, workspace) ⇒ Dnd
Returns a new instance of Dnd.
7 8 9 10 |
# File 'lib/slk/api/dnd.rb', line 7 def initialize(api_client, workspace) @api = api_client @workspace = workspace end |
Instance Method Details
#end_snooze ⇒ Object
21 22 23 |
# File 'lib/slk/api/dnd.rb', line 21 def end_snooze @api.post(@workspace, 'dnd.endSnooze') end |
#info ⇒ Object
12 13 14 |
# File 'lib/slk/api/dnd.rb', line 12 def info @api.post(@workspace, 'dnd.info') end |
#set_snooze(duration) ⇒ Object
rubocop:disable Naming/AccessorMethodName
16 17 18 19 |
# File 'lib/slk/api/dnd.rb', line 16 def set_snooze(duration) # rubocop:disable Naming/AccessorMethodName minutes = duration.to_minutes @api.post(@workspace, 'dnd.setSnooze', { num_minutes: minutes }) end |
#snooze_remaining ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/slk/api/dnd.rb', line 29 def snooze_remaining data = info return nil unless data['snooze_enabled'] endtime = data['snooze_endtime'] return nil unless endtime remaining = endtime - Time.now.to_i remaining.positive? ? Models::Duration.new(seconds: remaining) : nil end |
#snoozing? ⇒ Boolean
25 26 27 |
# File 'lib/slk/api/dnd.rb', line 25 def snoozing? info['snooze_enabled'] == true end |