Module: KayakoClient::PostClient

Included in:
TicketPost
Defined in:
lib/kayako_client/mixins/post_client.rb

Instance Method Summary collapse

Instance Method Details

#attachments(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/kayako_client/mixins/post_client.rb', line 18

def attachments(options = {})
    values = []
    if ticket_id && id
        items = KayakoClient::TicketAttachment.all(ticket_id, options.merge(inherited_options))
        items.each do |item|
            values << item if item.ticket_post_id == id
        end
    end
    values
end

#delete_attachment(attachment, options = {}) ⇒ Object Also known as: destroy_attachment



49
50
51
# File 'lib/kayako_client/mixins/post_client.rb', line 49

def delete_attachment(attachment, options = {})
    KayakoClient::TicketAttachment.delete(ticket_id, attachment, options.merge(inherited_options)) if ticket_id
end

#get_attachment(attachment, options = {}) ⇒ Object Also known as: find_attachment



29
30
31
# File 'lib/kayako_client/mixins/post_client.rb', line 29

def get_attachment(attachment, options = {})
    KayakoClient::TicketAttachment.get(ticket_id, attachment, options.merge(inherited_options)) if ticket_id
end

#post_attachment(options = {}) ⇒ Object Also known as: create_attachment



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/kayako_client/mixins/post_client.rb', line 35

def post_attachment(options = {})
    if ticket_id && id
        if logger
            logger.warn "overwriting :ticket_id"      if options[:ticket_id] && options[:ticket_id].to_i != ticket_id
            logger.warn "overwriting :ticket_post_id" if options[:ticket_post_id] && options[:ticket_post_id].to_i != id
        end
        options[:ticket_id] = ticket_id
        options[:ticket_post_id] = id
        KayakoClient::TicketAttachment.post(options.merge(inherited_options))
    end
end