Class: ZammadAPI::Resources::Ticket

Inherits:
Base
  • Object
show all
Defined in:
lib/zammad_api/resources/ticket.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, #initialize, #method_missing, #new_record?, #save, search, url

Constructor Details

This class inherits a constructor from ZammadAPI::Resources::Base

Dynamic Method Handling

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

Instance Method Details

#article(data) ⇒ Object



18
19
20
21
22
23
# File 'lib/zammad_api/resources/ticket.rb', line 18

def article(data)
  data[:ticket_id] = @attributes[:id]
  item = ZammadAPI::Resources::TicketArticle.new(@transport, data)
  item.save
  item
end

#articlesObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/zammad_api/resources/ticket.rb', line 4

def articles
  response = @transport.get(url: "/api/v1/ticket_articles/by_ticket/#{id}?expand=true")
  data = JSON.parse(response.body)
  if response.status != 200
    raise "Can't get articles (#{self.class.name}): #{data['error']}"
  end

  data.collect { |raw|
    item = ZammadAPI::Resources::TicketArticle.new(@transport, raw)
    item.new_instance = false
    item
  }
end