Class: VoiceML::ConversationsV1ServiceScopeResource

Inherits:
Object
  • Object
show all
Defined in:
lib/voiceml/resources/conversations_v1.rb

Overview

============================================================================

Phase 4 — /v1/Services/ChatServiceSid/... — 15 sub-resource families, 48 ops. Scoped via client.conversations_v1.services.scope(IS_sid). Flat method style matches the rest of conversations_v1.

Constant Summary collapse

CONVERSATION_FIELDS =
{
  'FriendlyName' => :friendly_name,
  'UniqueName' => :unique_name,
  'MessagingServiceSid' => :messaging_service_sid,
  'Attributes' => :attributes,
  'State' => :state,
  'Timers.Inactive' => :timers_inactive,
  'Timers.Closed' => :timers_closed
}.freeze
CONVERSATION_UPDATE_FIELDS =
{
  'FriendlyName' => :friendly_name,
  'UniqueName' => :unique_name,
  'Attributes' => :attributes,
  'State' => :state,
  'Timers.Inactive' => :timers_inactive,
  'Timers.Closed' => :timers_closed
}.freeze
MESSAGE_FIELDS =
{
  'Author' => :author,
  'Body' => :body,
  'Attributes' => :attributes,
  'ContentSid' => :content_sid
}.freeze
MESSAGE_UPDATE_FIELDS =
{
  'Author' => :author,
  'Body' => :body,
  'Attributes' => :attributes
}.freeze
PARTICIPANT_FIELDS =
{
  'Identity' => :identity,
  'Attributes' => :attributes,
  'RoleSid' => :role_sid,
  'MessagingBinding.Address' => :messaging_binding_address,
  'MessagingBinding.ProxyAddress' => :messaging_binding_proxy_address,
  'MessagingBinding.ProjectedAddress' => :messaging_binding_projected_address
}.freeze
PARTICIPANT_UPDATE_FIELDS =
{
  'Attributes' => :attributes,
  'RoleSid' => :role_sid
}.freeze
WEBHOOK_FIELDS =
{
  'Target' => :target,
  'Configuration.Url' => :configuration_url,
  'Configuration.Method' => :configuration_method,
  'Configuration.FlowSid' => :configuration_flow_sid
}.freeze
WEBHOOK_UPDATE_FIELDS =
{
  'Configuration.Url' => :configuration_url,
  'Configuration.Method' => :configuration_method,
  'Configuration.FlowSid' => :configuration_flow_sid
}.freeze
USER_FIELDS =
{
  'Identity' => :identity,
  'FriendlyName' => :friendly_name,
  'Attributes' => :attributes,
  'RoleSid' => :role_sid
}.freeze
USER_UPDATE_FIELDS =
{
  'FriendlyName' => :friendly_name,
  'Attributes' => :attributes,
  'RoleSid' => :role_sid
}.freeze
CONV_WITH_PARTICIPANTS_FIELDS =
{
  'FriendlyName' => :friendly_name,
  'UniqueName' => :unique_name,
  'MessagingServiceSid' => :messaging_service_sid,
  'Attributes' => :attributes,
  'State' => :state,
  'Timers.Inactive' => :timers_inactive,
  'Timers.Closed' => :timers_closed,
  'Participant' => :participant
}.freeze
CONFIG_UPDATE_FIELDS =
{
  'DefaultChatServiceRoleSid' => :default_chat_service_role_sid,
  'DefaultConversationCreatorRoleSid' => :default_conversation_creator_role_sid,
  'DefaultConversationRoleSid' => :default_conversation_role_sid,
  'ReachabilityEnabled' => :reachability_enabled
}.freeze
NOTIFICATION_UPDATE_FIELDS =
{
  'LogEnabled' => :log_enabled,
  'NewMessage.Enabled' => :new_message_enabled,
  'NewMessage.Template' => :new_message_template,
  'NewMessage.Sound' => :new_message_sound,
  'NewMessage.BadgeCountEnabled' => :new_message_badge_count_enabled,
  'NewMessage.WithMedia.Enabled' => :new_message_with_media_enabled,
  'NewMessage.WithMedia.Template' => :new_message_with_media_template,
  'AddedToConversation.Enabled' => :added_to_conversation_enabled,
  'AddedToConversation.Template' => :added_to_conversation_template,
  'AddedToConversation.Sound' => :added_to_conversation_sound,
  'RemovedFromConversation.Enabled' => :removed_from_conversation_enabled,
  'RemovedFromConversation.Template' => :removed_from_conversation_template,
  'RemovedFromConversation.Sound' => :removed_from_conversation_sound
}.freeze
WEBHOOK_CONFIG_UPDATE_FIELDS =
{
  'PreWebhookUrl' => :pre_webhook_url,
  'PostWebhookUrl' => :post_webhook_url,
  'Method' => :method,
  'Filters' => :filters
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport, chat_service_sid) ⇒ ConversationsV1ServiceScopeResource

