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.
19 20 21 22 |
# File 'lib/hubspot/ticket.rb', line 19 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.
17 18 19 |
# File 'lib/hubspot/ticket.rb', line 17 def id @id end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
17 18 19 |
# File 'lib/hubspot/ticket.rb', line 17 def properties @properties end |
Class Method Details
.create!(params = {}, associations: []) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/hubspot/ticket.rb', line 25 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
38 39 40 41 |
# File 'lib/hubspot/ticket.rb', line 38 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
32 33 34 35 36 |
# File 'lib/hubspot/ticket.rb', line 32 def update!(id, properties = {}) request = { properties: properties } response = Hubspot::Connection.patch_json(TICKET_PATH, params: { ticket_id: id }, body: request) new(response) end |