Class: ZammadAPI::Resources::TicketArticleAttachment

Inherits:
Base
  • Object
show all
Defined in:
lib/zammad_api/resources/ticket_article_attachment.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #changes, #new_instance, #url

Instance Method Summary collapse

Methods inherited from Base

all, #changed?, create, #destroy, destroy, find, get_url, #new_record?, #save, search, url

Constructor Details

#initialize(transport, attributes = {}) ⇒ TicketArticleAttachment

Returns a new instance of TicketArticleAttachment.



3
4
5
6
7
# File 'lib/zammad_api/resources/ticket_article_attachment.rb', line 3

def initialize(transport, attributes = {})
  @transport  = transport
  @attributes = attributes
  symbolize_keys_deep!(@attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *_args) ⇒ Object



9
10
11
# File 'lib/zammad_api/resources/ticket_article_attachment.rb', line 9

def method_missing(method, *_args)
  @attributes[method.to_sym]
end

Instance Method Details

#downloadObject



13
14
15
16
17
18
# File 'lib/zammad_api/resources/ticket_article_attachment.rb', line 13

def download
  response = @transport.get(url: "/api/v1/ticket_attachment/#{ticket_id}/#{article_id}/#{id}")
  return response.body if response.status == 200
  data = JSON.parse(response.body)
  raise "Can't get articles (#{self.class.name}): #{data['error']}"
end