Class: Hubspot::Ticket
- Inherits:
-
Object
- Object
- Hubspot::Ticket
- Defined in:
- lib/hubspot/ticket.rb
Overview
HubSpot Tickets API
https://developers.hubspot.com/beta-docs/guides/api/crm/objects/tickets
Constant Summary collapse
- TICKETS_PATH =
'/crm/v3/objects/tickets'
- TICKET_PATH =
'/crm/v3/objects/tickets/:ticket_id'
- DEFAULT_TICKET_FIELDS =
'content,createdate,hs_lastmodifieddate,hs_object_id,hs_pipeline,hs_pipeline_stage,'\ 'hs_ticket_category,hs_ticket_priority,hubspot_owner_id,subject'
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Class Method Summary collapse
- .create!(params = {}, associations: []) ⇒ Object
- .find(ticket_id, properties = DEFAULT_TICKET_FIELDS) ⇒ Object
- .update!(id, properties = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(response_hash) ⇒ Ticket
constructor
A new instance of Ticket.
Constructor Details
#initialize(response_hash) ⇒ Ticket
Returns a new instance of Ticket.
17 18 19 20 |
# File 'lib/hubspot/ticket.rb', line 17 def initialize(response_hash) @id = response_hash['id'] @properties = response_hash['properties'].deep_symbolize_keys end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
15 16 17 |
# File 'lib/hubspot/ticket.rb', line 15 def id @id end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
15 16 17 |
# File 'lib/hubspot/ticket.rb', line 15 def properties @properties end |
Class Method Details
.create!(params = {}, associations: []) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/hubspot/ticket.rb', line 23 def create!(params = {}, associations: []) associations_hash = { associations: } post_data = associations_hash.merge({ properties: params }) response = Hubspot::Connection.post_json(TICKETS_PATH, params: {}, body: post_data) new(response) end |
.find(ticket_id, properties = DEFAULT_TICKET_FIELDS) ⇒ Object
36 37 38 39 |
# File 'lib/hubspot/ticket.rb', line 36 def find(ticket_id, properties = DEFAULT_TICKET_FIELDS) response = Hubspot::Connection.get_json(TICKET_PATH, ticket_id: ticket_id, properties:) new(response) end |
.update!(id, properties = {}) ⇒ Object
30 31 32 33 34 |
# File 'lib/hubspot/ticket.rb', line 30 def update!(id, properties = {}) request = { properties: properties } response = Hubspot::Connection.patch_json(TICKET_PATH, params: { ticket_id: id }, body: request) new(response) end |