Returns a new instance of ConversationsV1ServiceScopeResource.



834
835
836
837
# File 'lib/voiceml/resources/conversations_v1.rb', line 834

def initialize(transport, chat_service_sid)
  @transport = transport
  @chat_service_sid = chat_service_sid
end

Instance Attribute Details

#chat_service_sidObject (readonly)

Returns the value of attribute chat_service_sid.



832
833
834
# File 'lib/voiceml/resources/conversations_v1.rb', line 832

def chat_service_sid
  @chat_service_sid
end

Instance Method Details

#create_conversation(**kwargs) ⇒ Object



848
849
850
851
852
# File 'lib/voiceml/resources/conversations_v1.rb', line 848

def create_conversation(**kwargs)
  ConversationsV1ServiceConversation.from_hash(
    @transport.request(:post, conv_root, form: build_form(CONVERSATION_FIELDS, kwargs))
  )
end

#create_conversation_with_participants(**kwargs) ⇒ Object

--- ServiceConversationWithParticipants (create only) ---



994
995
996
997
998
999
# File 'lib/voiceml/resources/conversations_v1.rb', line 994

def create_conversation_with_participants(**kwargs)
  ConversationsV1ServiceConversationWithParticipants.from_hash(
    @transport.request(:post, "#{svc_root}/ConversationWithParticipants",
                       form: build_form(CONV_WITH_PARTICIPANTS_FIELDS, kwargs))
  )
end

#create_message(conversation_sid, **kwargs) ⇒ Object



881
882
883
884
885
886
# File 'lib/voiceml/resources/conversations_v1.rb', line 881

def create_message(conversation_sid, **kwargs)
  ConversationsV1ServiceConversationMessage.from_hash(
    @transport.request(:post, "#{conv_root}/#{conversation_sid}/Messages",
                       form: build_form(MESSAGE_FIELDS, kwargs))
  )
end

#create_participant(conversation_sid, **kwargs) ⇒ Object



933
934
935
936
937
938
# File 'lib/voiceml/resources/conversations_v1.rb', line 933

def create_participant(conversation_sid, **kwargs)
  ConversationsV1ServiceConversationParticipant.from_hash(
    @transport.request(:post, "#{conv_root}/#{conversation_sid}/Participants",
                       form: build_form(PARTICIPANT_FIELDS, kwargs))
  )
end

#create_role(friendly_name:, type:, permission:) ⇒ Object



1030
1031
1032
1033
1034
1035
# File 'lib/voiceml/resources/conversations_v1.rb', line 1030

def create_role(friendly_name:, type:, permission:)
  form = { 'FriendlyName' => friendly_name, 'Type' => type, 'Permission' => Array(permission) }
  ConversationsV1ServiceRole.from_hash(
    @transport.request(:post, "#{svc_root}/Roles", form: form)
  )
end

#create_user(identity:, friendly_name: nil, attributes: nil, role_sid: nil) ⇒ Object



1064
1065
1066
1067
1068
1069
1070
# File 'lib/voiceml/resources/conversations_v1.rb', line 1064

