Module: Commands::Base
- Included in:
- Ack, AckAll, AckMine, Forget, Identify, Incident, IncidentsAll, IncidentsMine, Notes, OnCallList, OnCallLookup, PagerMe, Resolve, ResolveAll, ResolveMine
- Defined in:
- lib/lita/commands/base.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #current_user ⇒ Object
- #format_incident(incident) ⇒ Object
- #format_incidents(incidents) ⇒ Object
- #format_note(note, incident_id) ⇒ Object
- #format_notes(notes, incident_id) ⇒ Object
- #initialize(message, pagerduty, store) ⇒ Object
- #pagerduty ⇒ Object
- #response(obj) ⇒ Object
- #store ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/lita/commands/base.rb', line 3 def self.included(base) base.class_eval do extend ClassMethods attr_reader :message attr_reader :data attr_reader :pagerduty attr_reader :store end end |
Instance Method Details
#current_user ⇒ Object
62 63 64 65 |
# File 'lib/lita/commands/base.rb', line 62 def current_user @current_user ||= pagerduty.get_users(query: store.get_user()) .first end |
#format_incident(incident) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/lita/commands/base.rb', line 49 def format_incident(incident) assignee = (incident.fetch(:assignments, []).first || {}) .fetch(:assignee, {}) .fetch(:summary, 'none') { message: 'incident.info', params: { id: incident[:id], subject: incident[:title], assigned: assignee.inspect, url: incident[:html_url] } } end |
#format_incidents(incidents) ⇒ Object
45 46 47 |
# File 'lib/lita/commands/base.rb', line 45 def format_incidents(incidents) incidents.map { |incident| format_incident(incident) } end |
#format_note(note, incident_id) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/lita/commands/base.rb', line 34 def format_note(note, incident_id) { message: 'note.show', params: { id: incident_id, content: note[:content], user: note[:user][:summary] } } end |
#format_notes(notes, incident_id) ⇒ Object
30 31 32 |
# File 'lib/lita/commands/base.rb', line 30 def format_notes(notes, incident_id) notes.map { |note| format_note(note, incident_id) } end |
#initialize(message, pagerduty, store) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/lita/commands/base.rb', line 19 def initialize(, pagerduty, store) @message = @pagerduty = pagerduty @store = store @data = nil end |
#pagerduty ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/lita/commands/base.rb', line 67 def pagerduty @pagerduty ||= ::Pagerduty.new( http, config.api_key, config.email, config.teams ) end |
#response(obj) ⇒ Object
26 27 28 |
# File 'lib/lita/commands/base.rb', line 26 def response(obj) @data = obj end |