voiceml 0.8.1 β†’ 0.9.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15e4cbe52a1e5c8c9373bc3b9f636c5637915cf7827abd08c87512998f7fafe4
4
- data.tar.gz: bc844da7b2b3289c072d7f5b3ef130a90eace33a0fa7f1794235e3bb096b986c
3
+ metadata.gz: f65ec54117bee65194bbf24028d00c20d820cee04cc9200472a42b329cd942f8
4
+ data.tar.gz: 3e2104d7267e31948f3160b37e527cec42acf4a68cb366b4963435f71e55f8ca
5
5
  SHA512:
6
- metadata.gz: fa0180df722300f7dc736fb67eccd89fd2369c8528d43569eb06e369321d75989a4daee80612c8899354e163ee99fbeda8092bef2e6d561670a94b872fa0b8dc
7
- data.tar.gz: a1ca825eac62aa31cb2367340e666a521251055500d0736975ff4a6f5061d9e4e6254d5c4b0e7d643f523cbd03029dc5b4e9840bfd22b7cf07c42775d23ae8fb
6
+ metadata.gz: dbbe6c38b68861d43ed68d7d3ffa335fb9caf7582fa47b091ca37e29ed3fda725f3b492aab06501c7a61d686c2db1e123fa0fd75e5440ed407a4304646feb19a
7
+ data.tar.gz: '09ced634a9e275031687a7d3647795a4c7a287928a8da4ffe5f61babd10c86eee840890e5233552e64ddf4aa68a50319ef42cd2a37afe68975d87cddb16dbe69'
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # πŸ“ž VoiceML Ruby SDK
2
2
 