def create_user(identity:, friendly_name: nil, attributes: nil, role_sid: nil)
  kwargs = { identity: identity, friendly_name: friendly_name,
             attributes: attributes, role_sid: role_sid }
  ConversationsV1ServiceUser.from_hash(
    @transport.request(:post, "#{svc_root}/Users", form: build_form(USER_FIELDS, kwargs))
  )
end

#create_webhook(conversation_sid, target:, **kwargs) ⇒ Object



967
968
969
970
971
972
973
# File 'lib/voiceml/resources/conversations_v1.rb', line 967

def create_webhook(conversation_sid, target:, **kwargs)
  kwargs[:target] = target
  ConversationsV1ServiceConversationScopedWebhook.from_hash(
    @transport.request(:post, "#{conv_root}/#{conversation_sid}/Webhooks",
                       form: build_form(WEBHOOK_FIELDS, kwargs))
  )
end

#delete_binding(sid) ⇒ Object



1107
1108
1109
1110
# File 'lib/voiceml/resources/conversations_v1.rb', line 1107

def delete_binding(sid)
  @transport.request(:delete, "#{svc_root}/Bindings/#{sid}")
  nil
end

#delete_conversation(conversation_sid) ⇒ Object



867
868
869
870
# File 'lib/voiceml/resources/conversations_v1.rb', line 867

def delete_conversation(conversation_sid)
  @transport.request(:delete, "#{conv_root}/#{conversation_sid}")
  nil
end

#delete_message(conversation_sid, message_sid) ⇒ Object



901
902
903
904
# File 'lib/voiceml/resources/conversations_v1.rb', line 901

def delete_message(conversation_sid, message_sid)
  @transport.request(:delete, "#{conv_root}/#{conversation_sid}/Messages/#{message_sid}")
  nil
end

#delete_participant(conversation_sid, participant_sid) ⇒ Object



953
954
955
956
# File 'lib/voiceml/resources/conversations_v1.rb', line 953

def delete_participant(conversation_sid, participant_sid)
  @transport.request(:delete, "#{conv_root}/#{conversation_sid}/Participants/#{participant_sid}")
  nil
end

#delete_role(role_sid) ⇒ Object



1050
1051
1052
1053
# File 'lib/voiceml/resources/conversations_v1.rb', line 1050

def delete_role(role_sid)
  @transport.request(:delete, "#{svc_root}/Roles/#{role_sid}")
  nil
end

#delete_user(user_sid) ⇒ Object



1085
1086
1087
1088
# File 'lib/voiceml/resources/conversations_v1.rb', line 1085

def delete_user(user_sid)
  @transport.request(:delete, "#{svc_root}/Users/#{user_sid}")
  nil
end

#delete_webhook(conversation_sid, webhook_sid) ⇒ Object



988
989
990
991
# File 'lib/voiceml/resources/conversations_v1.rb', line 988

def delete_webhook(conversation_sid, webhook_sid)
  @transport.request(:delete, "#{conv_root}/#{conversation_sid}/Webhooks/#{webhook_sid}")
  nil
end

#fetch_binding(sid) ⇒ Object



1101
1102
1103
1104
1105
# File 'lib/voiceml/resources/conversations_v1.rb', line 1101

def fetch_binding(sid)
  ConversationsV1ServiceBinding.from_hash(
    @transport.request(:get, "#{svc_root}/Bindings/#{sid}")
  )
end

#fetch_configurationObject

--- ServiceConfiguration (fetch+update singleton) ---



1113
1114
1115
1116
1117
# File 'lib/voiceml/resources/conversations_v1.rb', line 1113

def fetch_configuration
  ConversationsV1ServiceConfiguration.from_hash(
    @transport.request(:get, "#{svc_root}/Configuration")
  )
end

#fetch_conversation(conversation_sid) ⇒ Object



854
855
856
857
858
# File 'lib/voiceml/resources/conversations_v1.rb', line 854

def fetch_conversation(conversation_sid)
  ConversationsV1ServiceConversation.from_hash(
    @transport.request(:get, "#{conv_root}/#{conversation_sid}")
  )
end

#fetch_message(conversation_sid, message_sid) ⇒ Object



