Skip to content

Commit

Permalink
Feature: Add default properties for tickets (#25)
Browse files Browse the repository at this point in the history
* add default properties for ticket

* linting + update history.md
  • Loading branch information
Trosss authored Nov 13, 2024
1 parent 45531e9 commit 820b9ac
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
4 changes: 4 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.17.1

* Add default properties for Ticket#find

## 0.17.0

* Add various Ticket endpoints (#create!, #update!, #find)
Expand Down
2 changes: 1 addition & 1 deletion hubspot-api-ruby.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "hubspot-api-ruby"
s.version = "0.17.0"
s.version = "0.17.1"
s.require_paths = ["lib"]
s.authors = ["Jonathan"]
s.email = ["jonathan@hoggo.com"]
Expand Down
3 changes: 1 addition & 2 deletions lib/hubspot/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def create!(params = {}, ticket_id: nil)
end

def find(task_id, properties = DEFAULT_TASK_FIELDS)
response = Hubspot::Connection.get_json(TASK_PATH, { task_id: task_id,
properties: properties })
response = Hubspot::Connection.get_json(TASK_PATH, task_id: task_id, properties:)
new(response)
end
end
Expand Down
6 changes: 4 additions & 2 deletions lib/hubspot/ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module Hubspot
class Ticket
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'

attr_reader :properties, :id

Expand Down Expand Up @@ -53,8 +55,8 @@ def update!(id, properties = {})
new(response)
end

def find(ticket_id)
response = Hubspot::Connection.get_json(TICKET_PATH, { ticket_id: ticket_id })
def find(ticket_id, properties = DEFAULT_TICKET_FIELDS)
response = Hubspot::Connection.get_json(TICKET_PATH, ticket_id: ticket_id, properties:)
new(response)
end
end
Expand Down
36 changes: 18 additions & 18 deletions spec/fixtures/vcr_cassettes/ticket_find.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/lib/hubspot/ticket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
VCR.use_cassette 'ticket' do
expect(new_ticket.id).not_to be_nil
expect(new_ticket.properties[:subject]).to eq('test ticket')
expect(new_ticket.properties[:hubspot_owner_id]).to be_nil
end
end
end
Expand Down

0 comments on commit 820b9ac

Please sign in to comment.