3
- The official Ruby client for the [VoiceML REST API](https://voicetel.com/docs/api/v0.7/voiceml/) β€” Twilio-compatible outbound voice and answering-machine-detection from VoiceTel, with idiomatic snake_case kwargs, structured errors, and a Twilio-compatible wire format.
3
+ The official Ruby client for the [VoiceML REST API](https://voicetel.com/docs/api/v0.8/voiceml/) β€” Twilio-compatible outbound voice and answering-machine-detection from VoiceTel, with idiomatic snake_case kwargs, structured errors, and a Twilio-compatible wire format.
4
4
 
5
- ![Version](https://img.shields.io/badge/version-0.8.1-blue)
5
+ ![Version](https://img.shields.io/badge/version-0.9.1-blue)
6
6
  ![Ruby](https://img.shields.io/badge/ruby-3.0%2B-red)
7
7
  ![License](https://img.shields.io/badge/license-MIT-green)
8
8
  ![Tests](https://img.shields.io/badge/tests-65%20specs-brightgreen)
@@ -110,7 +110,7 @@ client = VoiceML::Client.new(account_sid: 'AC...', api_key: '...')
110
110
  client.diagnostics.health # uses your AccountSid + key on every call
111
111
  ```
112
112
 
113
- > Don't have credentials yet? See **[voicetel.com/docs/api/v0.7/voiceml/](https://voicetel.com/docs/api/v0.7/voiceml/)** for issuance and rotation.
113
+ > Don't have credentials yet? See **[voicetel.com/docs/api/v0.8/voiceml/](https://voicetel.com/docs/api/v0.8/voiceml/)** for issuance and rotation.
114
114
 
115
115
  ## πŸ—ΊοΈ Resource Reference
116
116
 
@@ -245,7 +245,7 @@ gem build voiceml.gemspec
245
245
 
246
246
  ## πŸ“– API Documentation
247
247
 
248
- - **Reference docs:** [voicetel.com/docs/api/v0.7/voiceml/](https://voicetel.com/docs/api/v0.7/voiceml/)
248
+ - **Reference docs:** [voicetel.com/docs/api/v0.8/voiceml/](https://voicetel.com/docs/api/v0.8/voiceml/)
249
249
  - **Validator:** [voicetel.com/voiceml/validator/](https://voicetel.com/voiceml/validator/)
250
250
  - **SDK catalogue:** [voicetel.com/docs/voiceml-sdks/](https://voicetel.com/docs/voiceml-sdks/)
251
251
  - **YARD comments:** every resource method carries `@param` / `@return` docs β€” `yard doc lib` builds them locally.
@@ -12,6 +12,9 @@ require_relative 'resources/diagnostics'
12
12
  require_relative 'resources/messages'
13
13
  require_relative 'resources/sip'
14
14
  require_relative 'resources/routes_v2'
15
+ require_relative 'resources/voice_v1'
16
+ require_relative 'resources/conversations_v1'
17
+ require_relative 'resources/assistants_v1'
15
18
 
16
19
  module VoiceML
17
20
  # Synchronous client for the VoiceML REST API.
@@ -31,7 +34,7 @@ module VoiceML
31
34
  class Client
32
35
  attr_reader :calls, :conferences, :queues, :applications, :recordings,
33
36
  :incoming_phone_numbers, :notifications, :diagnostics, :messages,
34
- :sip, :routes_v2
37
+ :sip, :routes_v2, :voice_v1, :conversations_v1, :assistants_v1
35
38
 
36
39
  # @param account_sid [String] Twilio-format AccountSid (`AC` + 32 hex).
37
40
  # @param api_key [String, nil] per-tenant API key. Pass either `api_key:` or the
@@ -75,6 +78,9 @@ module VoiceML
75
78
  @messages = MessagesResource.new(@transport)
76
79
  @sip = SipResource.new(@transport)
77
80
  @routes_v2 = RoutesV2Resource.new(@transport)
81
+ @voice_v1 = VoiceV1Resource.new(@transport)
82
+ @conversations_v1 = ConversationsV1Resource.new(@transport)
83
+ @assistants_v1 = AssistantsV1Resource.new(@transport)
78
84
  end
79
85
 
80
86
  def account_sid
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'common'
4
+
5
+ module VoiceML
6
+ # Twilio-compatible Account resource. The voiceml SDK is single-account
7
+ # (the credential's account is implicit on every call), so this model
8
+ # exists primarily to decode `GET/POST /Accounts/{Sid}.json` responses
9
+ # round-trip with the Twilio shape β€” useful for migration tooling that
10
+ # echoes the account record back to the caller.
11
+ class Account
12
+ ATTRIBUTES = %w[
13
+ sid friendly_name status type auth_token owner_account_sid
14
+ date_created date_updated subresource_uris uri
15
+ ].freeze
16
+
17
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
18
+
19
+ def initialize(attrs = {})
20
+ ATTRIBUTES.each do |field|
21
+ value = attrs.key?(field) ? attrs[field] : attrs[field.to_sym]
22
+ instance_variable_set("@#{field}", value)
23
+ end
24
+ end
25
+
26
+ def self.from_hash(hash)
27
+ return nil if hash.nil?
28
+
29
+ new(hash)
30
+ end
31
+ end
32
+
33
+ # `GET /Accounts/{Sid}/Balance.json` β€” running balance for the account in
34
+ # the account's settlement currency. No `sid` field on the wire (the
35
+ # balance is account-scoped, not its own resource).
36
+ class Balance
37
+ ATTRIBUTES = %w[account_sid balance currency].freeze
38
+
39
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
40
+
41
+ def initialize(attrs = {})
42
+ ATTRIBUTES.each do |field|
43
+ value = attrs.key?(field) ? attrs[field] : attrs[field.to_sym]
44
+ instance_variable_set("@#{field}", value)
45
+ end
46
+ end
47
+
48
+ def self.from_hash(hash)
49
+ return nil if hash.nil?
50
+
51
+ new(hash)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,239 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'common'
4
+ require_relative 'voice_v1' # V1Pageable lives here; Assistants v1 reuses the same `meta` envelope
5
+
6
+ module VoiceML
7
+ # Assistants v1 (`/v1/Assistants`, `/v1/Tools`, `/v1/Knowledge`, `/v1/Sessions`,
8
+ # `/v1/Policies`) β€” Twilio AI-Assistants surface. Same /v1 conventions as Voice v1
9
+ # and Conversations v1: Basic-auth account resolution, ISO-8601 dates, `meta`
10
+ # list envelope (V1Pageable). 7 families for v0.9.1:
11
+ # - Assistant (aia_asst_...)
12
+ # - Tool (aia_tool_...) + ToolWithPolicies fetch shape
13
+ # - Knowledge (aia_know_...) + KnowledgeStatus + KnowledgeChunk
14
+ # - Session
15
+ # - Message (aia_msg_...) + SendMessageResponse
16
+ # - Feedback (aia_fdbk_...)
17
+ # - Policy (aia_plcy_...)
18
+
19
+ # AssistantsV1Assistant β€” `aia_asst_...`. Used by list/create/update/delete responses.
20
+ class AssistantsV1Assistant
21
+ ATTRIBUTES = %w[
22
+ account_sid customer_ai id model name owner url personality_prompt
23
+ date_created date_updated
24
+ ].freeze
25
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
26
+ def initialize(attrs = {})
27
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
28
+ end
29
+ def self.from_hash(h); h.nil? ? nil : new(h); end
30
+ end
31
+
32
+ class AssistantsV1AssistantList
33
+ include V1Pageable
34
+ attr_reader :assistants
35
+ def initialize(hash = {})
36
+ assign_meta_fields(hash)
37
+ @assistants = (hash['assistants'] || []).map { |h| AssistantsV1Assistant.from_hash(h) }
38
+ end
39
+ end
40
+
41
+ # AssistantsV1AssistantWithToolsAndKnowledge β€” fetch-one shape that includes the
42
+ # attached tools and knowledge arrays inline.
43
+ class AssistantsV1AssistantWithToolsAndKnowledge
44
+ ATTRIBUTES = %w[
45
+ account_sid customer_ai id model name owner url personality_prompt
46
+ date_created date_updated tools knowledge
47
+ ].freeze
48
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
49
+ def initialize(attrs = {})
50
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
51
+ end
52
+ def self.from_hash(h); h.nil? ? nil : new(h); end
53
+ end
54
+
55
+ # AssistantsV1Tool β€” `aia_tool_...`.
56
+ class AssistantsV1Tool
57
+ ATTRIBUTES = %w[
58
+ account_sid description enabled id meta name requires_auth type url
59
+ date_created date_updated
60
+ ].freeze
61
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
62
+ def initialize(attrs = {})
63
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
64
+ end
65
+ def self.from_hash(h); h.nil? ? nil : new(h); end
66
+ end
67
+
68
+ class AssistantsV1ToolList
69
+ include V1Pageable
70
+ attr_reader :tools
71
+ def initialize(hash = {})
72
+ assign_meta_fields(hash)
73
+ @tools = (hash['tools'] || []).map { |h| AssistantsV1Tool.from_hash(h) }
74
+ end
75
+ end
76
+
77
+ # AssistantsV1ToolWithPolicies β€” fetch-one shape that includes the policies array inline.
78
+ class AssistantsV1ToolWithPolicies
79
+ ATTRIBUTES = %w[
80
+ account_sid description enabled id meta name requires_auth type url
81
+ date_created date_updated policies
82
+ ].freeze
83
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
84
+ def initialize(attrs = {})
85
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
86
+ end
87
+ def self.from_hash(h); h.nil? ? nil : new(h); end
88
+ end
89
+
90
+ # AssistantsV1Knowledge β€” `aia_know_...`.
91
+ class AssistantsV1Knowledge
92
+ ATTRIBUTES = %w[
93
+ account_sid description id knowledge_source_details name status type url
94
+ embedding_model date_created date_updated
95
+ ].freeze
96
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
97
+ def initialize(attrs = {})
98
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
99
+ end
100
+ def self.from_hash(h); h.nil? ? nil : new(h); end
101
+ end
102
+
103
+ class AssistantsV1KnowledgeList
104
+ include V1Pageable
105
+ attr_reader :knowledge
106
+ def initialize(hash = {})
107
+ assign_meta_fields(hash)
108
+ @knowledge = (hash['knowledge'] || []).map { |h| AssistantsV1Knowledge.from_hash(h) }
109
+ end
110
+ end
111
+
112
+ # AssistantsV1KnowledgeStatus β€” read-only ingestion status snapshot.
113
+ class AssistantsV1KnowledgeStatus
114
+ ATTRIBUTES = %w[account_sid status last_status date_updated].freeze
115
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
116
+ def initialize(attrs = {})
117
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
118
+ end
119
+ def self.from_hash(h); h.nil? ? nil : new(h); end
120
+ end
121
+
122
+ # AssistantsV1KnowledgeChunk β€” single retrieved chunk of indexed Knowledge content.
123
+ class AssistantsV1KnowledgeChunk
124
+ ATTRIBUTES = %w[account_sid content metadata date_created date_updated].freeze
125
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
126
+ def initialize(attrs = {})
127
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
128
+ end
129
+ def self.from_hash(h); h.nil? ? nil : new(h); end
130
+ end
131
+
132
+ class AssistantsV1KnowledgeChunkList
133
+ include V1Pageable
134
+ attr_reader :chunks
135
+ def initialize(hash = {})
136
+ assign_meta_fields(hash)
137
+ @chunks = (hash['chunks'] || []).map { |h| AssistantsV1KnowledgeChunk.from_hash(h) }
138
+ end
139
+ end
140
+
141
+ # AssistantsV1Session β€” a chat session between an identity and an Assistant.
142
+ class AssistantsV1Session
143
+ ATTRIBUTES = %w[
144
+ id account_sid assistant_id verified identity date_created date_updated
145
+ ].freeze
146
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
147
+ def initialize(attrs = {})
148
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
149
+ end
150
+ def self.from_hash(h); h.nil? ? nil : new(h); end
151
+ end
152
+
153
+ class AssistantsV1SessionList
154
+ include V1Pageable
155
+ attr_reader :sessions
156
+ def initialize(hash = {})
157
+ assign_meta_fields(hash)
158
+ @sessions = (hash['sessions'] || []).map { |h| AssistantsV1Session.from_hash(h) }
159
+ end
160
+ end
161
+
162
+ # AssistantsV1Message β€” `aia_msg_...`. One message in an Assistant session.
163
+ class AssistantsV1Message
164
+ ATTRIBUTES = %w[
165
+ id account_sid assistant_id session_id identity role content meta
166
+ date_created date_updated
167
+ ].freeze
168
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
169
+ def initialize(attrs = {})
170
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
171
+ end
172
+ def self.from_hash(h); h.nil? ? nil : new(h); end
173
+ end
174
+
175
+ class AssistantsV1MessageList
176
+ include V1Pageable
177
+ attr_reader :messages
178
+ def initialize(hash = {})
179
+ assign_meta_fields(hash)
180
+ @messages = (hash['messages'] || []).map { |h| AssistantsV1Message.from_hash(h) }
181
+ end
182
+ end
183
+
184
+ # AssistantsV1SendMessageResponse β€” POST /v1/Assistants/{id}/Messages return shape.
185
+ # Distinct from AssistantsV1Message: carries the model's reply body + flag/abort signals.
186
+ class AssistantsV1SendMessageResponse
187
+ ATTRIBUTES = %w[status flagged aborted session_id account_sid body error].freeze
188
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
189
+ def initialize(attrs = {})
190
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
191
+ end
192
+ def self.from_hash(h); h.nil? ? nil : new(h); end
193
+ end
194
+
195
+ # AssistantsV1Feedback β€” `aia_fdbk_...`. Numeric score + text feedback on a message.
196
+ class AssistantsV1Feedback
197
+ ATTRIBUTES = %w[
198
+ assistant_id id account_sid user_sid message_id score session_id text
199
+ date_created date_updated
200
+ ].freeze
201
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
202
+ def initialize(attrs = {})
203
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
204
+ end
205
+ def self.from_hash(h); h.nil? ? nil : new(h); end
206
+ end
207
+
208
+ class AssistantsV1FeedbackList
209
+ include V1Pageable
210
+ attr_reader :feedbacks
211
+ def initialize(hash = {})
212
+ assign_meta_fields(hash)
213
+ @feedbacks = (hash['feedbacks'] || []).map { |h| AssistantsV1Feedback.from_hash(h) }
214
+ end
215
+ end
216
+
217
+ # AssistantsV1Policy β€” `aia_plcy_...`. Read-only β€” listed under /v1/Policies (filterable
218
+ # by ToolId/KnowledgeId) and embedded inline on Tool fetch responses.
219
+ class AssistantsV1Policy
220
+ ATTRIBUTES = %w[
221
+ id name description account_sid user_sid type policy_details
222
+ date_created date_updated
223
+ ].freeze
224
+ attr_reader(*ATTRIBUTES.map(&:to_sym))
225
+ def initialize(attrs = {})
226
+ ATTRIBUTES.each { |f| instance_variable_set("@#{f}", attrs.key?(f) ? attrs[f] : attrs[f.to_sym]) }
227
+ end
228
+ def self.from_hash(h); h.nil? ? nil : new(h); end
229
+ end
230
+
231
+ class AssistantsV1PolicyList
232
+ include V1Pageable
233
+ attr_reader :policies
234
+ def initialize(hash = {})
235
+ assign_meta_fields(hash)
236
+ @policies = (hash['policies'] || []).map { |h| AssistantsV1Policy.from_hash(h) }
237
+ end
238
+ end
239
+ end