sentdm 0.39.0 → 0.40.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 (140) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +1 -1
  4. data/lib/sentdm/internal/voice_agents_page.rb +115 -0
  5. data/lib/sentdm/models/call_event.rb +8 -6
  6. data/lib/sentdm/models/call_event_payload.rb +25 -6
  7. data/lib/sentdm/models/channels/voice_create_params.rb +23 -11
  8. data/lib/sentdm/models/channels/voice_number.rb +23 -1
  9. data/lib/sentdm/models/channels/voice_update_params.rb +12 -1
  10. data/lib/sentdm/models/voice/agent_create_params.rb +142 -0
  11. data/lib/sentdm/models/voice/agent_delete_params.rb +28 -0
  12. data/lib/sentdm/models/voice/agent_list_params.rb +38 -0
  13. data/lib/sentdm/models/voice/agent_retrieve_params.rb +28 -0
  14. data/lib/sentdm/models/voice/agent_rotate_secret_params.rb +34 -0
  15. data/lib/sentdm/models/voice/agent_update_params.rb +141 -0
  16. data/lib/sentdm/models/voice/api_response_of_voice_agent.rb +51 -0
  17. data/lib/sentdm/models/voice/api_response_of_voice_agent_secret.rb +45 -0
  18. data/lib/sentdm/models/voice/api_response_of_voice_agents_list.rb +48 -0
  19. data/lib/sentdm/models/voice/api_response_of_voice_catalogue.rb +49 -0
  20. data/lib/sentdm/models/voice/call.rb +97 -5
  21. data/lib/sentdm/models/voice/call_list_params.rb +19 -1
  22. data/lib/sentdm/models/voice/catalogue_list_params.rb +22 -0
  23. data/lib/sentdm/models/voice/voice_agent.rb +138 -0
  24. data/lib/sentdm/models/voice/voice_agent_audio.rb +19 -0
  25. data/lib/sentdm/models/voice/voice_agent_audio_spec.rb +20 -0
  26. data/lib/sentdm/models/voice/voice_agent_limits.rb +31 -0
  27. data/lib/sentdm/models/voice/voice_agent_limits_spec.rb +40 -0
  28. data/lib/sentdm/models/voice/voice_agent_party.rb +25 -0
  29. data/lib/sentdm/models/voice/voice_agent_party_spec.rb +28 -0
  30. data/lib/sentdm/models/voice/voice_agent_secret.rb +27 -0
  31. data/lib/sentdm/models/voice/voice_agent_speech.rb +31 -0
  32. data/lib/sentdm/models/voice/voice_agent_speech_spec.rb +40 -0
  33. data/lib/sentdm/models/voice/voice_agent_transcripts.rb +25 -0
  34. data/lib/sentdm/models/voice/voice_agent_transcripts_spec.rb +32 -0
  35. data/lib/sentdm/models/voice/voice_agents_list.rb +30 -0
  36. data/lib/sentdm/models/voice/voice_catalogue.rb +30 -0
  37. data/lib/sentdm/models/voice/voice_catalogue_voice.rb +43 -0
  38. data/lib/sentdm/models/webhook_create_params.rb +31 -5
  39. data/lib/sentdm/models/webhook_response.rb +66 -4
  40. data/lib/sentdm/models/webhook_update_params.rb +15 -3
  41. data/lib/sentdm/resources/channels/voice.rb +38 -15
  42. data/lib/sentdm/resources/profiles/campaigns.rb +3 -2
  43. data/lib/sentdm/resources/voice/agents.rb +319 -0
  44. data/lib/sentdm/resources/voice/calls/participants.rb +11 -0
  45. data/lib/sentdm/resources/voice/calls.rb +44 -13
  46. data/lib/sentdm/resources/voice/catalogue.rb +71 -0
  47. data/lib/sentdm/resources/voice/tokens.rb +11 -0
  48. data/lib/sentdm/resources/voice.rb +86 -0
  49. data/lib/sentdm/resources/webhooks.rb +43 -15
  50. data/lib/sentdm/version.rb +1 -1
  51. data/lib/sentdm.rb +29 -0
  52. data/rbi/sentdm/internal/voice_agents_page.rbi +71 -0
  53. data/rbi/sentdm/models/call_event.rbi +14 -10
  54. data/rbi/sentdm/models/call_event_payload.rbi +28 -5
  55. data/rbi/sentdm/models/channels/voice_create_params.rbi +33 -17
  56. data/rbi/sentdm/models/channels/voice_number.rbi +31 -0
  57. data/rbi/sentdm/models/channels/voice_update_params.rbi +14 -0
  58. data/rbi/sentdm/models/voice/agent_create_params.rbi +215 -0
  59. data/rbi/sentdm/models/voice/agent_delete_params.rbi +48 -0
  60. data/rbi/sentdm/models/voice/agent_list_params.rbi +66 -0
  61. data/rbi/sentdm/models/voice/agent_retrieve_params.rbi +48 -0
  62. data/rbi/sentdm/models/voice/agent_rotate_secret_params.rbi +64 -0
  63. data/rbi/sentdm/models/voice/agent_update_params.rbi +211 -0
  64. data/rbi/sentdm/models/voice/api_response_of_voice_agent.rbi +85 -0
  65. data/rbi/sentdm/models/voice/api_response_of_voice_agent_secret.rbi +81 -0
  66. data/rbi/sentdm/models/voice/api_response_of_voice_agents_list.rbi +83 -0
  67. data/rbi/sentdm/models/voice/api_response_of_voice_catalogue.rbi +83 -0
  68. data/rbi/sentdm/models/voice/call.rbi +141 -8
  69. data/rbi/sentdm/models/voice/call_list_params.rbi +20 -0
  70. data/rbi/sentdm/models/voice/catalogue_list_params.rbi +40 -0
  71. data/rbi/sentdm/models/voice/voice_agent.rbi +196 -0
  72. data/rbi/sentdm/models/voice/voice_agent_audio.rbi +30 -0
  73. data/rbi/sentdm/models/voice/voice_agent_audio_spec.rbi +33 -0
  74. data/rbi/sentdm/models/voice/voice_agent_limits.rbi +57 -0
  75. data/rbi/sentdm/models/voice/voice_agent_limits_spec.rbi +62 -0
  76. data/rbi/sentdm/models/voice/voice_agent_party.rbi +36 -0
  77. data/rbi/sentdm/models/voice/voice_agent_party_spec.rbi +45 -0
  78. data/rbi/sentdm/models/voice/voice_agent_secret.rbi +37 -0
  79. data/rbi/sentdm/models/voice/voice_agent_speech.rbi +48 -0
  80. data/rbi/sentdm/models/voice/voice_agent_speech_spec.rbi +62 -0
  81. data/rbi/sentdm/models/voice/voice_agent_transcripts.rbi +43 -0
  82. data/rbi/sentdm/models/voice/voice_agent_transcripts_spec.rbi +51 -0
  83. data/rbi/sentdm/models/voice/voice_agents_list.rbi +55 -0
  84. data/rbi/sentdm/models/voice/voice_catalogue.rbi +59 -0
  85. data/rbi/sentdm/models/voice/voice_catalogue_voice.rbi +75 -0
  86. data/rbi/sentdm/models/webhook_create_params.rbi +41 -3
  87. data/rbi/sentdm/models/webhook_response.rbi +112 -3
  88. data/rbi/sentdm/models/webhook_update_params.rbi +18 -3
  89. data/rbi/sentdm/resources/channels/voice.rbi +52 -19
  90. data/rbi/sentdm/resources/profiles/campaigns.rbi +3 -2
  91. data/rbi/sentdm/resources/voice/agents.rbi +316 -0
  92. data/rbi/sentdm/resources/voice/calls/participants.rbi +11 -0
  93. data/rbi/sentdm/resources/voice/calls.rbi +46 -11
  94. data/rbi/sentdm/resources/voice/catalogue.rbi +59 -0
  95. data/rbi/sentdm/resources/voice/tokens.rbi +11 -0
  96. data/rbi/sentdm/resources/voice.rbi +84 -0
  97. data/rbi/sentdm/resources/webhooks.rbi +56 -16
  98. data/sig/sentdm/internal/voice_agents_page.rbs +41 -0
  99. data/sig/sentdm/models/call_event_payload.rbs +12 -0
  100. data/sig/sentdm/models/channels/voice_create_params.rbs +9 -4
  101. data/sig/sentdm/models/channels/voice_number.rbs +12 -0
  102. data/sig/sentdm/models/channels/voice_update_params.rbs +5 -0
  103. data/sig/sentdm/models/voice/agent_create_params.rbs +99 -0
  104. data/sig/sentdm/models/voice/agent_delete_params.rbs +34 -0
  105. data/sig/sentdm/models/voice/agent_list_params.rbs +40 -0
  106. data/sig/sentdm/models/voice/agent_retrieve_params.rbs +32 -0
  107. data/sig/sentdm/models/voice/agent_rotate_secret_params.rbs +40 -0
  108. data/sig/sentdm/models/voice/agent_update_params.rbs +108 -0
  109. data/sig/sentdm/models/voice/api_response_of_voice_agent.rbs +41 -0
  110. data/sig/sentdm/models/voice/api_response_of_voice_agent_secret.rbs +41 -0
  111. data/sig/sentdm/models/voice/api_response_of_voice_agents_list.rbs +41 -0
  112. data/sig/sentdm/models/voice/api_response_of_voice_catalogue.rbs +41 -0
  113. data/sig/sentdm/models/voice/call.rbs +65 -0
  114. data/sig/sentdm/models/voice/call_list_params.rbs +10 -0
  115. data/sig/sentdm/models/voice/catalogue_list_params.rbs +27 -0
  116. data/sig/sentdm/models/voice/voice_agent.rbs +116 -0
  117. data/sig/sentdm/models/voice/voice_agent_audio.rbs +19 -0
  118. data/sig/sentdm/models/voice/voice_agent_audio_spec.rbs +17 -0
  119. data/sig/sentdm/models/voice/voice_agent_limits.rbs +38 -0
  120. data/sig/sentdm/models/voice/voice_agent_limits_spec.rbs +34 -0
  121. data/sig/sentdm/models/voice/voice_agent_party.rbs +23 -0
  122. data/sig/sentdm/models/voice/voice_agent_party_spec.rbs +19 -0
  123. data/sig/sentdm/models/voice/voice_agent_secret.rbs +19 -0
  124. data/sig/sentdm/models/voice/voice_agent_speech.rbs +32 -0
  125. data/sig/sentdm/models/voice/voice_agent_speech_spec.rbs +26 -0
  126. data/sig/sentdm/models/voice/voice_agent_transcripts.rbs +23 -0
  127. data/sig/sentdm/models/voice/voice_agent_transcripts_spec.rbs +20 -0
  128. data/sig/sentdm/models/voice/voice_agents_list.rbs +35 -0
  129. data/sig/sentdm/models/voice/voice_catalogue.rbs +35 -0
  130. data/sig/sentdm/models/voice/voice_catalogue_voice.rbs +42 -0
  131. data/sig/sentdm/models/webhook_create_params.rbs +12 -0
  132. data/sig/sentdm/models/webhook_response.rbs +46 -3
  133. data/sig/sentdm/models/webhook_update_params.rbs +5 -0
  134. data/sig/sentdm/resources/channels/voice.rbs +3 -1
  135. data/sig/sentdm/resources/voice/agents.rbs +74 -0
  136. data/sig/sentdm/resources/voice/calls.rbs +2 -0
  137. data/sig/sentdm/resources/voice/catalogue.rbs +14 -0
  138. data/sig/sentdm/resources/voice.rbs +4 -0
  139. data/sig/sentdm/resources/webhooks.rbs +3 -0
  140. metadata +89 -2
