signalwire_agents 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +79 -0
  3. data/bin/swaig-test +310 -0
  4. data/lib/signalwire_agents/agent/agent_base.rb +1171 -0
  5. data/lib/signalwire_agents/contexts/context_builder.rb +622 -0
  6. data/lib/signalwire_agents/datamap/data_map.rb +279 -0
  7. data/lib/signalwire_agents/logging.rb +92 -0
  8. data/lib/signalwire_agents/prefabs/concierge.rb +92 -0
  9. data/lib/signalwire_agents/prefabs/faq_bot.rb +67 -0
  10. data/lib/signalwire_agents/prefabs/info_gatherer.rb +79 -0
  11. data/lib/signalwire_agents/prefabs/receptionist.rb +74 -0
  12. data/lib/signalwire_agents/prefabs/survey.rb +75 -0
  13. data/lib/signalwire_agents/relay/action.rb +291 -0
  14. data/lib/signalwire_agents/relay/call.rb +523 -0
  15. data/lib/signalwire_agents/relay/client.rb +671 -0
  16. data/lib/signalwire_agents/relay/constants.rb +124 -0
  17. data/lib/signalwire_agents/relay/message.rb +137 -0
  18. data/lib/signalwire_agents/relay/relay_event.rb +670 -0
  19. data/lib/signalwire_agents/rest/http_client.rb +147 -0
  20. data/lib/signalwire_agents/rest/namespaces/addresses.rb +19 -0
  21. data/lib/signalwire_agents/rest/namespaces/calling.rb +179 -0
  22. data/lib/signalwire_agents/rest/namespaces/chat.rb +18 -0
  23. data/lib/signalwire_agents/rest/namespaces/compat.rb +229 -0
  24. data/lib/signalwire_agents/rest/namespaces/datasphere.rb +39 -0
  25. data/lib/signalwire_agents/rest/namespaces/fabric.rb +175 -0
  26. data/lib/signalwire_agents/rest/namespaces/imported_numbers.rb +18 -0
  27. data/lib/signalwire_agents/rest/namespaces/logs.rb +46 -0
  28. data/lib/signalwire_agents/rest/namespaces/lookup.rb +18 -0
  29. data/lib/signalwire_agents/rest/namespaces/mfa.rb +26 -0
  30. data/lib/signalwire_agents/rest/namespaces/number_groups.rb +32 -0
  31. data/lib/signalwire_agents/rest/namespaces/phone_numbers.rb +20 -0
  32. data/lib/signalwire_agents/rest/namespaces/project.rb +33 -0
  33. data/lib/signalwire_agents/rest/namespaces/pubsub.rb +18 -0
  34. data/lib/signalwire_agents/rest/namespaces/queues.rb +28 -0
  35. data/lib/signalwire_agents/rest/namespaces/recordings.rb +18 -0
  36. data/lib/signalwire_agents/rest/namespaces/registry.rb +67 -0
  37. data/lib/signalwire_agents/rest/namespaces/short_codes.rb +26 -0
  38. data/lib/signalwire_agents/rest/namespaces/sip_profile.rb +22 -0
  39. data/lib/signalwire_agents/rest/namespaces/verified_callers.rb +24 -0
  40. data/lib/signalwire_agents/rest/namespaces/video.rb +129 -0
  41. data/lib/signalwire_agents/rest/signalwire_client.rb +110 -0
  42. data/lib/signalwire_agents/security/session_manager.rb +124 -0
  43. data/lib/signalwire_agents/server/agent_server.rb +260 -0
  44. data/lib/signalwire_agents/skills/builtin/api_ninjas_trivia.rb +91 -0
  45. data/lib/signalwire_agents/skills/builtin/claude_skills.rb +92 -0
  46. data/lib/signalwire_agents/skills/builtin/custom_skills.rb +54 -0
  47. data/lib/signalwire_agents/skills/builtin/datasphere.rb +141 -0
  48. data/lib/signalwire_agents/skills/builtin/datasphere_serverless.rb +107 -0
  49. data/lib/signalwire_agents/skills/builtin/datetime.rb +97 -0
  50. data/lib/signalwire_agents/skills/builtin/google_maps.rb +168 -0
  51. data/lib/signalwire_agents/skills/builtin/info_gatherer.rb +189 -0
  52. data/lib/signalwire_agents/skills/builtin/joke.rb +65 -0
  53. data/lib/signalwire_agents/skills/builtin/math.rb +176 -0
  54. data/lib/signalwire_agents/skills/builtin/mcp_gateway.rb +121 -0
  55. data/lib/signalwire_agents/skills/builtin/native_vector_search.rb +116 -0
  56. data/lib/signalwire_agents/skills/builtin/play_background_file.rb +86 -0
  57. data/lib/signalwire_agents/skills/builtin/spider.rb +142 -0
  58. data/lib/signalwire_agents/skills/builtin/swml_transfer.rb +118 -0
  59. data/lib/signalwire_agents/skills/builtin/weather_api.rb +85 -0
  60. data/lib/signalwire_agents/skills/builtin/web_search.rb +123 -0
  61. data/lib/signalwire_agents/skills/builtin/wikipedia_search.rb +109 -0
  62. data/lib/signalwire_agents/skills/skill_base.rb +58 -0
  63. data/lib/signalwire_agents/skills/skill_manager.rb +85 -0
  64. data/lib/signalwire_agents/skills/skill_registry.rb +76 -0
  65. data/lib/signalwire_agents/swaig/function_result.rb +777 -0
  66. data/lib/signalwire_agents/swml/document.rb +84 -0
  67. data/lib/signalwire_agents/swml/schema.json +12250 -0
  68. data/lib/signalwire_agents/swml/schema.rb +81 -0
  69. data/lib/signalwire_agents/swml/service.rb +304 -0
  70. data/lib/signalwire_agents/version.rb +5 -0
  71. data/lib/signalwire_agents.rb +19 -0
  72. metadata +212 -0
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+ require 'json'
5
+ require 'uri'
6
+ require 'base64'
7
+
8
+ module SignalWireAgents
9
+ module REST
10
+ # Raised when the SignalWire REST API returns a non-2xx response.
11
+ class SignalWireRestError < StandardError
12
+ attr_reader :status_code, :body, :url, :method_name
13
+
14
+ def initialize(status_code, body, url, method_name = 'GET')
15
+ @status_code = status_code
16
+ @body = body
17
+ @url = url
18
+ @method_name = method_name
19
+ super("#{method_name} #{url} returned #{status_code}: #{body}")
20
+ end
21
+ end
22
+
23
+ # Thin wrapper around Net::HTTP with Basic Auth and JSON handling.
24
+ class HttpClient
25
+ attr_reader :base_url
26
+
27
+ def initialize(project_id, token, space)
28
+ host = space.include?('.') ? space : "#{space}.signalwire.com"
29
+ @base_url = "https://#{host}"
30
+ @project_id = project_id
31
+ @token = token
32
+ @auth_header = 'Basic ' + Base64.strict_encode64("#{project_id}:#{token}")
33
+ end
34
+
35
+ def get(path, params = nil)
36
+ _request('GET', path, params: params)
37
+ end
38
+
39
+ def post(path, body = nil, params: nil)
40
+ _request('POST', path, body: body, params: params)
41
+ end
42
+
43
+ def put(path, body = nil)
44
+ _request('PUT', path, body: body)
45
+ end
46
+
47
+ def patch(path, body = nil)
48
+ _request('PATCH', path, body: body)
49
+ end
50
+
51
+ def delete(path)
52
+ _request('DELETE', path)
53
+ end
54
+
55
+ private
56
+
57
+ def _request(method, path, body: nil, params: nil)
58
+ uri = URI("#{@base_url}#{path}")
59
+ if params && !params.empty?
60
+ uri.query = URI.encode_www_form(params)
61
+ end
62
+
63
+ req = case method
64
+ when 'GET' then Net::HTTP::Get.new(uri)
65
+ when 'POST' then Net::HTTP::Post.new(uri)
66
+ when 'PUT' then Net::HTTP::Put.new(uri)
67
+ when 'PATCH' then Net::HTTP::Patch.new(uri)
68
+ when 'DELETE' then Net::HTTP::Delete.new(uri)
69
+ else raise ArgumentError, "Unknown HTTP method: #{method}"
70
+ end
71
+
72
+ req['Authorization'] = @auth_header
73
+ req['Content-Type'] = 'application/json'
74
+ req['Accept'] = 'application/json'
75
+ req['User-Agent'] = 'signalwire-agents-ruby-rest/1.0'
76
+
77
+ if body && %w[POST PUT PATCH].include?(method)
78
+ req.body = JSON.generate(body)
79
+ end
80
+
81
+ http = Net::HTTP.new(uri.host, uri.port)
82
+ http.use_ssl = true
83
+
84
+ response = http.request(req)
85
+
86
+ unless response.is_a?(Net::HTTPSuccess)
87
+ err_body = begin
88
+ JSON.parse(response.body)
89
+ rescue
90
+ response.body
91
+ end
92
+ raise SignalWireRestError.new(response.code.to_i, err_body, path, method)
93
+ end
94
+
95
+ return {} if response.code.to_i == 204 || response.body.nil? || response.body.empty?
96
+
97
+ JSON.parse(response.body)
98
+ end
99
+ end
100
+
101
+ # Base for all namespace/resource classes.
102
+ class BaseResource
103
+ def initialize(http, base_path)
104
+ @http = http
105
+ @base_path = base_path
106
+ end
107
+
108
+ private
109
+
110
+ def _path(*parts)
111
+ ([@base_path] + parts.map(&:to_s)).join('/')
112
+ end
113
+ end
114
+
115
+ # Standard CRUD resource with list/create/get/update/delete.
116
+ class CrudResource < BaseResource
117
+ def self.update_method
118
+ @update_method || 'PATCH'
119
+ end
120
+
121
+ def self.update_method=(m)
122
+ @update_method = m
123
+ end
124
+
125
+ def list(**params)
126
+ @http.get(@base_path, params.empty? ? nil : params)
127
+ end
128
+
129
+ def create(**kwargs)
130
+ @http.post(@base_path, kwargs)
131
+ end
132
+
133
+ def get(resource_id)
134
+ @http.get(_path(resource_id))
135
+ end
136
+
137
+ def update(resource_id, **kwargs)
138
+ m = self.class.update_method.downcase
139
+ @http.send(m, _path(resource_id), kwargs)
140
+ end
141
+
142
+ def delete(resource_id)
143
+ @http.delete(_path(resource_id))
144
+ end
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SignalWireAgents
4
+ module REST
5
+ module Namespaces
6
+ # Address management (no update endpoint).
7
+ class AddressesResource < BaseResource
8
+ def initialize(http)
9
+ super(http, '/api/relay/rest/addresses')
10
+ end
11
+
12
+ def list(**params) = @http.get(@base_path, params.empty? ? nil : params)
13
+ def create(**kwargs) = @http.post(@base_path, kwargs)
14
+ def get(address_id) = @http.get(_path(address_id))
15
+ def delete(address_id) = @http.delete(_path(address_id))
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,179 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SignalWireAgents
4
+ module REST
5
+ module Namespaces
6
+ # REST call control -- all 37 commands dispatched via single POST endpoint.
7
+ class CallingNamespace < BaseResource
8
+ def initialize(http)
9
+ super(http, '/api/calling/calls')
10
+ end
11
+
12
+ # Call lifecycle
13
+ def dial(**params) = _execute('dial', **params)
14
+ def update(**params) = _execute('update', **params)
15
+
16
+ def end_call(call_id, **params)
17
+ _execute('calling.end', call_id: call_id, **params)
18
+ end
19
+
20
+ def transfer(call_id, **params)
21
+ _execute('calling.transfer', call_id: call_id, **params)
22
+ end
23
+
24
+ def disconnect(call_id, **params)
25
+ _execute('calling.disconnect', call_id: call_id, **params)
26
+ end
27
+
28
+ # Play
29
+ def play(call_id, **params)
30
+ _execute('calling.play', call_id: call_id, **params)
31
+ end
32
+
33
+ def play_pause(call_id, **params)
34
+ _execute('calling.play.pause', call_id: call_id, **params)
35
+ end
36
+
37
+ def play_resume(call_id, **params)
38
+ _execute('calling.play.resume', call_id: call_id, **params)
39
+ end
40
+
41
+ def play_stop(call_id, **params)
42
+ _execute('calling.play.stop', call_id: call_id, **params)
43
+ end
44
+
45
+ def play_volume(call_id, **params)
46
+ _execute('calling.play.volume', call_id: call_id, **params)
47
+ end
48
+
49
+ # Record
50
+ def record(call_id, **params)
51
+ _execute('calling.record', call_id: call_id, **params)
52
+ end
53
+
54
+ def record_pause(call_id, **params)
55
+ _execute('calling.record.pause', call_id: call_id, **params)
56
+ end
57
+
58
+ def record_resume(call_id, **params)
59
+ _execute('calling.record.resume', call_id: call_id, **params)
60
+ end
61
+
62
+ def record_stop(call_id, **params)
63
+ _execute('calling.record.stop', call_id: call_id, **params)
64
+ end
65
+
66
+ # Collect
67
+ def collect(call_id, **params)
68
+ _execute('calling.collect', call_id: call_id, **params)
69
+ end
70
+
71
+ def collect_stop(call_id, **params)
72
+ _execute('calling.collect.stop', call_id: call_id, **params)
73
+ end
74
+
75
+ def collect_start_input_timers(call_id, **params)
76
+ _execute('calling.collect.start_input_timers', call_id: call_id, **params)
77
+ end
78
+
79
+ # Detect
80
+ def detect(call_id, **params)
81
+ _execute('calling.detect', call_id: call_id, **params)
82
+ end
83
+
84
+ def detect_stop(call_id, **params)
85
+ _execute('calling.detect.stop', call_id: call_id, **params)
86
+ end
87
+
88
+ # Tap
89
+ def tap(call_id, **params)
90
+ _execute('calling.tap', call_id: call_id, **params)
91
+ end
92
+
93
+ def tap_stop(call_id, **params)
94
+ _execute('calling.tap.stop', call_id: call_id, **params)
95
+ end
96
+
97
+ # Stream
98
+ def stream(call_id, **params)
99
+ _execute('calling.stream', call_id: call_id, **params)
100
+ end
101
+
102
+ def stream_stop(call_id, **params)
103
+ _execute('calling.stream.stop', call_id: call_id, **params)
104
+ end
105
+
106
+ # Denoise
107
+ def denoise(call_id, **params)
108
+ _execute('calling.denoise', call_id: call_id, **params)
109
+ end
110
+
111
+ def denoise_stop(call_id, **params)
112
+ _execute('calling.denoise.stop', call_id: call_id, **params)
113
+ end
114
+
115
+ # Transcribe
116
+ def transcribe(call_id, **params)
117
+ _execute('calling.transcribe', call_id: call_id, **params)
118
+ end
119
+
120
+ def transcribe_stop(call_id, **params)
121
+ _execute('calling.transcribe.stop', call_id: call_id, **params)
122
+ end
123
+
124
+ # AI
125
+ def ai_message(call_id, **params)
126
+ _execute('calling.ai_message', call_id: call_id, **params)
127
+ end
128
+
129
+ def ai_hold(call_id, **params)
130
+ _execute('calling.ai_hold', call_id: call_id, **params)
131
+ end
132
+
133
+ def ai_unhold(call_id, **params)
134
+ _execute('calling.ai_unhold', call_id: call_id, **params)
135
+ end
136
+
137
+ def ai_stop(call_id, **params)
138
+ _execute('calling.ai.stop', call_id: call_id, **params)
139
+ end
140
+
141
+ # Live transcribe / translate
142
+ def live_transcribe(call_id, **params)
143
+ _execute('calling.live_transcribe', call_id: call_id, **params)
144
+ end
145
+
146
+ def live_translate(call_id, **params)
147
+ _execute('calling.live_translate', call_id: call_id, **params)
148
+ end
149
+
150
+ # Fax
151
+ def send_fax_stop(call_id, **params)
152
+ _execute('calling.send_fax.stop', call_id: call_id, **params)
153
+ end
154
+
155
+ def receive_fax_stop(call_id, **params)
156
+ _execute('calling.receive_fax.stop', call_id: call_id, **params)
157
+ end
158
+
159
+ # SIP
160
+ def refer(call_id, **params)
161
+ _execute('calling.refer', call_id: call_id, **params)
162
+ end
163
+
164
+ # Custom events
165
+ def user_event(call_id, **params)
166
+ _execute('calling.user_event', call_id: call_id, **params)
167
+ end
168
+
169
+ private
170
+
171
+ def _execute(command, call_id: nil, **params)
172
+ body = { 'command' => command, 'params' => params.transform_keys(&:to_s) }
173
+ body['id'] = call_id if call_id
174
+ @http.post(@base_path, body)
175
+ end
176
+ end
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SignalWireAgents
4
+ module REST
5
+ module Namespaces
6
+ # Chat token generation.
7
+ class ChatResource < BaseResource
8
+ def initialize(http)
9
+ super(http, '/api/chat/tokens')
10
+ end
11
+
12
+ def create_token(**kwargs)
13
+ @http.post(@base_path, kwargs)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,229 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SignalWireAgents
4
+ module REST
5
+ module Namespaces
6
+ # Compat account/subproject management.
7
+ class CompatAccounts < BaseResource
8
+ def initialize(http)
9
+ super(http, '/api/laml/2010-04-01/Accounts')
10
+ end
11
+
12
+ def list(**params) = @http.get(@base_path, params.empty? ? nil : params)
13
+ def create(**kwargs) = @http.post(@base_path, kwargs)
14
+ def get(sid) = @http.get(_path(sid))
15
+ def update(sid, **kwargs) = @http.post(_path(sid), kwargs)
16
+ end
17
+
18
+ # Compat call management with recording and stream sub-resources.
19
+ class CompatCalls < CrudResource
20
+ def update(sid, **kwargs)
21
+ @http.post(_path(sid), kwargs)
22
+ end
23
+
24
+ def start_recording(call_sid, **kwargs)
25
+ @http.post(_path(call_sid, 'Recordings'), kwargs)
26
+ end
27
+
28
+ def update_recording(call_sid, recording_sid, **kwargs)
29
+ @http.post(_path(call_sid, 'Recordings', recording_sid), kwargs)
30
+ end
31
+
32
+ def start_stream(call_sid, **kwargs)
33
+ @http.post(_path(call_sid, 'Streams'), kwargs)
34
+ end
35
+
36
+ def stop_stream(call_sid, stream_sid, **kwargs)
37
+ @http.post(_path(call_sid, 'Streams', stream_sid), kwargs)
38
+ end
39
+ end
40
+
41
+ # Compat message management with media sub-resources.
42
+ class CompatMessages < CrudResource
43
+ def update(sid, **kwargs) = @http.post(_path(sid), kwargs)
44
+
45
+ def list_media(message_sid, **params)
46
+ @http.get(_path(message_sid, 'Media'), params.empty? ? nil : params)
47
+ end
48
+
49
+ def get_media(message_sid, media_sid)
50
+ @http.get(_path(message_sid, 'Media', media_sid))
51
+ end
52
+
53
+ def delete_media(message_sid, media_sid)
54
+ @http.delete(_path(message_sid, 'Media', media_sid))
55
+ end
56
+ end
57
+
58
+ # Compat fax management with media sub-resources.
59
+ class CompatFaxes < CrudResource
60
+ def update(sid, **kwargs) = @http.post(_path(sid), kwargs)
61
+
62
+ def list_media(fax_sid, **params)
63
+ @http.get(_path(fax_sid, 'Media'), params.empty? ? nil : params)
64
+ end
65
+
66
+ def get_media(fax_sid, media_sid)
67
+ @http.get(_path(fax_sid, 'Media', media_sid))
68
+ end
69
+
70
+ def delete_media(fax_sid, media_sid)
71
+ @http.delete(_path(fax_sid, 'Media', media_sid))
72
+ end
73
+ end
74
+
75
+ # Compat conference management.
76
+ class CompatConferences < BaseResource
77
+ def list(**params) = @http.get(@base_path, params.empty? ? nil : params)
78
+ def get(sid) = @http.get(_path(sid))
79
+ def update(sid, **kw) = @http.post(_path(sid), kw)
80
+
81
+ # Participants
82
+ def list_participants(conference_sid, **params)
83
+ @http.get(_path(conference_sid, 'Participants'), params.empty? ? nil : params)
84
+ end
85
+
86
+ def get_participant(conference_sid, call_sid)
87
+ @http.get(_path(conference_sid, 'Participants', call_sid))
88
+ end
89
+
90
+ def update_participant(conference_sid, call_sid, **kwargs)
91
+ @http.post(_path(conference_sid, 'Participants', call_sid), kwargs)
92
+ end
93
+
94
+ def remove_participant(conference_sid, call_sid)
95
+ @http.delete(_path(conference_sid, 'Participants', call_sid))
96
+ end
97
+
98
+ # Conference recordings
99
+ def list_recordings(conference_sid, **params)
100
+ @http.get(_path(conference_sid, 'Recordings'), params.empty? ? nil : params)
101
+ end
102
+
103
+ def get_recording(conference_sid, recording_sid)
104
+ @http.get(_path(conference_sid, 'Recordings', recording_sid))
105
+ end
106
+
107
+ def update_recording(conference_sid, recording_sid, **kwargs)
108
+ @http.post(_path(conference_sid, 'Recordings', recording_sid), kwargs)
109
+ end
110
+
111
+ def delete_recording(conference_sid, recording_sid)
112
+ @http.delete(_path(conference_sid, 'Recordings', recording_sid))
113
+ end
114
+
115
+ # Conference streams
116
+ def start_stream(conference_sid, **kwargs)
117
+ @http.post(_path(conference_sid, 'Streams'), kwargs)
118
+ end
119
+
120
+ def stop_stream(conference_sid, stream_sid, **kwargs)
121
+ @http.post(_path(conference_sid, 'Streams', stream_sid), kwargs)
122
+ end
123
+ end
124
+
125
+ # Compat phone number management.
126
+ class CompatPhoneNumbers < BaseResource
127
+ def initialize(http, base)
128
+ super(http, base)
129
+ @available_base = base.sub('/IncomingPhoneNumbers', '/AvailablePhoneNumbers')
130
+ end
131
+
132
+ def list(**params) = @http.get(@base_path, params.empty? ? nil : params)
133
+ def purchase(**kwargs) = @http.post(@base_path, kwargs)
134
+ def get(sid) = @http.get(_path(sid))
135
+ def update(sid, **kwargs) = @http.post(_path(sid), kwargs)
136
+ def delete(sid) = @http.delete(_path(sid))
137
+
138
+ def import_number(**kwargs)
139
+ path = @base_path.sub('/IncomingPhoneNumbers', '/ImportedPhoneNumbers')
140
+ @http.post(path, kwargs)
141
+ end
142
+
143
+ def list_available_countries(**params)
144
+ @http.get(@available_base, params.empty? ? nil : params)
145
+ end
146
+
147
+ def search_local(country, **params)
148
+ @http.get("#{@available_base}/#{country}/Local", params.empty? ? nil : params)
149
+ end
150
+
151
+ def search_toll_free(country, **params)
152
+ @http.get("#{@available_base}/#{country}/TollFree", params.empty? ? nil : params)
153
+ end
154
+ end
155
+
156
+ # Compat application management.
157
+ class CompatApplications < CrudResource
158
+ def update(sid, **kwargs) = @http.post(_path(sid), kwargs)
159
+ end
160
+
161
+ # Compat cXML/LaML script management.
162
+ class CompatLamlBins < CrudResource
163
+ def update(sid, **kwargs) = @http.post(_path(sid), kwargs)
164
+ end
165
+
166
+ # Compat queue management with members.
167
+ class CompatQueues < CrudResource
168
+ def update(sid, **kwargs) = @http.post(_path(sid), kwargs)
169
+
170
+ def list_members(queue_sid, **params)
171
+ @http.get(_path(queue_sid, 'Members'), params.empty? ? nil : params)
172
+ end
173
+
174
+ def get_member(queue_sid, call_sid)
175
+ @http.get(_path(queue_sid, 'Members', call_sid))
176
+ end
177
+
178
+ def dequeue_member(queue_sid, call_sid, **kwargs)
179
+ @http.post(_path(queue_sid, 'Members', call_sid), kwargs)
180
+ end
181
+ end
182
+
183
+ # Compat recording management.
184
+ class CompatRecordings < BaseResource
185
+ def list(**params) = @http.get(@base_path, params.empty? ? nil : params)
186
+ def get(sid) = @http.get(_path(sid))
187
+ def delete(sid) = @http.delete(_path(sid))
188
+ end
189
+
190
+ # Compat transcription management.
191
+ class CompatTranscriptions < BaseResource
192
+ def list(**params) = @http.get(@base_path, params.empty? ? nil : params)
193
+ def get(sid) = @http.get(_path(sid))
194
+ def delete(sid) = @http.delete(_path(sid))
195
+ end
196
+
197
+ # Compat API token management.
198
+ class CompatTokens < BaseResource
199
+ def create(**kwargs) = @http.post(@base_path, kwargs)
200
+ def update(token_id, **kwargs) = @http.patch(_path(token_id), kwargs)
201
+ def delete(token_id) = @http.delete(_path(token_id))
202
+ end
203
+
204
+ # Twilio-compatible LAML API namespace.
205
+ class CompatNamespace
206
+ attr_reader :accounts, :calls, :messages, :faxes, :conferences,
207
+ :phone_numbers, :applications, :laml_bins, :queues,
208
+ :recordings, :transcriptions, :tokens
209
+
210
+ def initialize(http, account_sid)
211
+ base = "/api/laml/2010-04-01/Accounts/#{account_sid}"
212
+
213
+ @accounts = CompatAccounts.new(http)
214
+ @calls = CompatCalls.new(http, "#{base}/Calls")
215
+ @messages = CompatMessages.new(http, "#{base}/Messages")
216
+ @faxes = CompatFaxes.new(http, "#{base}/Faxes")
217
+ @conferences = CompatConferences.new(http, "#{base}/Conferences")
218
+ @phone_numbers = CompatPhoneNumbers.new(http, "#{base}/IncomingPhoneNumbers")
219
+ @applications = CompatApplications.new(http, "#{base}/Applications")
220
+ @laml_bins = CompatLamlBins.new(http, "#{base}/LamlBins")
221
+ @queues = CompatQueues.new(http, "#{base}/Queues")
222
+ @recordings = CompatRecordings.new(http, "#{base}/Recordings")
223
+ @transcriptions = CompatTranscriptions.new(http, "#{base}/Transcriptions")
224
+ @tokens = CompatTokens.new(http, "#{base}/tokens")
225
+ end
226
+ end
227
+ end
228
+ end
229
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SignalWireAgents
4
+ module REST
5
+ module Namespaces
6
+ # Document management with search and chunk operations.
7
+ class DatasphereDocuments < CrudResource
8
+ def initialize(http)
9
+ super(http, '/api/datasphere/documents')
10
+ end
11
+
12
+ def search(**kwargs)
13
+ @http.post(_path('search'), kwargs)
14
+ end
15
+
16
+ def list_chunks(document_id, **params)
17
+ @http.get(_path(document_id, 'chunks'), params.empty? ? nil : params)
18
+ end
19
+
20
+ def get_chunk(document_id, chunk_id)
21
+ @http.get(_path(document_id, 'chunks', chunk_id))
22
+ end
23
+
24
+ def delete_chunk(document_id, chunk_id)
25
+ @http.delete(_path(document_id, 'chunks', chunk_id))
26
+ end
27
+ end
28
+
29
+ # Datasphere API namespace.
30
+ class DatasphereNamespace
31
+ attr_reader :documents
32
+
33
+ def initialize(http)
34
+ @documents = DatasphereDocuments.new(http)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end