Skip to content

Commit

Permalink
add ticket_properties.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Yves committed Nov 7, 2024
1 parent fd464db commit 3aeb59d
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/hubspot-api-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
require 'hubspot/file'
require 'hubspot/meeting'
require 'hubspot/ticket'
require 'hubspot/ticket_properties'
require 'hubspot/task'

module Hubspot
Expand Down
10 changes: 10 additions & 0 deletions lib/hubspot/ticket_properties.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Hubspot
class TicketProperties < Properties
CREATE_PROPERTY_PATH = '/crm/v3/properties/ticket'
class << self
def create!(params={})
superclass.create!(CREATE_PROPERTY_PATH, params)
end
end
end
end
77 changes: 77 additions & 0 deletions spec/fixtures/vcr_cassettes/ticket_create_property.yml

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

41 changes: 41 additions & 0 deletions spec/lib/hubspot/ticket_properties_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
describe Hubspot::TicketProperties do
describe '.create' do
context 'with no valid parameters' do
it 'should return nil' do
VCR.use_cassette 'ticket_fail_to_create_property' do
expect(Hubspot::TicketProperties.create!({})).to be(nil)
end
end
end

context 'with all valid parameters' do
let(:params) do
{
'name' => 'my_new_property',
'label' => 'This is my new property',
'description' => 'How much money do you have?',
'groupName' => 'ticketinformation',
'type' => 'string',
'fieldType' => 'text',
'hidden' => false,
'deleted' => false,
'displayOrder' => 0,
'formField' => true,
'readOnlyValue' => false,
'readOnlyDefinition' => false,
'mutableDefinitionNotDeletable' => false,
'calculated' => false,
'externalOptions' => false,
'displayMode' => 'current_value'
}
end

it 'should return the valid parameters' do
VCR.use_cassette 'ticket_create_property' do
response = Hubspot::TicketProperties.create!(params)
expect(Hubspot::TicketProperties.same?(params, response.compact.except("options"))).to be true
end
end
end
end
end

0 comments on commit 3aeb59d

Please sign in to comment.