@@ -10,6 +10,8 @@ module Sentdm
10
10
  optional :id, String
11
11
 
12
12
  # @!attribute consecutive_failures
13
+ # Failed attempts since the last success. Version 1 only: always 0 on a version 2
14
+ # webhook, whose deliveries are in its events (GET /v3/webhooks/{id}/events).
13
15
  #
14
16
  # @return [Integer, nil]
15
17
  optional :consecutive_failures, Integer
@@ -53,12 +55,24 @@ module Sentdm
53
55
  # @return [Boolean, nil]
54
56
  optional :is_active, Sentdm::Internal::Type::Boolean
55
57
 
58
+ # @!attribute is_inheritable
59
+ # Whether the webhook also receives its organization's sender profiles' events,
60
+ # and each profile sees it and reads the events about itself. Always false on a
61
+ # version 1 webhook.
62
+ #
63
+ # @return [Boolean, nil]
64
+ optional :is_inheritable, Sentdm::Internal::Type::Boolean
65
+
56
66
  # @!attribute last_delivery_attempt_at
67
+ # When the webhook was last attempted. Version 1 only: always null on a version 2
68
+ # webhook.
57
69
  #
58
70
  # @return [Time, nil]
59
71
  optional :last_delivery_attempt_at, Time, nil?: true
