Class: TicketMaster::Provider::Mingle::Ticket

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Ticket

declare needed overloaded methods herea



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

def initialize(*object)
  if object.first
    args = object
    object = args.shift
    identifier = args.shift
    @system_data = {:client => object}
    unless object.is_a? Hash
     hash = {:number => object.number,
             :name => object.name,
             :description => object.description,
             :card_type_name => object.card_type.nil? ? "Card" : object.card_type.name,
             :identifier => identifier,
             :created_on => object.created_on,
             :modified_on => object.modified_on,
             :properties => object.properties}
    else
      hash = object
    end
    super hash
  end
end

Class Method Details

.create(*options) ⇒ Object



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

def self.create(*options)
  card = API.new(*options)
  ticket = self.new card
  card.save
  ticket
end

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



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

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

.find_by_id(identifier, number) ⇒ Object



39
40
41
# File 'lib/provider/ticket.rb', line 39

def self.find_by_id(identifier, number)
  self.search(identifier, {'number' => number}).first
end

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



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

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

Instance Method Details

#comment!(*options) ⇒ Object

def comment(*options)



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

def comment!(*options)
  options[0].update(:identifier => identifier, :number => number) if options.first.is_a?(Hash)
  Comment.create(*options)
end

#comments(*options) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/provider/ticket.rb', line 80

def comments(*options)
  begin
    if options.empty?
      comments = MingleAPI::Comment.find(:all, :params => {:identifier => identifier, :number => number}).collect { |comment| TicketMaster::Provider::Mingle::Comment.new comment }
    else
      super(*options)
    end
  rescue
   [] 
  end
end

#descriptionObject



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

def description
  self[:description]
end

#idObject



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

def id
  self[:id].to_i
end

#identifierObject



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

def identifier
  self[:identifier]
end

#nameObject



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

def name
  self[:name]
end

#numberObject



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

def number
 self[:number].to_i
end

#statusObject



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

def status
  self.properties[1].value
end

#titleObject



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

def title
  self[:name]
end