Class: TicketAbstractorClient::Base::Ticket
- Inherits:
-
Object
- Object
- TicketAbstractorClient::Base::Ticket
- Defined in:
- lib/ticket_abstractor_client/base/ticket.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attachments ⇒ Object
readonly
Returns the value of attribute attachments.
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#communications_stack ⇒ Object
Returns the value of attribute communications_stack.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#project ⇒ Object
Returns the value of attribute project.
-
#status ⇒ Object
Returns the value of attribute status.
-
#ticket_id ⇒ Object
Returns the value of attribute ticket_id.
Instance Method Summary collapse
- #add_attachment(attachment) ⇒ Object
- #add_comment(comment) ⇒ Object
- #any_changes? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Ticket
constructor
A new instance of Ticket.
- #reset_changes! ⇒ Object
- #sync! ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Ticket
Returns a new instance of Ticket.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 7 def initialize(opts = {}) opts = opts.with_indifferent_access @ticket_id = opts[:ticket_id] @fields = opts.fetch(:fields, {}).with_indifferent_access @endpoint = opts[:endpoint] || raise(Errors::TicketArgumentError, 'Endpoint is not given') @project = opts[:project] @communications_stack = opts[:communications_stack] || [] @attachments ||= [] @comments ||= [] initialize_changes! mark_changes! end |
Instance Attribute Details
#attachments ⇒ Object (readonly)
Returns the value of attribute attachments.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 4 def @attachments end |
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 4 def changes @changes end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 4 def comments @comments end |
#communications_stack ⇒ Object
Returns the value of attribute communications_stack.
5 6 7 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 5 def communications_stack @communications_stack end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 5 def endpoint @endpoint end |
#fields ⇒ Object
Returns the value of attribute fields.
5 6 7 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 5 def fields @fields end |
#project ⇒ Object
Returns the value of attribute project.
5 6 7 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 5 def project @project end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 4 def status @status end |
#ticket_id ⇒ Object
Returns the value of attribute ticket_id.
5 6 7 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 5 def ticket_id @ticket_id end |
Instance Method Details
#add_attachment(attachment) ⇒ Object
20 21 22 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 20 def () self.class.not_implemented __method__ end |
#add_comment(comment) ⇒ Object
24 25 26 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 24 def add_comment(comment) self.class.not_implemented __method__ end |
#any_changes? ⇒ Boolean
28 29 30 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 28 def any_changes? @changes.values.any? { |value| value.is_a?(Fixnum) ? !value.zero? : value.present? } end |
#reset_changes! ⇒ Object
32 33 34 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 32 def reset_changes! initialize_changes! end |
#sync! ⇒ Object
42 43 44 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 42 def sync! self.class.not_implemented __method__ end |
#to_hash ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 46 def to_hash { ticket_id: self.ticket_id, status: self.status, updated_at: self.updated_at, fields: self.fields, comments: self.comments.map(&:to_hash), attachments: self..map(&:to_hash) } end |
#to_json ⇒ Object
57 58 59 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 57 def to_json to_hash.to_json end |
#updated_at ⇒ Object
61 62 63 |
# File 'lib/ticket_abstractor_client/base/ticket.rb', line 61 def updated_at self.class.not_implemented __method__ end |