Class: JIRA::Resource::Attachment

Inherits:
Base
  • Object
show all
Defined in:
lib/jira/resource/attachment.rb

Constant Summary

Constants inherited from Base

Base::QUERY_PARAMS_FOR_SEARCH, Base::QUERY_PARAMS_FOR_SINGLE_FETCH

Instance Attribute Summary

Attributes inherited from Base

#attrs, #client, #deleted, #expanded

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, belongs_to, belongs_to_relationships, build, collection_attributes_are_nested, collection_path, #collection_path, #delete, #fetch, find, #has_errors?, has_many, has_one, #id, #initialize, key_attribute, #key_value, #method_missing, nested_collections, #new_record?, parse_json, #patched_url, #path_component, #respond_to?, #save, #set_attrs, #set_attrs_from_response, singular_path, #to_json, #to_s, #to_sym, #url

Constructor Details

This class inherits a constructor from JIRA::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JIRA::Base

Class Method Details

.endpoint_nameObject



13
14
15
# File 'lib/jira/resource/attachment.rb', line 13

def self.endpoint_name
  'attachments'
end

.meta(client) ⇒ Object



17
18
19
20
# File 'lib/jira/resource/attachment.rb', line 17

def self.meta(client)
  response = client.get(client.options[:rest_base_path] + '/attachment/meta')
  parse_json(response.body)
end

Instance Method Details

#save!(attrs, path = url) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jira/resource/attachment.rb', line 22

def save!(attrs, path = url)
  file = attrs['file'] || attrs[:file] # Keep supporting 'file' parameter as a string for backward compatibility
  mime_type = attrs[:mimeType] || 'application/binary'

  headers = { 'X-Atlassian-Token' => 'nocheck' }
  data = { 'file' => UploadIO.new(file, mime_type, file) }

  response = client.post_multipart(path, data , headers)

  set_attributes(attrs, response)

  @expanded = false
  true
end