888
889
890
891
892
# File 'lib/voiceml/resources/conversations_v1.rb', line 888

def fetch_message(conversation_sid, message_sid)
  ConversationsV1ServiceConversationMessage.from_hash(
    @transport.request(:get, "#{conv_root}/#{conversation_sid}/Messages/#{message_sid}")
  )
end

#fetch_message_receipt(conversation_sid, message_sid, sid) ⇒ Object



917
918
919
920
921
922
# File 'lib/voiceml/resources/conversations_v1.rb', line 917

def fetch_message_receipt(conversation_sid, message_sid, sid)
  ConversationsV1ServiceConversationMessageReceipt.from_hash(
    @transport.request(:get,
                       "#{conv_root}/#{conversation_sid}/Messages/#{message_sid}/Receipts/#{sid}")
  )
end

#fetch_notificationsObject

--- ServiceNotification (fetch+update singleton) ---



1127
1128
1129
1130
1131
# File 'lib/voiceml/resources/conversations_v1.rb', line 1127

def fetch_notifications
  ConversationsV1ServiceNotification.from_hash(
    @transport.request(:get, "#{svc_root}/Configuration/Notifications")
  )
end

#fetch_participant(conversation_sid, participant_sid) ⇒ Object



940
941
942
943
944
# File 'lib/voiceml/resources/conversations_v1.rb', line 940

def fetch_participant(conversation_sid, participant_sid)
  ConversationsV1ServiceConversationParticipant.from_hash(
    @transport.request(:get, "#{conv_root}/#{conversation_sid}/Participants/#{participant_sid}")
  )
end

#fetch_role(role_sid) ⇒ Object



1037
1038
1039
1040
1041
# File 'lib/voiceml/resources/conversations_v1.rb', line 1037

def fetch_role(role_sid)
  ConversationsV1ServiceRole.from_hash(
    @transport.request(:get, "#{svc_root}/Roles/#{role_sid}")
  )
end

#fetch_user(user_sid) ⇒ Object



1072
1073
1074
1075
1076
# File 'lib/voiceml/resources/conversations_v1.rb', line 1072

def fetch_user(user_sid)
  ConversationsV1ServiceUser.from_hash(
    @transport.request(:get, "#{svc_root}/Users/#{user_sid}")
  )
end

#fetch_webhook(conversation_sid, webhook_sid) ⇒ Object



975
976
977
978
979
# File 'lib/voiceml/resources/conversations_v1.rb', line 975

def fetch_webhook(conversation_sid, webhook_sid)
  ConversationsV1ServiceConversationScopedWebhook.from_hash(
    @transport.request(:get, "#{conv_root}/#{conversation_sid}/Webhooks/#{webhook_sid}")
  )
end

#fetch_webhook_configurationObject

--- ServiceWebhookConfiguration (fetch+update singleton) ---



1141
1142
1143
1144
1145
# File 'lib/voiceml/resources/conversations_v1.rb', line 1141

def fetch_webhook_configuration
  ConversationsV1ServiceWebhookConfiguration.from_hash(
    @transport.request(:get, "#{svc_root}/Configuration/Webhooks")
  )
end

#list_bindings(binding_type: nil, identity: nil, page_size: nil) ⇒ Object

--- ServiceBinding (list/fetch/delete only) ---



1091
1092
1093
1094
1095
1096
1097
1098
1099
# File 'lib/voiceml/resources/conversations_v1.rb', line 1091

def list_bindings(binding_type: nil, identity: nil, page_size: nil)
  params = {}
  params['BindingType'] = binding_type unless binding_type.nil?
  params['Identity']    = identity     unless identity.nil?
  params['PageSize']    = page_size    unless page_size.nil?
  ConversationsV1ServiceBindingList.new(
    @transport.request(:get, "#{svc_root}/Bindings", params: params)
  )
end

#list_conversations(page_size: nil) ⇒ Object

--- ServiceConversation (5 CRUD) ---



840
841
842
843
844
845
846
# File 'lib/voiceml/resources/conversations_v1.rb', line 840

