Class: TicketSharing::Ticket
Instance Attribute Summary collapse
-
#agreement ⇒ Object
Returns the value of attribute agreement.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #comments ⇒ Object
- #relative_url ⇒ Object
-
#requested_at=(val) ⇒ Object
TSTODO make all of these setters behave this way, not like they do in parse.
- #send_to(url) ⇒ Object
- #unshare(base_url) ⇒ Object
- #update_partner(url) ⇒ Object
Methods inherited from Base
#as_json, field_list, #field_list, fields, first_ancestor, #initialize, #to_json
Constructor Details
This class inherits a constructor from TicketSharing::Base
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 (readonly)
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.comments ticket.comments = ticket.comments.map { |comment| Comment.new(comment) } end ticket end |
Instance Method Details
#comments ⇒ Object
41 42 43 |
# File 'lib/ticket_sharing/ticket.rb', line 41 def comments @comments ||= [] 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 |