Class: TicketSharing::Ticket
- Inherits:
-
Base
- Object
- Base
- TicketSharing::Ticket
show all
- Defined in:
- lib/ticket_sharing/ticket.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#as_json, field_list, #field_list, fields, first_ancestor, #initialize, #to_json
Instance Attribute Details
#agreement ⇒ Object
Returns the value of attribute agreement.
14
15
16
|
# File 'lib/ticket_sharing/ticket.rb', line 14
def agreement
@agreement
end
|
#response ⇒ Object
Returns the value of attribute response.
15
16
17
|
# File 'lib/ticket_sharing/ticket.rb', line 15
def response
@response
end
|
Class Method Details
.parse(json) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/ticket_sharing/ticket.rb', line 17
def self.parse(json)
attributes = JsonSupport.decode(json)
ticket = new(attributes)
if ticket.requester
ticket.requester = Actor.new(ticket.requester)
end
if ticket.current_actor
ticket.current_actor = Actor.new(ticket.current_actor)
end
if ticket.
ticket. = ticket..map { || .new() }
end
ticket
end
|
Instance Method Details
41
42
43
|
# File 'lib/ticket_sharing/ticket.rb', line 41
def
||= []
end
|
#relative_url ⇒ Object
68
69
70
|
# File 'lib/ticket_sharing/ticket.rb', line 68
def relative_url
"/tickets/#{uuid}"
end
|
#requested_at=(val) ⇒ Object
TSTODO make all of these setters behave this way, not like they do in parse
37
38
39
|
# File 'lib/ticket_sharing/ticket.rb', line 37
def requested_at=(val)
@requested_at = TicketSharing::Time.new(val)
end
|
#send_to(url) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/ticket_sharing/ticket.rb', line 45
def send_to(url)
raise "Agreement not present" unless agreement
client = Client.new(url, agreement.authentication_token)
@response = client.post(relative_url, self.to_json)
@response.status
end
|
#unshare(base_url) ⇒ Object
61
62
63
64
65
66
|
# File 'lib/ticket_sharing/ticket.rb', line 61
def unshare(base_url)
client = Client.new(base_url, agreement.authentication_token)
@response = client.delete(relative_url)
@response.status
end
|
#update_partner(url) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/ticket_sharing/ticket.rb', line 54
def update_partner(url)
client = Client.new(url, agreement.authentication_token)
@response = client.put(relative_url, self.to_json)
@response.status
end
|