Class: TicketMaster::Provider::Lighthouse::Ticket
- Inherits:
-
Base::Ticket
- Object
- Base::Ticket
- TicketMaster::Provider::Lighthouse::Ticket
- Defined in:
- lib/provider/ticket.rb
Overview
Ticket class for ticketmaster-lighthouse
Due to the way Lighthouse stores tickets, we actually end up creating a new ticket version every time we edit tickets. Their api FAQ states these attributes as the only editable ones(?):
-
title
-
body - follows the same formatting rules.
-
state - Can be any one of these: new, open, resolved, hold, invalid. Optional, set to open by default for new tickets.
-
assigned-user-id - optional
-
milestone-id - optional
-
tag - space or comma delimited list of tags
We had to remap things a bit since lighthouse doesn’t name things as ticketmaster specifies.
-
id => number (read-only)
-
status => state
-
resolution => ticket.latest_body
-
description => ticket.original_body (setting a new description creates a new body)
-
assignee => assigned_user_name (read-only)
-
requestor => creator_name (read-only)
-
project_id => prefix_options
-
priority
-
title
-
created_at
-
updated_at
Constant Summary collapse
- API =
::Lighthouse::Ticket
- @@allowed_states =
['new', 'open', 'resolved', 'hold', 'invalid']
Instance Attribute Summary collapse
-
#prefix_options ⇒ Object
Returns the value of attribute prefix_options.
Class Method Summary collapse
-
.search(project_id, options = {}, limit = 1000) ⇒ Object
Lighthouse limits us to a 100 ticket limit per page…
Instance Method Summary collapse
-
#assignee ⇒ Object
Get the assigned person’s name.
-
#body=(bod) ⇒ Object
Set the body.
-
#close(resolution = 'resolved') ⇒ Object
The closer.
-
#description ⇒ Object
Get the description, mapped to original_body.
-
#description=(desc) ⇒ Object
Set the description, mapped to body, which actually does a comment.
-
#id ⇒ Object
This is to get the ticket id We can’t set ids, so there’s no ‘id=’ method.
-
#project_id ⇒ Object
Get the project id.
-
#requestor ⇒ Object
Get the requestor’s name.
-
#resolution ⇒ Object
Get the resolution, mapped to latest_body.
-
#resolution=(res) ⇒ Object
Set the resolution…also sets state to resolved.
-
#save ⇒ Object
Gotta unset the body attribute…otherwise every save ends up using that body.
-
#status ⇒ Object
This is to get the status, mapped to state.
-
#status=(stat) ⇒ Object
This is to set the status, mapped to state.
-
#tags ⇒ Object
Tags, a little helper for the ticket tagging.
Instance Attribute Details
#prefix_options ⇒ Object
Returns the value of attribute prefix_options.
31 32 33 |
# File 'lib/provider/ticket.rb', line 31 def @prefix_options end |
Class Method Details
.search(project_id, options = {}, limit = 1000) ⇒ Object
Lighthouse limits us to a 100 ticket limit per page… Since the paging sucks…we probably want to store this rather than do a call each time
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/provider/ticket.rb', line 36 def self.search(project_id, = {}, limit = 1000) page = 1 tickets = ::Lighthouse::Ticket.find(:all, :params => {:project_id => project_id, :limit => 100, :page => page}) result = [] while tickets.length > 0 and page <= 3 #limit to page 3 since lighthouse is so slow... result += tickets.collect { |ticket| self.new ticket } page += 1 tickets = ::Lighthouse::Ticket.find(:all, :params => {:project_id => project_id, :limit => 100, :page => page}) end search_by_attribute(result, , limit) end |
Instance Method Details
#assignee ⇒ Object
Get the assigned person’s name
87 88 89 |
# File 'lib/provider/ticket.rb', line 87 def assignee self.assigned_user_name end |
#body=(bod) ⇒ Object
Set the body
102 103 104 105 |
# File 'lib/provider/ticket.rb', line 102 def body=(bod) @system_data[:client].body = nil super(bod) end |
#close(resolution = 'resolved') ⇒ Object
The closer
130 131 132 133 134 135 |
# File 'lib/provider/ticket.rb', line 130 def close(resolution = 'resolved') resolution = 'resolved' unless @@allowed_states.include?(resolution) ticket = ::Lighthouse::Ticket.find(self.id, :params => {:project_id => self.[:project_id]}) ticket.state = resolution ticket.save end |
#description ⇒ Object
Get the description, mapped to original_body
77 78 79 |
# File 'lib/provider/ticket.rb', line 77 def description self.original_body end |
#description=(desc) ⇒ Object
Set the description, mapped to body, which actually does a comment
82 83 84 |
# File 'lib/provider/ticket.rb', line 82 def description=(desc) self.body = desc end |
#id ⇒ Object
This is to get the ticket id We can’t set ids, so there’s no ‘id=’ method.
50 51 52 |
# File 'lib/provider/ticket.rb', line 50 def id @system_data[:client].number end |
#project_id ⇒ Object
Get the project id
97 98 99 |
# File 'lib/provider/ticket.rb', line 97 def project_id [:project_id] end |
#requestor ⇒ Object
Get the requestor’s name
92 93 94 |
# File 'lib/provider/ticket.rb', line 92 def requestor self.creator_name end |
#resolution ⇒ Object
Get the resolution, mapped to latest_body
66 67 68 |
# File 'lib/provider/ticket.rb', line 66 def resolution self.latest_body end |
#resolution=(res) ⇒ Object
Set the resolution…also sets state to resolved
71 72 73 74 |
# File 'lib/provider/ticket.rb', line 71 def resolution=(res) state = 'resolved' self.body = res end |
#save ⇒ Object
Gotta unset the body attribute…otherwise every save ends up using that body
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/provider/ticket.rb', line 117 def save # self.tag = @tags.reduce([]) do |mem, t| # t = "\"#{t}\"" if t.include?(' ') # mem << t # end.join(' ') if @tags @system_data[:client].attributes.delete('versions') result = super body = nil @system_data[:client].body = nil result end |
#status ⇒ Object
This is to get the status, mapped to state
55 56 57 |
# File 'lib/provider/ticket.rb', line 55 def status state end |
#status=(stat) ⇒ Object
This is to set the status, mapped to state
60 61 62 63 |
# File 'lib/provider/ticket.rb', line 60 def status=(stat) stat = state unless @@allowed_states.include?(stat) self.state = stat end |
#tags ⇒ Object
Tags, a little helper for the ticket tagging
108 109 110 111 112 113 114 |
# File 'lib/provider/ticket.rb', line 108 def return @tags if @tags tagz = self.tag.split(/([\w\d]+)|"([\w \d]+)"/) tagz.delete(' ') tagz.delete('') @tags = tagz end |