60
72
 
61
73
  # @!attribute last_successful_delivery_at
74
+ # When the webhook last received an event. Version 1 only: always null on a
75
+ # version 2 webhook.
62
76
  #
63
77
  # @return [Time, nil]
64
78
  optional :last_successful_delivery_at, Time, nil?: true
@@ -68,6 +82,16 @@ module Sentdm
68
82
  # @return [Integer, nil]
69
83
  optional :retry_count, Integer
70
84
 
85
+ # @!attribute sender_profile
86
+ # The events a version 1 webhook's sender profile clones receive, as a response
87
+ # reports them.
88
+ #
89
+ # Its own type, field for field the same as the request's sender_profile. A
90
+ # response is not a request, whatever it carries.
91
+ #
92
+ # @return [Sentdm::Models::WebhookResponse::SenderProfile, nil]
93
+ optional :sender_profile, -> { Sentdm::WebhookResponse::SenderProfile }, nil?: true
94
+
71
95
  # @!attribute signing_secret
72
96
  #
73
97
  # @return [String, nil]
@@ -83,13 +107,20 @@ module Sentdm
83
107
  # @return [Time, nil]
84
108
  optional :updated_at, Time, nil?: true
85
109
 
86
- # @!method initialize(id: nil, consecutive_failures: nil, created_at: nil, customer_id: nil, display_name: nil, endpoint_url: nil, event_filters: nil, event_types: nil, is_active: nil, last_delivery_attempt_at: nil, last_successful_delivery_at: nil, retry_count: nil, signing_secret: nil, timeout_seconds: nil, updated_at: nil)
110
+ # @!attribute webhook_version
111
+ # Who delivers the webhook: 1 the older delivery, which will be retired, or 2
112
+ # Svix. A webhook is created as version 2 unless the request asks for 1.
113
+ #
114
+ # @return [Integer, nil]
115
+ optional :webhook_version, Integer
116
+
117
+ # @!method initialize(id: nil, consecutive_failures: nil, created_at: nil, customer_id: nil, display_name: nil, endpoint_url: nil, event_filters: nil, event_types: nil, is_active: nil, is_inheritable: nil, last_delivery_attempt_at: nil, last_successful_delivery_at: nil, retry_count: nil, sender_profile: nil, signing_secret: nil, timeout_seconds: nil, updated_at: nil, webhook_version: nil)
87
118
  # Some parameter documentations has been truncated, see
88
119
  # {Sentdm::Models::WebhookResponse} for more details.
89
120
  #
90
121
  # @param id [String]
91
122
  #
92
- # @param consecutive_failures [Integer]
123
+ # @param consecutive_failures [Integer] Failed attempts since the last success. Version 1 only: always 0 on a version 2
93
124
  #
94
125
  # @param created_at [Time]
95
126
  #
@@ -105,17 +136,48 @@ module Sentdm
105
136
  #
106
137
  # @param is_active [Boolean]
107
138
  #
108
- # @param last_delivery_attempt_at [Time, nil]
139
+ # @param is_inheritable [Boolean] Whether the webhook also receives its organization's sender profiles' events, an
109
140
  #
110
- # @param last_successful_delivery_at [Time, nil]
141
+ # @param last_delivery_attempt_at [Time, nil] When the webhook was last attempted. Version 1 only: always null on a version 2
142
+ #
143
+ # @param last_successful_delivery_at [Time, nil] When the webhook last received an event. Version 1 only: always null on a versio
111
144
  #
112
145
  # @param retry_count [Integer]
113
146
  #
147
+ # @param sender_profile [Sentdm::Models::WebhookResponse::SenderProfile, nil] The events a version 1 webhook's sender profile clones receive, as a response re
148
+ #
114
149
  # @param signing_secret [String, nil]
115
150
  #
116
151
  # @param timeout_seconds [Integer]
117
152
  #
118
153
  # @param updated_at [Time, nil]
