Class: TicketMaster::Provider::Codaset::Ticket

Inherits:
Base::Ticket
  • Object
show all
Defined in:
lib/provider/ticket.rb

Overview

The class to access the api’s tickets

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Ticket

declare needed overloaded methods here



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/provider/ticket.rb', line 12

def initialize(*object)
  if object.first
    args = object
    object = args.shift
    project_id = args.shift
    @system_data = {:client => object}
    unless object.is_a? Hash
      hash = {:id => object.id,
              :title => object.title,
              :description => object.description,
              :status => object.state,
              :created_at => object.created_at,
              :updated_at => object.updated_at,
              :project_id => project_id}
    else
      hash = object
    end
    super hash
  end
end

Instance Attribute Details

#prefix_optionsObject

Returns the value of attribute prefix_options.



8
9
10
# File 'lib/provider/ticket.rb', line 8

def prefix_options
  @prefix_options
end

Class Method Details

.create(*options) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/provider/ticket.rb', line 33

def self.create(*options) 
    issue = API.new(options.first.merge!(:state => 'new', 
                                         :created_at => Time.now,
                                         :updated_at => Time.now))
    ticket = self.new issue
    issue.save
    ticket
end

.find_by_attributes(project_id, attributes = {}) ⇒ Object



51
52
53
# File 'lib/provider/ticket.rb', line 51

def self.find_by_attributes(project_id, attributes = {})
   self.search(project_id, attributes)
end

.find_by_id(project_id, id) ⇒ Object



42
43
44
# File 'lib/provider/ticket.rb', line 42

def self.find_by_id(project_id, id)
    self.search(project_id, {'id' => id}).first
end

.search(project_id, options = {}, limit = 1000) ⇒ Object



46
47
48
49
# File 'lib/provider/ticket.rb', line 46

def self.search(project_id, options = {}, limit = 1000)
    tickets = API.find(:all, :params => {:slug => project_id}).collect { |ticket| self.new ticket, project_id }
    search_by_attribute(tickets, options, limit)
end

Instance Method Details

#commentObject

TODO?



89
90
91
92
# File 'lib/provider/ticket.rb', line 89

def comment
    warn 'Comments not supported. Perhaps you should leave feedback to request it?'
    nil
end

#comment!Object

TODO?



95
96
97
98
# File 'lib/provider/ticket.rb', line 95

def comment!
    warn 'Comments not supported. Perhaps you should leave feedback to request it?'
    []
end

#commentsObject



83
84
85
86
# File 'lib/provider/ticket.rb', line 83

def comments
    warn 'Comments not supported. Perhaps you should leave feedback to request it?'
    []
end

#created_atObject



59
60
61
# File 'lib/provider/ticket.rb', line 59

def created_at
  @created_at ||= self[:created_at] ? Time.parse(self[:created_at]) : nil
end

#descriptionObject



79
80
81
# File 'lib/provider/ticket.rb', line 79

def description
  self[:description]
end

#idObject



67
68
69
# File 'lib/provider/ticket.rb', line 67

def id
  self[:id].to_i
end

#project_idObject



55
56
57
# File 'lib/provider/ticket.rb', line 55

def project_id
  self[:project_id]
end

#statusObject



71
72
73
# File 'lib/provider/ticket.rb', line 71

def status
  self[:status]
end

#titleObject



75
76
77
# File 'lib/provider/ticket.rb', line 75

def title
  self[:title]
end

#updated_atObject



63
64
65
# File 'lib/provider/ticket.rb', line 63

def updated_at
  @updated_at ||= self[:updated_at] ? Time.parse(self[:updated_at]) : nil
end