Module: Nearmiss::Client::Incidents
- Defined in:
- lib/toolhound-ruby/client/incidents.rb
Overview
Methods for the Incidents API
Instance Method Summary collapse
-
#create_incident(options = {}) ⇒ Sawyer::Resource
(also: #create_nearmiss)
Create an incident.
-
#create_incident_comment(incident_id, comment, options = {}) ⇒ Sawyer::Resource
(also: #create_nearmiss_comment)
Create incident comment.
-
#delete_incident_comment(incident_id, comment_id, options = {}) ⇒ Boolean
(also: #delete_nearmiss_comment)
Delete incident comment.
-
#incident(incident, options = {}) ⇒ Sawyer::Resource
(also: #nearmiss)
Get a single incident.
-
#incident_comment(incident_id, comment_id, options = {}) ⇒ Sawyer::Resource
(also: #nearmiss_comment)
Get incident comment.
-
#incident_comments(incident_id, options = {}) ⇒ Array<Sawyer::Resource>
(also: #nearmiss_comments)
List incident comments.
-
#incidents(options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_incidents, #list_nearmisses, #nearmisses)
List nearmiss incidents.
-
#project_incidents(project, options = {}) ⇒ Sawyer::Resource
Project incidents.
- #update_incident(incident, options = {}) ⇒ Object (also: #edit_incident, #update_nearmiss, #edit_nearmiss)
-
#update_incident_comment(incident_id, comment_id, comment, options = {}) ⇒ Sawyer::Resource
(also: #edit_incident_comment, #update_nearmiss_comment, #edit_nearmiss_comment)
Update incident comment.
Instance Method Details
#create_incident(options = {}) ⇒ Sawyer::Resource Also known as: create_nearmiss
Create an incident
66 67 68 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 66 def create_incident( = {}) post 'incidents', end |
#create_incident_comment(incident_id, comment, options = {}) ⇒ Sawyer::Resource Also known as: create_nearmiss_comment
Create incident comment
108 109 110 111 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 108 def create_incident_comment(incident_id, comment, = {}) .merge!({text: comment}) post "incidents/#{incident_id}/comments", end |
#delete_incident_comment(incident_id, comment_id, options = {}) ⇒ Boolean Also known as: delete_nearmiss_comment
Delete incident comment
Requires authenticated client.
139 140 141 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 139 def delete_incident_comment(incident_id, comment_id, = {}) boolean_from_response(:delete, "incidents/#{incident_id}/comments/#{comment_id}", ) end |
#incident(incident, options = {}) ⇒ Sawyer::Resource Also known as: nearmiss
Get a single incident
29 30 31 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 29 def incident(incident, = {}) get "incidents/#{incident}", end |
#incident_comment(incident_id, comment_id, options = {}) ⇒ Sawyer::Resource Also known as: nearmiss_comment
Get incident comment
96 97 98 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 96 def incident_comment(incident_id, comment_id, = {}) get "incidents/#{incident_id}/comments/#{comment_id}", end |
#incident_comments(incident_id, options = {}) ⇒ Array<Sawyer::Resource> Also known as: nearmiss_comments
List incident comments
84 85 86 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 84 def incident_comments(incident_id, = {}) paginate "incidents/#{incident_id}/comments", end |
#incidents(options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_incidents, list_nearmisses, nearmisses
List nearmiss incidents
12 13 14 15 16 17 18 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 12 def incidents( = {}) since = [:since] || ["since"] .merge!(since: iso8601(parse_date(since))) if since paginate "incidents", end |
#project_incidents(project, options = {}) ⇒ Sawyer::Resource
Project incidents
39 40 41 42 43 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 39 def project_incidents(project, = {}) paginate "#{Project.new(project).path}/incidents", end |
#update_incident(incident, options = {}) ⇒ Object Also known as: edit_incident, update_nearmiss, edit_nearmiss
71 72 73 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 71 def update_incident(incident, = {}) patch "incidents/#{incident}", end |
#update_incident_comment(incident_id, comment_id, comment, options = {}) ⇒ Sawyer::Resource Also known as: edit_incident_comment, update_nearmiss_comment, edit_nearmiss_comment
Update incident comment
122 123 124 125 |
# File 'lib/toolhound-ruby/client/incidents.rb', line 122 def update_incident_comment(incident_id, comment_id, comment, = {}) .merge!({text: comment}) patch "incidents/#{incident_id}/comments/#{comment_id}", end |