154
+ #
155
+ # @param webhook_version [Integer] Who delivers the webhook: 1 the older delivery, which will be retired, or 2 Svix
156
+
157
+ # @see Sentdm::Models::WebhookResponse#sender_profile
158
+ class SenderProfile < Sentdm::Internal::Type::BaseModel
159
+ # @!attribute event_filters
160
+ #
161
+ # @return [Hash{Symbol=>Array<String>}, nil]
162
+ optional :event_filters,
163
+ Sentdm::Internal::Type::HashOf[Sentdm::Internal::Type::ArrayOf[String]],
164
+ nil?: true
165
+
166
+ # @!attribute event_types
167
+ #
168
+ # @return [Array<String>, nil]
169
+ optional :event_types, Sentdm::Internal::Type::ArrayOf[String]
170
+
171
+ # @!method initialize(event_filters: nil, event_types: nil)
172
+ # The events a version 1 webhook's sender profile clones receive, as a response
173
+ # reports them.
174
+ #
175
+ # Its own type, field for field the same as the request's sender_profile. A
176
+ # response is not a request, whatever it carries.
177
+ #
178
+ # @param event_filters [Hash{Symbol=>Array<String>}, nil]
179
+ # @param event_types [Array<String>]
180
+ end
119
181
  end
120
182
  end
121
183
  end
@@ -34,6 +34,14 @@ module Sentdm
34
34
  # @return [Array<String>, nil]
35
35
  optional :event_types, Sentdm::Internal::Type::ArrayOf[String]
36
36
 
37
+ # @!attribute is_inheritable
38
+ # Makes this webhook inheritable by the organization's sender profiles (see
39
+ # create), or stops it being inheritable. Omit or pass null to keep it as it is.
40
+ # Only a version 2 webhook can be inheritable.
41
+ #
42
+ # @return [Boolean, nil]
43
+ optional :is_inheritable, Sentdm::Internal::Type::Boolean, nil?: true
44
+
37
45
  # @!attribute retry_count
38
46
  #
39
47
  # @return [Integer, nil]
@@ -48,7 +56,8 @@ module Sentdm
48
56
 
49
57
  # @!attribute sender_profile
50
58
  # Request-only: the events an organization webhook's sender profile clones
51
- # receive, one clone per existing and future profile. Responses never return it.
59
+ # receive, one clone per existing and future profile. A version 1 webhook's
60
+ # responses report it as WebhookSenderProfileV3Response.
52
61
  #
53
62
  # @return [Sentdm::Models::WebhookUpdateParams::SenderProfile, nil]
54
63
  optional :sender_profile, -> { Sentdm::WebhookUpdateParams::SenderProfile }, nil?: true
@@ -68,7 +77,7 @@ module Sentdm
68
77
  # @return [String, nil]
69
78
  optional :x_profile_id, String
70
79
 
71
- # @!method initialize(id:, display_name: nil, endpoint_url: nil, event_filters: nil, event_types: nil, retry_count: nil, sandbox: nil, sender_profile: nil, timeout_seconds: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
80
+ # @!method initialize(id:, display_name: nil, endpoint_url: nil, event_filters: nil, event_types: nil, is_inheritable: nil, retry_count: nil, sandbox: nil, sender_profile: nil, timeout_seconds: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
72
81
  # Some parameter documentations has been truncated, see
73
82
  # {Sentdm::Models::WebhookUpdateParams} for more details.
74
83
  #
@@ -82,6 +91,8 @@ module Sentdm
82
91
  #
83
92
  # @param event_types [Array<String>]
84
93
  #
94
+ # @param is_inheritable [Boolean, nil] Makes this webhook inheritable by the organization's sender profiles (see create
95
+ #
85
96
  # @param retry_count [Integer]
86
97
  #
87
98
  # @param sandbox [Boolean] Sandbox flag - when true, the operation is simulated without side effects
@@ -111,7 +122,8 @@ module Sentdm
111
122
 
112
123
  # @!method initialize(event_filters: nil, event_types: nil)
113
124
  # Request-only: the events an organization webhook's sender profile clones
114
- # receive, one clone per existing and future profile. Responses never return it.
125
+ # receive, one clone per existing and future profile. A version 1 webhook's
126
+ # responses report it as WebhookSenderProfileV3Response.
115
127
  #
116
128
  # @param event_filters [Hash{Symbol=>Array<String>}, nil]
117
129
  # @param event_types [Array<String>]
@@ -47,6 +47,16 @@ module Sentdm
47
47
  # question the way you verify a webhook. `POST /v3/channels/voice/{number}/test`
48
48
  # sends a test question and reports the verdict.
49
49
  #
50
+ # Send `agent_id` instead of `callback_url`, or with it, to have one of your voice
51
+ # agents (`GET /v3/voice/agents`) answer calls to the number. The agent wins over
52
+ # the callback URL for calls to the number; calls your app places from it still
53
+ # follow your app. `routes_to` in the response says which answers, and reads
54
+ # `agent_pending` while the number is still being moved to the agent. Calls follow
55
+ # the move within about an hour, as the provider applies it on its own clock.
56
+ # While numbers cannot be bound to agents, a request with `agent_id` is refused
57
+ # with `502` before any number is obtained or anything is written; send
58
+ # `callback_url` instead.
59
+ #
50
60
  # Your first voice number becomes the line app-originated calls are placed from
51
61
  # when a voice token names no number; send `default_for_app_calls: true` to give
52
62
  # that role to another number. A number you turned off earlier is turned back on,
@@ -59,12 +69,14 @@ module Sentdm
59
69
  # With `sandbox: true` the request is validated and a simulated number reported
60
70
  # with `202`; nothing is written and no number is bought.
61
71
  #
62
- # @overload create(callback_url:, area_code: nil, default_for_app_calls: nil, number: nil, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
72
+ # @overload create(agent_id: nil, area_code: nil, callback_url: nil, default_for_app_calls: nil, number: nil, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
63
73
  #
64
- # @param callback_url [String] Body param: Where Sent asks what to do with each call on this number: an absolut
74
+ # @param agent_id [String, nil] Body param: One of your voice agents (GET /v3/voice/agents), such as
65
75
  #
