Module: Nearmiss::Client::Attachments

Defined in:
lib/toolhound-ruby/client/attachments.rb

Overview

Methods for the Attachments API

Instance Method Summary collapse

Instance Method Details

#attachment(attachment, options = {}) ⇒ Sawyer::Resource

Get a single attachment

Parameters:

  • attachment (String)

    ID of attachment to fetch

Returns:

  • (Sawyer::Resource)

    Incident information



26
27
28
# File 'lib/toolhound-ruby/client/attachments.rb', line 26

def attachment(attachment, options = {})
  get "attachments/#{attachment}", options
end

#attachments(options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_attachments

List nearmiss attachments

Returns:

  • (Array<Sawyer::Resource>)

    List of attachments



12
13
14
15
16
17
18
# File 'lib/toolhound-ruby/client/attachments.rb', line 12

def attachments(options = {})
  since = options[:since] || options["since"]

  options.merge!(since: iso8601(parse_date(since))) if since

  paginate "attachments", options
end

#create_attachment(options = {}) ⇒ Sawyer::Resource

Returns Newly created attachment info.

Returns:

  • (Sawyer::Resource)

    Newly created attachment info



54
55
56
# File 'lib/toolhound-ruby/client/attachments.rb', line 54

def create_attachment(options = {})
  post 'attachments', options
end

#incident_attachments(incident, options = {}) ⇒ Sawyer::Resource Also known as: nearmiss_attachments

Project attachments

Parameters:

  • project (String, Hash, Incident)

    Incident

Returns:

  • (Sawyer::Resource)

    Incident information



35
36
37
38
39
# File 'lib/toolhound-ruby/client/attachments.rb', line 35

def incident_attachments(incident, options = {})

  paginate "#{Incident.new(incident).path}/attachments", options

end

#update_attachment(attachment, options = {}) ⇒ Object Also known as: edit_attachment



59
60
61
# File 'lib/toolhound-ruby/client/attachments.rb', line 59

def update_attachment(attachment, options = {})
  patch "attachments/#{attachment}", options
end