Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/test/tmp
/test/version_tmp
/tmp
/.vscode/

# Environment variables
.env
Expand Down
4 changes: 4 additions & 0 deletions lib/dialpad.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ class APIError < Error; end
require 'dialpad/call_center'
require 'dialpad/contact'
require 'dialpad/department'
require 'dialpad/sms'
require 'dialpad/meeting'
require 'dialpad/recording_sharelink'
require 'dialpad/subscriptions/call_event'
require 'dialpad/subscriptions/contact_event'
require 'dialpad/subscriptions/sms_event'
require 'dialpad/user'
require 'dialpad/websocket'

Expand Down
67 changes: 67 additions & 0 deletions lib/dialpad/meeting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module Dialpad
class Meeting < DialpadObject
class RequiredAttributeError < Dialpad::DialpadObject::RequiredAttributeError; end

ATTRIBUTES = %i(
call_out
dial_in_number
duration
end_datetime
id
instance_id
is_moderated
meeting_type
meeting_url
organizer_pin
participant_pin
participants_info
recurrence
recurrence_end_date
start_datetime
timezone
title
).freeze

class << self
include Validations

# https://developers.dialpad.com/reference/meetingsget
def retrieve(scheduled_conference_id = nil)
validate_required_attribute(id, "ID")

response = Dialpad.client.get("meetings/#{scheduled_conference_id}")
new(response.body)
end

# https://developers.dialpad.com/reference/meetingslist
def list(params = {})
response = Dialpad.client.get('meetings', params)
paginated_response_from(response)
end

# https://developers.dialpad.com/reference/meetingscreate
def create(attributes = {})
validate_required_attributes(attributes, %i(end_datetime meeting_type start_datetime title user_id))

response = Dialpad.client.post('meetings', attributes)
new(response.body)
end

# https://developers.dialpad.com/reference/meetingsupdate
def update(scheduled_conference_id = nil, attributes = {})
validate_required_attributes(attributes, %i(end_datetime meeting_type start_datetime title user_id))

response = Dialpad.client.put("meetings/#{scheduled_conference_id}", attributes)
new(response.body)
end

# https://developers.dialpad.com/reference/meetingsdelete
def destroy(scheduled_conference_id = nil)
validate_required_attribute(scheduled_conference_id, "Scheduled Conference ID")

response = Dialpad.client.delete("meetings/#{scheduled_conference_id}")
new(response.body)
end
end
end
end
56 changes: 56 additions & 0 deletions lib/dialpad/recording_sharelink.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module Dialpad
class RecordingSharelink < DialpadObject
class RequiredAttributeError < Dialpad::DialpadObject::RequiredAttributeError; end

ATTRIBUTES = %i(
access_link
call_id
created_by_id
date_added
id
item_id
privacy
type
).freeze

# privacy: (admin company owner public)
# type: (admincallrecording callrecording voicemail)

class << self
include Validations

# https://developers.dialpad.com/reference/recording_share_linkget
def retrieve(id = nil)
validate_required_attribute(id, "ID")

response = Dialpad.client.get("recordingsharelink/#{id}")
new(response.body)
end

# https://developers.dialpad.com/reference/contactscreate
def create(attributes = {})
validate_required_attributes(attributes, %i(recording_id recording_type))

response = Dialpad.client.post('recordingsharelink', attributes)
new(response.body)
end

# https://developers.dialpad.com/reference/recording_share_linkupdate
def update(id = nil, attributes = {})
validate_required_attribute(id, "ID")
validate_required_attributes(attributes, %i(privacy))

response = Dialpad.client.put("recordingsharelink/#{id}", attributes)
new(response.body)
end

# https://developers.dialpad.com/reference/recording_share_linkdelete
def destroy(id = nil)
validate_required_attribute(id, "ID")

response = Dialpad.client.delete("recordingsharelink/#{id}")
new(response.body)
end
end
end
end
55 changes: 55 additions & 0 deletions lib/dialpad/sms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module Dialpad
class Sms < DialpadObject
class RequiredAttributeError < Dialpad::DialpadObject::RequiredAttributeError; end

ATTRIBUTES = %i(
contact
contact_id
created_date
device_type
direction
event_timestamp
from_number
id
is_internal
message_delivery_result
message_status
mms
mms_url
sender_id
target
text
text_content
to_number
).freeze

def contact_id
attributes[:contact_id] || contact && contact[:id]
end

def contact
attributes[:contact]
end

class << self
# https://developers.dialpad.com/reference/smssend

# Attributes:
#
# channel_hashtag: string | null
# from_number: string | null
# infer_country_code: boolean | null (Defaults to false)
# media: string | null (Base64-encoded media attachment (will cause the message to be sent as MMS). (Max 500 KiB raw file size))
# sender_group_id: int64 | null
# sender_group_type: string | null, Allowed: (callcenter, department, office)
# text: string | null
# to_numbers: array of strings | null
# user_id: int64 | null

def send(attributes = {})
response = Dialpad.client.post('sms', attributes)
new(response.body)
end
end
end
end
70 changes: 70 additions & 0 deletions lib/dialpad/subscriptions/sms_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module Dialpad
module Subscriptions
class SmsEvent < DialpadObject
class RequiredAttributeError < Dialpad::DialpadObject::RequiredAttributeError; end

ATTRIBUTES = %i(
direction
enabled
id
include_internal
status
target_id
target_type
webhook
websocket
).freeze

# target_type is one of (callcenter callrouter channel coachinggroup coachingteam department office room staffgroup unknown user)
# direction is one of (all inbound outbound)

# Response might contain webhook or websocket object
def webhook
attributes[:webhook]
end

def websocket
attributes[:websocket]
end

class << self
include Validations

# https://developers.dialpad.com/reference/webhook_sms_event_subscriptionget
def retrieve(id = nil)
validate_required_attribute(id, "ID")
response = Dialpad.client.get("subscriptions/sms/#{id}")
new(response.body)
end

# https://developers.dialpad.com/reference/webhook_sms_event_subscriptionlist
def list(params = {})
response = Dialpad.client.get('subscriptions/sms', params)
paginated_response_from(response)
end

# https://developers.dialpad.com/reference/webhook_sms_event_subscriptioncreate
def create(attributes = {})
validate_required_attributes(attributes, [:webhook_id])

response = Dialpad.client.post('subscriptions/sms', attributes)
new(response.body)
end

# https://developers.dialpad.com/reference/webhook_sms_event_subscriptionupdate
def update(id = nil, attributes = {})
response = Dialpad.client.patch("subscriptions/sms/#{id}", attributes)
new(response.body)
end

# https://developers.dialpad.com/reference/webhook_sms_event_subscriptiondelete
def destroy(id = nil)
validate_required_attribute(id, "ID")

response = Dialpad.client.delete("subscriptions/sms/#{id}")
new(response.body)
end
end
end
end
end
Loading
Loading