66
76
  # @param area_code [String, nil] Body param: The US area code a new number should be in, as 212. Only for a reque
67
77
  #
78
+ # @param callback_url [String, nil] Body param: Where Sent asks what to do with each call on this number: an absolut
79
+ #
68
80
  # @param default_for_app_calls [Boolean, nil] Body param: Make this the line app-originated calls are placed from when a voice
69
81
  #
70
82
  # @param number [String, nil] Body param: One of your phone numbers, in E.164 format. Leave the field out enti
@@ -80,7 +92,7 @@ module Sentdm
80
92
  # @return [Sentdm::Models::Channels::APIResponseOfVoiceNumberCreated]
81
93
  #
82
94
  # @see Sentdm::Models::Channels::VoiceCreateParams
83
- def create(params)
95
+ def create(params = {})
84
96
  parsed, options = Sentdm::Channels::VoiceCreateParams.dump_request(params)
85
97
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
86
98
  @client.request(
@@ -136,18 +148,23 @@ module Sentdm
136
148
  #
137
149
  # ## What it changes
138
150
  #
139
- # | Body | Effect |
140
- # | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
141
- # | `"status": "ACTIVE"` | turns calls on again for a number you turned off; the callback URL and the secret it had are kept |
142
- # | `"status": "INACTIVE"` | turns calls off; the callback URL and the secret stay on the number |
143
- # | `"default_for_app_calls": true` | makes this the line app-originated calls are placed from when a voice token names no number |
144
- # | `"callback_url": "https://example.com/voice"` | replaces where Sent asks what to do with each call on the number; the signing secret and the status are kept |
145
- # | key omitted | left exactly as it is |
151
+ # | Body | Effect |
152
+ # | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
153
+ # | `"status": "ACTIVE"` | turns calls on again for a number you turned off; the callback URL and the secret it had are kept |
154
+ # | `"status": "INACTIVE"` | turns calls off; the callback URL and the secret stay on the number |
155
+ # | `"default_for_app_calls": true` | makes this the line app-originated calls are placed from when a voice token names no number |
156
+ # | `"callback_url": "https://example.com/voice"` | replaces where Sent asks what to do with each call on the number; the signing secret and the status are kept |
157
+ # | `"agent_id": "agent_…"` | one of your voice agents answers calls to the number, within about an hour of the change (the provider applies the move on its own clock, and `routes_to` reads `agent` as soon as it has recorded it); it wins over `callback_url` for calls to the number, and calls your app places from it still follow your app. `routes_to` reads `agent_pending` while the number is still being moved to the agent |
158
+ # | `"agent_id": null` | unbinds the agent, so `callback_url` answers calls to the number again |
159
+ # | key omitted | left exactly as it is |
146
160
  #
147
161
  # `status` is matched ignoring case. Any combination is accepted:
148
162
  # `status: "ACTIVE"` with `default_for_app_calls: true` turns a number on as the
149
- # new default, and a `callback_url` sent with either status is written too. A body
150
- # that names none of the three is refused.
163
+ # new default, and a `callback_url` sent with either status is written too.
164
+ # `agent_id` is applied first, so a refusal to move the number to or from the
165
+ # agent leaves everything as it was, and the `409` and `400` refusals below are
166
+ # decided before anything is written, so they leave everything as it was too. A
167
+ # body that names none of them is refused.
151
168
  #
152
169
  # A number can be on without a callback URL: calls placed from your app then
153
170
  # connect straight to the number or user they dial, and calls to the number are
@@ -166,8 +183,12 @@ module Sentdm
166
183
  # **Making an inactive number the default is `400`.** Send `status: "ACTIVE"` in
167
184
  # the same call.
168
185
  #
169
- # **A number you never turned voice on for is `404`.** Add it with
170
- # `POST /v3/channels/voice`.
186
+ # **A number you never turned voice on for is `404`**, and so is an `agent_id`
187
+ # that is not one of your agents. Add the number with `POST /v3/channels/voice`.
188
+ #
189
+ # **`502` means the number could not be moved to or from the agent**, or an
190
+ # `agent_id` was sent while numbers cannot be bound to agents; nothing was
191
+ # written.
171
192
  #
172
193
  # The number is the E.164 value in the path with the plus sign URL-encoded
173
194
  # (`%2B`).
@@ -176,10 +197,12 @@ module Sentdm
176
197
  # stored number and the number is reported with `200` as it would read after the
177
198
  # change.
178
199
  #
179
- # @overload update(number, callback_url: nil, default_for_app_calls: nil, sandbox: nil, status: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
200
+ # @overload update(number, agent_id: nil, callback_url: nil, default_for_app_calls: nil, sandbox: nil, status: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
180
201
  #
181
202
  # @param number [String] Path param: The number in E.164 format with the plus sign URL-encoded, e.g. %2B1
182
203
  #
204
+ # @param agent_id [String, nil] Body param: One of your voice agents, such as agent_9f2ab000-0000-4000-8000-0000
205
+ #
183
206
  # @param callback_url [String, nil] Body param: A new callback URL for the number, active or not: an absolute HTTP o
184
207
  #
185
208
  # @param default_for_app_calls [Boolean, nil] Body param: true makes this the line app-originated calls are placed from when a
@@ -66,8 +66,9 @@ module Sentdm
66
66
  # which models a profile's markets, compliance, brand, campaigns and billing
67
67
  # explicitly.
68
68
  #
69
- # Updates an existing campaign under the brand of the specified profile. Cannot
70
- # update campaigns that have already been submitted to TCR.
69
+ # Updates an existing campaign under the brand of the specified profile. Once the
70
+ # campaign has been submitted to TCR its volume can no longer move between low
71
+ # volume (under 2,000 messages a day) and high volume.
71
72
  #
72
73
  # @overload update(campaign_id, profile_id:, campaign:, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
73
74
  #
@@ -0,0 +1,319 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sentdm
4
+ module Resources
5
+ class Voice
6
+ # Phone calls from the numbers you hold, driven by your own callback URL.
7
+ #
8
+ # `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent
9
+ # asks what to do with each call on it, and `POST /v3/voice/tokens` mints a
10
+ # short-lived token that lets a user of your app place and receive calls as that
11
+ # number. When a call arrives or a caller presses a key, a signed question is
12
+ # POSTed to the callback URL and the answer decides the call;
13
+ # `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need
14
+ # before a real call reaches it, and
15
+ # `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret.
16
+ # The call events themselves (`call.completed` and the rest) arrive through your
17
+ # webhooks.
18
+ #
19
+ # Every call is a record under `/v3/voice/calls`: read it, list its recordings
20
+ # once one is ready, hang it up, start or stop recording, and add, mute or remove
21
+ # conference participants while it is live. A leg to a phone number runs for at
22
+ # most what your balance affords at the destination's rate.
23
+ #
24
+ # **Voice agents.** `POST /v3/voice/agents` creates an agent that answers calls
25
+ # through the Sent Voice Gateway: `session_type` says whether Sent carries the
26
+ # call as text (speech recognised and spoken for the agent) or as audio,
27
+ # `websocket_url` is where the gateway dials the agent for each call (leave it out
28
+ # and the agent dials in with your API key), and `tools`, `transfer_targets`,
29
+ # `fallback` and `limits` say what it may do on a call. The agent's
30
+ # `signing_secret` is shown on create and on
31
+ # `POST /v3/voice/agents/{id}/rotate-secret` only. Voices and languages for text
32
+ # sessions come from `GET /v3/voice/voices`. A number takes calls to an agent once
33
+ # it is bound to it on `/v3/channels/voice`.
34
+ class Agents
35
+ # Some parameter documentations has been truncated, see
36
+ # {Sentdm::Models::Voice::AgentCreateParams} for more details.
37
+ #
38
+ # Creates an agent that answers phone calls through the Sent Voice Gateway.
39
+ # `session_type` says whether Sent carries the call as text (the caller's speech
40
+ # recognised for the agent, the agent's text spoken) or as audio. With
41
+ # `websocket_url` the gateway dials your agent for each call and signs the
42
+ # handshake with the `signing_secret` this response returns; without it, your
43
+ # agent dials in with your API key and this agent's `id`.
44
+ #
45
+ # `tools`, `transfer_targets`, `fallback` and `limits` say what the agent may do
46
+ # on a call. Voices and languages for text sessions come from
47
+ # `GET /v3/voice/voices`. Calls reach the agent once a number is bound to it on
48
+ # `/v3/channels/voice`.
49
+ #
50
+ # `signing_secret` is shown here and on `POST /v3/voice/agents/{id}/rotate-secret`
51
+ # only; store it now. With `sandbox: true` the request is validated and the agent
52
+ # reported with `202`; nothing is written.
53
+ #
54
+ # @overload create(audio: nil, fallback: nil, greeting: nil, limits: nil, name: nil, sandbox: nil, session_type: nil, speech: nil, tools: nil, transcripts: nil, transfer_targets: nil, websocket_url: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
55
+ #
56
+ # @param audio [Sentdm::Models::Voice::VoiceAgentAudioSpec, nil] Body param: Audio sessions only: the sound format.
57
+ #
58
+ # @param fallback [Sentdm::Models::Voice::VoiceAgentPartySpec, nil] Body param: Who takes the call when the agent cannot: a phone number (kind: numb
59
+ #
60
+ # @param greeting [String, nil] Body param: Text sessions only: what the caller hears as soon as the call is ans
61
+ #
62
+ # @param limits [Sentdm::Models::Voice::VoiceAgentLimitsSpec, nil] Body param
63
+ #
64
+ # @param name [String, nil] Body param: A name for your own reference, 1 to 100 characters.
65
+ #
66
+ # @param sandbox [Boolean] Body param: Sandbox flag - when true, the operation is simulated without side ef
67
+ #
68
+ # @param session_type [String, nil] Body param: text: Sent turns the caller's speech into text and the agent's text
69
+ #
70
+ # @param speech [Sentdm::Models::Voice::VoiceAgentSpeechSpec, nil] Body param: Text sessions only: how the caller is spoken to and listened to.
71
+ #
72
+ # @param tools [Array<String>, nil] Body param: What the agent may do to the call: any of transfer, hangup, send_dtm
73
+ #
74
+ # @param transcripts [Sentdm::Models::Voice::VoiceAgentTranscriptsSpec, nil] Body param
75
+ #
76
+ # @param transfer_targets [Array<Sentdm::Models::Voice::VoiceAgentPartySpec>, nil] Body param: Where the agent may transfer a call to, up to 20 parties: a phone nu
77
+ #
78
+ # @param websocket_url [String, nil] Body param: Where the gateway connects to the agent for each call: an absolute w
79
+ #
80
+ # @param idempotency_key [String] Header param: Unique key to ensure idempotent request processing. Must be 1-255
81
+ #
82
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
83
+ #
84
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
85
+ #
86
+ # @return [Sentdm::Models::Voice::APIResponseOfVoiceAgent]
87
+ #
88
+ # @see Sentdm::Models::Voice::AgentCreateParams
89
+ def create(params = {})
90
+ parsed, options = Sentdm::Voice::AgentCreateParams.dump_request(params)
91
+ header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
92
+ @client.request(
93
+ method: :post,
94
+ path: "v3/voice/agents",
95
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
96
+ body: parsed.except(*header_params.keys),
97
+ model: Sentdm::Voice::APIResponseOfVoiceAgent,
98
+ options: options
99
+ )
100
+ end
101
+
102
+ # Some parameter documentations has been truncated, see
103
+ # {Sentdm::Models::Voice::AgentRetrieveParams} for more details.
104
+ #
105
+ # The agent as stored, without its signing secret.
106
+ #
107
+ # @overload retrieve(id, x_profile_id: nil, request_options: {})
108
+ #
109
+ # @param id [String] The agent id, such as agent_9f2ab000-0000-4000-8000-000000000001
110
+ #
111
+ # @param x_profile_id [String] Profile UUID to scope the request to a child profile. Only organization API keys
112
+ #
113
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
114
+ #
115
+ # @return [Sentdm::Models::Voice::APIResponseOfVoiceAgent]
116
+ #
117
+ # @see Sentdm::Models::Voice::AgentRetrieveParams
118
+ def retrieve(id, params = {})
119
+ parsed, options = Sentdm::Voice::AgentRetrieveParams.dump_request(params)
120
+ @client.request(
121
+ method: :get,
122
+ path: ["v3/voice/agents/%1$s", id],
123
+ headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
124
+ model: Sentdm::Voice::APIResponseOfVoiceAgent,
125
+ options: options
126
+ )
127
+ end
128
+
129
+ # Some parameter documentations has been truncated, see
130
+ # {Sentdm::Models::Voice::AgentUpdateParams} for more details.
131
+ #
132
+ # Changes the fields you name and answers with the agent as stored, the same shape
133
+ # `GET` returns.
134
+ #
135
+ # A key left out is left alone. A key sent as `null` clears an optional field
136
+ # (`websocket_url` makes the agent dial in, `greeting` and `fallback` go,
137
+ # `speech`, `audio`, `tools`, `limits` and `transcripts` return to their
138
+ # defaults). A key sent with a value replaces that field whole: send the whole
139
+ # `limits` object, not one of its keys. Changing `session_type` drops `speech`,
140
+ # `audio` and `greeting` unless the body sends them, since the other type cannot
141
+ # carry them. The result is checked like a new agent, and a body that changes
142
+ # nothing is `400`.
143
+ #
144
+ # With `sandbox: true` nothing is written: the request is validated against the
145
+ # stored agent and the agent is reported with `200` as it would read after the
146
+ # change.
147
+ #
148
+ # @overload update(id, audio: nil, fallback: nil, greeting: nil, limits: nil, name: nil, sandbox: nil, session_type: nil, speech: nil, tools: nil, transcripts: nil, transfer_targets: nil, websocket_url: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
149
+ #
150
+ # @param id [String] Path param: The agent id, such as agent_9f2ab000-0000-4000-8000-000000000001
151
+ #
152
+ # @param audio [Sentdm::Models::Voice::VoiceAgentAudioSpec, nil] Body param: Audio sessions: { sample_rate }; null restores the default.
153
+ #
154
+ # @param fallback [Sentdm::Models::Voice::VoiceAgentPartySpec, nil] Body param: A new fallback party, or null for none.
155
+ #
156
+ # @param greeting [String, nil] Body param: A new greeting, or null for none.
157
+ #
158
+ # @param limits [Sentdm::Models::Voice::VoiceAgentLimitsSpec, nil] Body param: The whole limits object; null restores the defaults.
159
+ #
160
+ # @param name [String] Body param: A new name, 1 to 100 characters.
161
+ #
162
+ # @param sandbox [Boolean] Body param: Sandbox flag - when true, the operation is simulated without side ef
163
+ #
164
+ # @param session_type [String] Body param: text or audio. Changing it drops the settings the other type cannot
165
+ #
166
+ # @param speech [Sentdm::Models::Voice::VoiceAgentSpeechSpec, nil] Body param: Text sessions: { setting, voice, language }, replaced whole; null re
167
+ #
168
+ # @param tools [Array<String>, nil] Body param: The whole list of tools; null restores the default.
169
+ #
170
+ # @param transcripts [Sentdm::Models::Voice::VoiceAgentTranscriptsSpec, nil] Body param: The whole transcripts object; null restores the defaults.
171
+ #
172
+ # @param transfer_targets [Array<Sentdm::Models::Voice::VoiceAgentPartySpec>, nil] Body param: The whole list of parties; null clears it.
173
+ #
174
+ # @param websocket_url [String, nil] Body param: A new wss:// URL, or null for an agent that dials in.
175
+ #
176
+ # @param idempotency_key [String] Header param: Unique key to ensure idempotent request processing. Must be 1-255
177
+ #
178
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
179
+ #
180
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
181
+ #
182
+ # @return [Sentdm::Models::Voice::APIResponseOfVoiceAgent]
183
+ #
184
+ # @see Sentdm::Models::Voice::AgentUpdateParams
185
+ def update(id, params = {})
186
+ parsed, options = Sentdm::Voice::AgentUpdateParams.dump_request(params)
187
+ header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
188
+ @client.request(
189
+ method: :patch,
190
+ path: ["v3/voice/agents/%1$s", id],
191
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
192
+ body: parsed.except(*header_params.keys),
193
+ model: Sentdm::Voice::APIResponseOfVoiceAgent,
194
+ options: options
195
+ )
196
+ end
197
+
198
+ # Some parameter documentations has been truncated, see
199
+ # {Sentdm::Models::Voice::AgentListParams} for more details.
200
+ #
201
+ # Your voice agents, newest first. `page` and `page_size` (1 to 100, default 20)
202
+ # page the list. Signing secrets are never listed.
203
+ #
204
+ # @overload list(page: nil, page_size: nil, x_profile_id: nil, request_options: {})
205
+ #
206
+ # @param page [Integer] Query param: Page number, from 1
207
+ #
208
+ # @param page_size [Integer] Query param
209
+ #
210
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
211
+ #
212
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
213
+ #
214
+ # @return [Sentdm::Internal::VoiceAgentsPage<Sentdm::Models::Voice::VoiceAgent>]
215
+ #
216
+ # @see Sentdm::Models::Voice::AgentListParams
217
+ def list(params = {})
218
+ query_params = [:page, :page_size]
219
+ parsed, options = Sentdm::Voice::AgentListParams.dump_request(params)
220
+ query = Sentdm::Internal::Util.encode_query_params(parsed.slice(*query_params))
221
+ @client.request(
222
+ method: :get,
223
+ path: "v3/voice/agents",
224
+ query: query,
225
+ headers: parsed.except(*query_params).transform_keys(x_profile_id: "x-profile-id"),
226
+ page: Sentdm::Internal::VoiceAgentsPage,
227
+ model: Sentdm::Voice::VoiceAgent,
228
+ options: options
229
+ )
230
+ end
231
+
232
+ # Some parameter documentations has been truncated, see
233
+ # {Sentdm::Models::Voice::AgentDeleteParams} for more details.
234
+ #
235
+ # Removes the agent. Calls it already took keep their `agent_id`.
236
+ #
237
+ # An agent that one of your voice numbers routes to, or that another of your
238
+ # agents lists in `transfer_targets`, is not deleted: the answer is `409` with a
239
+ # message naming those numbers and agents. Unbind the numbers
240
+ # (`PATCH /v3/channels/voice/{number}` with `"agent_id": null`), take the agent
241
+ # out of the others' `transfer_targets` or delete them, and try again.
242
+ #
243
+ # With `sandbox: true` nothing is written: the agent is looked up and the answer
244
+ # is the one a real delete would give.
245
+ #
246
+ # @overload delete(id, sandbox: nil, x_profile_id: nil, request_options: {})
247
+ #
248
+ # @param id [String] Path param: The agent id, such as agent_9f2ab000-0000-4000-8000-000000000001
249
+ #
250
+ # @param sandbox [Boolean] Body param: Sandbox flag - when true, the operation is simulated without side ef
251
+ #
252
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
253
+ #
254
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
255
+ #
256
+ # @return [nil]
257
+ #
258
+ # @see Sentdm::Models::Voice::AgentDeleteParams
259
+ def delete(id, params = {})
260
+ parsed, options = Sentdm::Voice::AgentDeleteParams.dump_request(params)
261
+ header_params = {x_profile_id: "x-profile-id"}
262
+ @client.request(
263
+ method: :delete,
264
+ path: ["v3/voice/agents/%1$s", id],
265
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
266
+ body: parsed.except(*header_params.keys),
267
+ model: NilClass,
268
+ options: options
269
+ )
270
+ end
271
+
272
+ # Some parameter documentations has been truncated, see
273
+ # {Sentdm::Models::Voice::AgentRotateSecretParams} for more details.
274
+ #
275
+ # Generates a new `signing_secret` for the agent and returns it. The previous
276
+ # secret stops signing immediately, so update your agent before the next call
277
+ # reaches it.
278
+ #
279
+ # With `sandbox: true` a secret is generated and returned with `202`, and nothing
280
+ # is written.
281
+ #
282
+ # @overload rotate_secret(id, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
283
+ #
284
+ # @param id [String] Path param: The agent id, such as agent_9f2ab000-0000-4000-8000-000000000001
285
+ #
286
+ # @param sandbox [Boolean] Body param: Sandbox flag - when true, the operation is simulated without side ef
287
+ #
288
+ # @param idempotency_key [String] Header param: Unique key to ensure idempotent request processing. Must be 1-255
289
+ #
290
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
291
+ #
292
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
293
+ #
294
+ # @return [Sentdm::Models::Voice::APIResponseOfVoiceAgentSecret]
295
+ #
296
+ # @see Sentdm::Models::Voice::AgentRotateSecretParams
297
+ def rotate_secret(id, params = {})
298
+ parsed, options = Sentdm::Voice::AgentRotateSecretParams.dump_request(params)
299
+ header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
300
+ @client.request(
301
+ method: :post,
302
+ path: ["v3/voice/agents/%1$s/rotate-secret", id],
303
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
304
+ body: parsed.except(*header_params.keys),
305
+ model: Sentdm::Voice::APIResponseOfVoiceAgentSecret,
306
+ options: options
307
+ )
308
+ end
309
+
310
+ # @api private
311
+ #
312
+ # @param client [Sentdm::Client]
313
+ def initialize(client:)
314
+ @client = client
315
+ end
316
+ end
317
+ end
318
+ end
319
+ end
@@ -21,6 +21,17 @@ module Sentdm
21
21
  # once one is ready, hang it up, start or stop recording, and add, mute or remove
22
22
  # conference participants while it is live. A leg to a phone number runs for at
23
23
  # most what your balance affords at the destination's rate.
24
+ #
25
+ # **Voice agents.** `POST /v3/voice/agents` creates an agent that answers calls
26
+ # through the Sent Voice Gateway: `session_type` says whether Sent carries the
27
+ # call as text (speech recognised and spoken for the agent) or as audio,
28
+ # `websocket_url` is where the gateway dials the agent for each call (leave it out
29
+ # and the agent dials in with your API key), and `tools`, `transfer_targets`,
30
+ # `fallback` and `limits` say what it may do on a call. The agent's
31
+ # `signing_secret` is shown on create and on
32
+ # `POST /v3/voice/agents/{id}/rotate-secret` only. Voices and languages for text
33
+ # sessions come from `GET /v3/voice/voices`. A number takes calls to an agent once
34
+ # it is bound to it on `/v3/channels/voice`.
24
35
  class Participants
25
36
  # Some parameter documentations has been truncated, see
26
37
  # {Sentdm::Models::Voice::Calls::ParticipantUpdateParams} for more details.