Skip to content

Commit

Permalink
Merge pull request #5 from captaincontrat/feature/add_meeting_endpoint
Browse files Browse the repository at this point in the history
Create meeting request
  • Loading branch information
Chavret authored May 5, 2022
2 parents 30726d4 + 366082d commit 97bd450
Show file tree
Hide file tree
Showing 8 changed files with 629 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/hubspot-api-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
require 'hubspot/subscription'
require 'hubspot/oauth'
require 'hubspot/file'
require 'hubspot/meeting'

module Hubspot
def self.configure(config={})
Expand Down
44 changes: 44 additions & 0 deletions lib/hubspot/meeting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require 'hubspot/utils'

module Hubspot
class Meeting
#
# HubSpot Meeting API
#
# {https://developers.hubspot.com/docs/api/crm/meetings}
#
CREATE_MEETING_PATH = '/crm/v3/objects/meetings'
MEETING_PATH = '/crm/v3/objects/meetings/:meeting_id'
ASSOCIATE_MEETING_PATH = '/crm/v3/objects/meetings/:meeting_id/associations/Contact/:contact_id/meeting_event_to_contact'

class << self
def create!(owner_id, meeting_title, meeting_body, start_date_time, end_date_time)
body = {
properties: {
hs_timestamp: DateTime.now.strftime('%Q'),
hubspot_owner_id: owner_id,
hs_meeting_title: meeting_title,
hs_meeting_body: meeting_body,
hs_meeting_start_time: start_date_time.is_a?(DateTime) ? start_date_time.strftime('%Q') : start_date_time,
hs_meeting_end_time: end_date_time.is_a?(DateTime) ? end_date_time.strftime('%Q') : end_date_time,
hs_meeting_outcome: 'SCHEDULED'
}
}
response = Hubspot::Connection.post_json(CREATE_MEETING_PATH, params: {}, body: body)
HashWithIndifferentAccess.new(response)
end

def destroy!(meeting_id)
Hubspot::Connection.delete_json(MEETING_PATH, {meeting_id: meeting_id})
end

def associate!(meeting_id, contact_id)
Hubspot::Connection.put_json(ASSOCIATE_MEETING_PATH,
params: {
meeting_id: meeting_id,
contact_id: contact_id
})
end
end
end
end
76 changes: 76 additions & 0 deletions spec/fixtures/vcr_cassettes/meeting.yml

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

216 changes: 216 additions & 0 deletions spec/fixtures/vcr_cassettes/meeting_associate.yml

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

Loading

0 comments on commit 97bd450

Please sign in to comment.