class KayakoClient::Ticket

Constants

FLAG_BLUE
FLAG_GREEN
FLAG_NONE

NOTE: department is required to be of :tickets type

FLAG_ORANGE
FLAG_PURPLE
FLAG_RED
FLAG_YELLOW
SEARCH_AUTHOR
SEARCH_CONTENTS
SEARCH_CREATOR_EMAIL
SEARCH_EMAIL
SEARCH_FULL_NAME
SEARCH_NOTES
SEARCH_TAGS
SEARCH_TICKET_ID
SEARCH_USER
SEARCH_USER_GROUP
SEARCH_USER_ORGANIZATION
TICKET_TYPES

Public Class Methods

all(*args) click to toggle source
Calls superclass method
# File lib/kayako_client/ticket.rb, line 160
def self.all(*args)
    options = args.last.is_a?(Hash) ? args.pop : {}

    components = []
    args.each_index do |index|
        break if index > 5
        if args[index]
            components[index] ||= []
            components[index] << args[index]
        end
    end

    options.keys.each do |option|
        case option.to_s.gsub(%r{_}, '')
        when 'departmentid', 'department'
            index = 0
        when 'ticketstatusid', 'ticketstatus'
            index = 1
        when 'ownerstaffid', 'ownerstaff'
            index = 2
        when 'userid', 'user'
            index = 3
        when 'count', 'limit'
            index = 4
            components[index] = []
        when 'start', 'offset'
            index = 5
            components[index] = []
        else
            next
        end
        components[index] ||= []
        components[index] << options.delete(option)
    end

    raise ArgumentError, "missing :department_id" unless components[0]

    e = path + '/ListAll' + components.inject('') do |uri, item|
        uri << '/' + (item.nil? ? '-1' : item.flatten.uniq.join(','))
    end

    super(options.merge(:e => e))
end
get(id = :all, options = {}) click to toggle source
Calls superclass method
# File lib/kayako_client/ticket.rb, line 204
def self.get(id = :all, options = {})
    if id == :all
        all(options.delete(:id), options)
    else
        super(options.merge(:id => id))
    end
end

Public Instance Methods

created_by_user?() click to toggle source
# File lib/kayako_client/ticket.rb, line 146
def created_by_user?
    !user_id.nil? && user_id > 0
end
Also aliased as: has_user?
has_owner_staff?() click to toggle source
# File lib/kayako_client/ticket.rb, line 156
def has_owner_staff?
    !owner_staff_id.nil? && owner_staff_id > 0
end
has_user?()
Alias for: created_by_user?
has_user_organization?() click to toggle source
# File lib/kayako_client/ticket.rb, line 152
def has_user_organization?
    !user_organization_id.nil? && user_organization_id > 0
end
posts() click to toggle source
# File lib/kayako_client/ticket.rb, line 130
def posts
    if instance_variable_defined?(:@posts)
        instance_variable_get(:@posts)
    elsif !new? && id && id > 0
        logger.debug "posts are missing - trying to load" if logger
        post = KayakoClient::TicketPost.all(id, inherited_options)
        if post && !post.empty?
            instance_variable_set(:@posts, post)
        else
            instance_variable_set(:@posts, nil)
        end
    else
        nil
    end
end

Private Instance Methods

validate(method, params) click to toggle source
# File lib/kayako_client/ticket.rb, line 258
def validate(method, params)
    if method == :post
        unless params[:auto_user_id] || params[:user_id] || params[:staff_id]
            raise ArgumentError, ":auto_user_id, :user_id or :staff_id is required"
        end
    end
    if params.has_key?(:template_group_id) && params.has_key?(:template_group_name)
        raise ArgumentError, "Only one of :template_group_id or :template_group_name should be used"
    end
end