def list_conversations(page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ServiceConversationList.new(
    @transport.request(:get, conv_root, params: params)
  )
end

#list_message_receipts(conversation_sid, message_sid, page_size: nil) ⇒ Object

--- ServiceConversationMessageReceipt (list+fetch only) ---



907
908
909
910
911
912
913
914
915
# File 'lib/voiceml/resources/conversations_v1.rb', line 907

def list_message_receipts(conversation_sid, message_sid, page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ServiceConversationMessageReceiptList.new(
    @transport.request(:get,
                       "#{conv_root}/#{conversation_sid}/Messages/#{message_sid}/Receipts",
                       params: params)
  )
end

#list_messages(conversation_sid, page_size: nil) ⇒ Object

--- ServiceConversationMessage (5 CRUD) ---



873
874
875
876
877
878
879
# File 'lib/voiceml/resources/conversations_v1.rb', line 873

def list_messages(conversation_sid, page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ServiceConversationMessageList.new(
    @transport.request(:get, "#{conv_root}/#{conversation_sid}/Messages", params: params)
  )
end

#list_participant_conversations(identity: nil, address: nil, page_size: nil) ⇒ Object

--- ServiceParticipantConversation (list only) ---



1002
1003
1004
1005
1006
1007
1008
1009
1010
# File 'lib/voiceml/resources/conversations_v1.rb', line 1002

def list_participant_conversations(identity: nil, address: nil, page_size: nil)
  params = {}
  params['Identity'] = identity unless identity.nil?
  params['Address']  = address  unless address.nil?
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ServiceParticipantConversationList.new(
    @transport.request(:get, "#{svc_root}/ParticipantConversations", params: params)
  )
end

#list_participants(conversation_sid, page_size: nil) ⇒ Object

--- ServiceConversationParticipant (5 CRUD) ---



925
926
927
928
929
930
931
# File 'lib/voiceml/resources/conversations_v1.rb', line 925

def list_participants(conversation_sid, page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ServiceConversationParticipantList.new(
    @transport.request(:get, "#{conv_root}/#{conversation_sid}/Participants", params: params)
  )
end

#list_roles(page_size: nil) ⇒ Object

--- ServiceRole (5 CRUD) ---



1022
1023
1024
1025
1026
1027
1028
# File 'lib/voiceml/resources/conversations_v1.rb', line 1022

def list_roles(page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ServiceRoleList.new(
    @transport.request(:get, "#{svc_root}/Roles", params: params)
  )
end

#list_user_conversations(user_sid, page_size: nil) ⇒ Object

--- ServiceUserConversation (list only, under Users/Sid/Conversations) ---



1013
1014
1015
1016
1017
1018
1019
# File 'lib/voiceml/resources/conversations_v1.rb', line 1013

def list_user_conversations(user_sid, page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ServiceUserConversationList.new(
    @transport.request(:get, "#{svc_root}/Users/#{user_sid}/Conversations", params: params)
  )
end

#list_users(page_size: nil) ⇒ Object

--- ServiceUser (5 CRUD) ---



1056
1057
1058
1059
1060
1061
1062
# File 'lib/voiceml/resources/conversations_v1.rb', line 1056

def list_users(page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ServiceUserList.new(
    @transport.request(:get, "#{svc_root}/Users", params: params)
  )
end

#list_webhooks(conversation_sid, page_size: nil) ⇒ Object

--- ServiceConversationScopedWebhook (5 CRUD) ---



959
960
961
962
963
964
965
# File 'lib/voiceml/resources/conversations_v1.rb', line 959

def list_webhooks(conversation_sid, page_size: nil)
  params = {}
  params['PageSize'] = page_size unless page_size.nil?
  ConversationsV1ServiceConversationScopedWebhookList.new(
    @transport.request(:get, "#{conv_root}/#{conversation_sid}/Webhooks", params: params)
  )
end

#update_configuration(**kwargs) ⇒ Object



1119
1120
1121
1122
1123
1124
# File 'lib/voiceml/resources/conversations_v1.rb', line 1119

def update_configuration(**kwargs)
  ConversationsV1ServiceConfiguration.from_hash(
    @transport.request(:post, "#{svc_root}/Configuration",
                       form: build_form(CONFIG_UPDATE_FIELDS, kwargs))
  )
end

#update_conversation(conversation_sid, **kwargs) ⇒ Object



860
861
862
863
864
865
# File 'lib/voiceml/resources/conversations_v1.rb', line 860

def update_conversation(conversation_sid, **kwargs)
  ConversationsV1ServiceConversation.from_hash(
    @transport.request(:post, "#{conv_root}/#{conversation_sid}",
                       form: build_form(CONVERSATION_UPDATE_FIELDS, kwargs))
  )
end

#update_message(conversation_sid, message_sid, **kwargs) ⇒ Object



894
895
896
897
898
899
# File 'lib/voiceml/resources/conversations_v1.rb', line 894

def update_message(conversation_sid, message_sid, **kwargs)
  ConversationsV1ServiceConversationMessage.from_hash(
    @transport.request(:post, "#{conv_root}/#{conversation_sid}/Messages/#{message_sid}",
                       form: build_form(MESSAGE_UPDATE_FIELDS, kwargs))
  )
end

#update_notifications(**kwargs) ⇒ Object



1133
1134
1135
1136
1137
1138
# File 'lib/voiceml/resources/conversations_v1.rb', line 1133

def update_notifications(**kwargs)
  ConversationsV1ServiceNotification.from_hash(
    @transport.request(:post, "#{svc_root}/Configuration/Notifications",
                       form: build_form(NOTIFICATION_UPDATE_FIELDS, kwargs))
  )
end

#update_participant(conversation_sid, participant_sid, **kwargs) ⇒ Object



946
947
948
949
950
951
# File 'lib/voiceml/resources/conversations_v1.rb', line 946

def update_participant(conversation_sid, participant_sid, **kwargs)
  ConversationsV1ServiceConversationParticipant.from_hash(
    @transport.request(:post, "#{conv_root}/#{conversation_sid}/Participants/#{participant_sid}",
                       form: build_form(PARTICIPANT_UPDATE_FIELDS, kwargs))
  )
end

#update_role(role_sid, permission:) ⇒ Object



1043
1044
1045
1046
1047
1048
# File 'lib/voiceml/resources/conversations_v1.rb', line 1043

def update_role(role_sid, permission:)
  form = { 'Permission' => Array(permission) }
  ConversationsV1ServiceRole.from_hash(
    @transport.request(:post, "#{svc_root}/Roles/#{role_sid}", form: form)
  )
end

#update_user(user_sid, **kwargs) ⇒ Object



1078
1079
1080
1081
1082
1083
# File 'lib/voiceml/resources/conversations_v1.rb', line 1078

def update_user(user_sid, **kwargs)
  ConversationsV1ServiceUser.from_hash(
    @transport.request(:post, "#{svc_root}/Users/#{user_sid}",
                       form: build_form(USER_UPDATE_FIELDS, kwargs))
  )
end

#update_webhook(conversation_sid, webhook_sid, **kwargs) ⇒ Object



981
982
983
984
985
986
# File 'lib/voiceml/resources/conversations_v1.rb', line 981

def update_webhook(conversation_sid, webhook_sid, **kwargs)
  ConversationsV1ServiceConversationScopedWebhook.from_hash(
    @transport.request(:post, "#{conv_root}/#{conversation_sid}/Webhooks/#{webhook_sid}",
                       form: build_form(WEBHOOK_UPDATE_FIELDS, kwargs))
  )
end

#update_webhook_configuration(**kwargs) ⇒ Object



1147
1148
1149
1150
1151
1152
# File 'lib/voiceml/resources/conversations_v1.rb', line 1147

def update_webhook_configuration(**kwargs)
  ConversationsV1ServiceWebhookConfiguration.from_hash(
    @transport.request(:post, "#{svc_root}/Configuration/Webhooks",
                       form: build_form(WEBHOOK_CONFIG_UPDATE_FIELDS, kwargs))
  )
end