sentdm 0.34.0 → 0.35.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 (165) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +11 -9
  4. data/lib/sentdm/client.rb +25 -0
  5. data/lib/sentdm/internal/calls_page.rb +115 -0
  6. data/lib/sentdm/models/api_response_of_call.rb +43 -0
  7. data/lib/sentdm/models/api_response_of_call_recordings.rb +43 -0
  8. data/lib/sentdm/models/api_response_of_calls_list.rb +42 -0
  9. data/lib/sentdm/models/call.rb +133 -0
  10. data/lib/sentdm/models/call_event.rb +72 -0
  11. data/lib/sentdm/models/call_event_payload.rb +102 -0
  12. data/lib/sentdm/models/call_hangup_params.rb +32 -0
  13. data/lib/sentdm/models/call_list_params.rb +83 -0
  14. data/lib/sentdm/models/call_list_recordings_params.rb +26 -0
  15. data/lib/sentdm/models/call_party.rb +31 -0
  16. data/lib/sentdm/models/call_record_params.rb +55 -0
  17. data/lib/sentdm/models/call_recording.rb +38 -0
  18. data/lib/sentdm/models/call_recordings.rb +24 -0
  19. data/lib/sentdm/models/call_retrieve_params.rb +26 -0
  20. data/lib/sentdm/models/call_timeline_entry.rb +26 -0
  21. data/lib/sentdm/models/calls/api_response_of_list_of_call_participant.rb +45 -0
  22. data/lib/sentdm/models/calls/call_participant.rb +60 -0
  23. data/lib/sentdm/models/calls/call_participant_target.rb +30 -0
  24. data/lib/sentdm/models/calls/participant_add_params.rb +66 -0
  25. data/lib/sentdm/models/calls/participant_list_params.rb +28 -0
  26. data/lib/sentdm/models/calls/participant_remove_all_params.rb +28 -0
  27. data/lib/sentdm/models/calls/participant_remove_params.rb +34 -0
  28. data/lib/sentdm/models/calls/participant_update_params.rb +64 -0
  29. data/lib/sentdm/models/calls_list.rb +26 -0
  30. data/lib/sentdm/models/channels/api_response_of_list_of_voice_number.rb +45 -0
  31. data/lib/sentdm/models/channels/api_response_of_voice_callback_test.rb +45 -0
  32. data/lib/sentdm/models/channels/api_response_of_voice_number.rb +45 -0
  33. data/lib/sentdm/models/channels/api_response_of_voice_number_created.rb +45 -0
  34. data/lib/sentdm/models/channels/api_response_of_voice_secret.rb +45 -0
  35. data/lib/sentdm/models/channels/api_response_of_voice_token.rb +45 -0
  36. data/lib/sentdm/models/channels/voice_callback_test.rb +65 -0
  37. data/lib/sentdm/models/channels/voice_callback_test_error_info.rb +41 -0
  38. data/lib/sentdm/models/channels/voice_callback_test_request_info.rb +40 -0
  39. data/lib/sentdm/models/channels/voice_callback_test_response_info.rb +28 -0
  40. data/lib/sentdm/models/channels/voice_create_params.rb +86 -0
  41. data/lib/sentdm/models/channels/voice_create_token_params.rb +69 -0
  42. data/lib/sentdm/models/channels/voice_list_params.rb +22 -0
  43. data/lib/sentdm/models/channels/voice_number.rb +68 -0
  44. data/lib/sentdm/models/channels/voice_number_created.rb +26 -0
  45. data/lib/sentdm/models/channels/voice_retrieve_params.rb +28 -0
  46. data/lib/sentdm/models/channels/voice_rotate_secret_params.rb +34 -0
  47. data/lib/sentdm/models/channels/voice_secret.rb +25 -0
  48. data/lib/sentdm/models/channels/voice_test_params.rb +34 -0
  49. data/lib/sentdm/models/channels/voice_token.rb +44 -0
  50. data/lib/sentdm/models/channels/voice_update_params.rb +95 -0
  51. data/lib/sentdm/models/webhook_list_events_response.rb +4 -173
  52. data/lib/sentdm/models.rb +36 -0
  53. data/lib/sentdm/resources/calls/participants.rb +231 -0
  54. data/lib/sentdm/resources/calls.rb +235 -0
  55. data/lib/sentdm/resources/channels/voice.rb +381 -0
  56. data/lib/sentdm/resources/channels.rb +45 -0
  57. data/lib/sentdm/version.rb +1 -1
  58. data/lib/sentdm.rb +50 -0
  59. data/rbi/sentdm/client.rbi +23 -0
  60. data/rbi/sentdm/internal/calls_page.rbi +71 -0
  61. data/rbi/sentdm/models/api_response_of_call.rbi +74 -0
  62. data/rbi/sentdm/models/api_response_of_call_recordings.rbi +74 -0
  63. data/rbi/sentdm/models/api_response_of_calls_list.rbi +74 -0
  64. data/rbi/sentdm/models/call.rbi +177 -0
  65. data/rbi/sentdm/models/call_event.rbi +114 -0
  66. data/rbi/sentdm/models/call_event_payload.rbi +135 -0
  67. data/rbi/sentdm/models/call_hangup_params.rbi +59 -0
  68. data/rbi/sentdm/models/call_list_params.rbi +112 -0
  69. data/rbi/sentdm/models/call_list_recordings_params.rbi +46 -0
  70. data/rbi/sentdm/models/call_party.rbi +41 -0
  71. data/rbi/sentdm/models/call_record_params.rbi +83 -0
  72. data/rbi/sentdm/models/call_recording.rbi +59 -0
  73. data/rbi/sentdm/models/call_recordings.rbi +39 -0
  74. data/rbi/sentdm/models/call_retrieve_params.rbi +46 -0
  75. data/rbi/sentdm/models/call_timeline_entry.rbi +40 -0
  76. data/rbi/sentdm/models/calls/api_response_of_list_of_call_participant.rbi +76 -0
  77. data/rbi/sentdm/models/calls/call_participant.rbi +92 -0
  78. data/rbi/sentdm/models/calls/call_participant_target.rbi +47 -0
  79. data/rbi/sentdm/models/calls/participant_add_params.rbi +98 -0
  80. data/rbi/sentdm/models/calls/participant_list_params.rbi +51 -0
  81. data/rbi/sentdm/models/calls/participant_remove_all_params.rbi +51 -0
  82. data/rbi/sentdm/models/calls/participant_remove_params.rbi +61 -0
  83. data/rbi/sentdm/models/calls/participant_update_params.rbi +94 -0
  84. data/rbi/sentdm/models/calls_list.rbi +47 -0
  85. data/rbi/sentdm/models/channels/api_response_of_list_of_voice_number.rbi +76 -0
  86. data/rbi/sentdm/models/channels/api_response_of_voice_callback_test.rbi +83 -0
  87. data/rbi/sentdm/models/channels/api_response_of_voice_number.rbi +81 -0
  88. data/rbi/sentdm/models/channels/api_response_of_voice_number_created.rbi +83 -0
  89. data/rbi/sentdm/models/channels/api_response_of_voice_secret.rbi +81 -0
  90. data/rbi/sentdm/models/channels/api_response_of_voice_token.rbi +81 -0
  91. data/rbi/sentdm/models/channels/voice_callback_test.rbi +126 -0
  92. data/rbi/sentdm/models/channels/voice_callback_test_error_info.rbi +65 -0
  93. data/rbi/sentdm/models/channels/voice_callback_test_request_info.rbi +66 -0
  94. data/rbi/sentdm/models/channels/voice_callback_test_response_info.rbi +48 -0
  95. data/rbi/sentdm/models/channels/voice_create_params.rbi +127 -0
  96. data/rbi/sentdm/models/channels/voice_create_token_params.rbi +104 -0
  97. data/rbi/sentdm/models/channels/voice_list_params.rbi +40 -0
  98. data/rbi/sentdm/models/channels/voice_number.rbi +105 -0
  99. data/rbi/sentdm/models/channels/voice_number_created.rbi +42 -0
  100. data/rbi/sentdm/models/channels/voice_retrieve_params.rbi +51 -0
  101. data/rbi/sentdm/models/channels/voice_rotate_secret_params.rbi +64 -0
  102. data/rbi/sentdm/models/channels/voice_secret.rbi +35 -0
  103. data/rbi/sentdm/models/channels/voice_test_params.rbi +61 -0
  104. data/rbi/sentdm/models/channels/voice_token.rbi +76 -0
  105. data/rbi/sentdm/models/channels/voice_update_params.rbi +158 -0
  106. data/rbi/sentdm/models/webhook_list_events_response.rbi +3 -269
  107. data/rbi/sentdm/models.rbi +36 -0
  108. data/rbi/sentdm/resources/calls/participants.rbi +199 -0
  109. data/rbi/sentdm/resources/calls.rbi +206 -0
  110. data/rbi/sentdm/resources/channels/voice.rbi +371 -0
  111. data/rbi/sentdm/resources/channels.rbi +42 -0
  112. data/sig/sentdm/client.rbs +4 -0
  113. data/sig/sentdm/internal/calls_page.rbs +41 -0
  114. data/sig/sentdm/models/api_response_of_call.rbs +39 -0
  115. data/sig/sentdm/models/api_response_of_call_recordings.rbs +39 -0
  116. data/sig/sentdm/models/api_response_of_calls_list.rbs +39 -0
  117. data/sig/sentdm/models/call.rbs +101 -0
  118. data/sig/sentdm/models/call_event.rbs +44 -0
  119. data/sig/sentdm/models/call_event_payload.rbs +68 -0
  120. data/sig/sentdm/models/call_hangup_params.rbs +38 -0
  121. data/sig/sentdm/models/call_list_params.rbs +67 -0
  122. data/sig/sentdm/models/call_list_recordings_params.rbs +30 -0
  123. data/sig/sentdm/models/call_party.rbs +17 -0
  124. data/sig/sentdm/models/call_record_params.rbs +54 -0
  125. data/sig/sentdm/models/call_recording.rbs +32 -0
  126. data/sig/sentdm/models/call_recordings.rbs +17 -0
  127. data/sig/sentdm/models/call_retrieve_params.rbs +30 -0
  128. data/sig/sentdm/models/call_timeline_entry.rbs +19 -0
  129. data/sig/sentdm/models/calls/api_response_of_list_of_call_participant.rbs +41 -0
  130. data/sig/sentdm/models/calls/call_participant.rbs +52 -0
  131. data/sig/sentdm/models/calls/call_participant_target.rbs +23 -0
  132. data/sig/sentdm/models/calls/participant_add_params.rbs +63 -0
  133. data/sig/sentdm/models/calls/participant_list_params.rbs +32 -0
  134. data/sig/sentdm/models/calls/participant_remove_all_params.rbs +34 -0
  135. data/sig/sentdm/models/calls/participant_remove_params.rbs +40 -0
  136. data/sig/sentdm/models/calls/participant_update_params.rbs +61 -0
  137. data/sig/sentdm/models/calls_list.rbs +26 -0
  138. data/sig/sentdm/models/channels/api_response_of_list_of_voice_number.rbs +41 -0
  139. data/sig/sentdm/models/channels/api_response_of_voice_callback_test.rbs +41 -0
  140. data/sig/sentdm/models/channels/api_response_of_voice_number.rbs +41 -0
  141. data/sig/sentdm/models/channels/api_response_of_voice_number_created.rbs +41 -0
  142. data/sig/sentdm/models/channels/api_response_of_voice_secret.rbs +41 -0
  143. data/sig/sentdm/models/channels/api_response_of_voice_token.rbs +41 -0
  144. data/sig/sentdm/models/channels/voice_callback_test.rbs +51 -0
  145. data/sig/sentdm/models/channels/voice_callback_test_error_info.rbs +28 -0
  146. data/sig/sentdm/models/channels/voice_callback_test_request_info.rbs +34 -0
  147. data/sig/sentdm/models/channels/voice_callback_test_response_info.rbs +20 -0
  148. data/sig/sentdm/models/channels/voice_create_params.rbs +64 -0
  149. data/sig/sentdm/models/channels/voice_create_token_params.rbs +61 -0
  150. data/sig/sentdm/models/channels/voice_list_params.rbs +27 -0
  151. data/sig/sentdm/models/channels/voice_number.rbs +57 -0
  152. data/sig/sentdm/models/channels/voice_number_created.rbs +17 -0
  153. data/sig/sentdm/models/channels/voice_retrieve_params.rbs +32 -0
  154. data/sig/sentdm/models/channels/voice_rotate_secret_params.rbs +40 -0
  155. data/sig/sentdm/models/channels/voice_secret.rbs +17 -0
  156. data/sig/sentdm/models/channels/voice_test_params.rbs +40 -0
  157. data/sig/sentdm/models/channels/voice_token.rbs +40 -0
  158. data/sig/sentdm/models/channels/voice_update_params.rbs +78 -0
  159. data/sig/sentdm/models/webhook_list_events_response.rbs +1 -107
  160. data/sig/sentdm/models.rbs +36 -0
  161. data/sig/sentdm/resources/calls/participants.rbs +50 -0
  162. data/sig/sentdm/resources/calls.rbs +50 -0
  163. data/sig/sentdm/resources/channels/voice.rbs +68 -0
  164. data/sig/sentdm/resources/channels.rbs +9 -0
  165. metadata +152 -2
@@ -0,0 +1,381 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sentdm
4
+ module Resources
5
+ class Channels
6
+ # The senders you send from, one per channel.
7
+ #
8
+ # **SMS is a list of markets**, each keyed by `(country, number_type)` — a
9
+ # customer can hold `us/10dlc` and `gb/alphanumeric` at once, so a market is
10
+ # addressed by the pair rather than by country alone. **WhatsApp and RCS are
11
+ # single**: a customer has one business account and one agent. **Voice is per
12
+ # number**: each number you hold can carry phone calls on its own
13
+ # (`POST /v3/channels/voice`), each with the callback URL Sent asks what to do
14
+ # with its calls, one of them is the default line for calls placed from your app,
15
+ # and voice tokens are minted under `POST /v3/channels/voice/tokens`. Read your
16
+ # voice numbers with `GET /v3/channels/voice` and change one with
17
+ # `PATCH /v3/channels/voice/{number}`.
18
+ #
19
+ # ## Compliance lives on the market
20
+ #
21
+ # Adding a market records everything that market registers with, in its
22
+ # `compliance` object. Only **US `TEN_DLC`** registers with a regime — The
23
+ # Campaign Registry — and it is the only market whose compliance carries `brand`
24
+ # and `campaign`. Everywhere else compliance is documents, and many markets ask
25
+ # for none at all.
26
+ #
27
+ # `GET` and `PATCH` on a market return and accept the same shape, so what comes
28
+ # back can be sent back: an omitted key is left alone, and a key reported in
29
+ # `requirements` is the path into the body that clears it.
30
+ #
31
+ # Call `GET /v3/compliance/requirements` first — it answers what a market demands
32
+ # before you hold it, with a body you can fill in and post.
33
+ class Voice
34
+ # Some parameter documentations has been truncated, see
35
+ # {Sentdm::Models::Channels::VoiceCreateParams} for more details.
36
+ #
37
+ # Adds voice to one of the numbers you hold, or gives you a new one. Send `number`
38
+ # for a number that is already yours (see `GET /v3/channels`); leave it out to be
39
+ # given a new US number, optionally in a particular `area_code`. Sending both is
40
+ # refused. Nothing registers, so the number can carry calls as soon as this
41
+ # returns.
42
+ #
43
+ # What happens on a call is decided by your `callback_url`: when a call arrives on
44
+ # the number, or a caller presses a key on a menu, Sent POSTs a signed question
45
+ # there and follows the answer. The response carries the `callback_secret` the
46
+ # questions are signed with, the one time it is shown without rotating; verify a
47
+ # question the way you verify a webhook. `POST /v3/channels/voice/{number}/test`
48
+ # sends a test question and reports the verdict.
49
+ #
50
+ # Your first voice number becomes the line app-originated calls are placed from
51
+ # when a voice token names no number; send `default_for_app_calls: true` to give
52
+ # that role to another number. A number you turned off earlier is turned back on,
53
+ # and the same number with a different `callback_url` has its URL replaced and
54
+ # keeps its secret.
55
+ #
56
+ # Read the number's settings with `GET /v3/channels/voice` and change them with
57
+ # `PATCH /v3/channels/voice/{number}`.
58
+ #
59
+ # With `sandbox: true` the request is validated and a simulated number reported
60
+ # with `202`; nothing is written and no number is bought.
61
+ #
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: {})
63
+ #
64
+ # @param callback_url [String] Body param: Where Sent asks what to do with each call on this number: an absolut
65
+ #
66
+ # @param area_code [String, nil] Body param: The US area code a new number should be in, as 212. Only for a reque
67
+ #
68
+ # @param default_for_app_calls [Boolean, nil] Body param: Make this the line app-originated calls are placed from when a voice
69
+ #
70
+ # @param number [String, nil] Body param: One of your phone numbers, in E.164 format. Leave the field out enti
71
+ #
72
+ # @param sandbox [Boolean] Body param: Sandbox flag - when true, the operation is simulated without side ef
73
+ #
74
+ # @param idempotency_key [String] Header param: Unique key to ensure idempotent request processing. Must be 1-255
75
+ #
76
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
77
+ #
78
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
79
+ #
80
+ # @return [Sentdm::Models::Channels::APIResponseOfVoiceNumberCreated]
81
+ #
82
+ # @see Sentdm::Models::Channels::VoiceCreateParams
83
+ def create(params)
84
+ parsed, options = Sentdm::Channels::VoiceCreateParams.dump_request(params)
85
+ header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
86
+ @client.request(
87
+ method: :post,
88
+ path: "v3/channels/voice",
89
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
90
+ body: parsed.except(*header_params.keys),
91
+ model: Sentdm::Channels::APIResponseOfVoiceNumberCreated,
92
+ options: options
93
+ )
94
+ end
95
+
96
+ # Some parameter documentations has been truncated, see
97
+ # {Sentdm::Models::Channels::VoiceRetrieveParams} for more details.
98
+ #
99
+ # Reads one of your voice numbers, active or inactive: its status, whether it is
100
+ # the default line for calls placed from your app, and its callback URL. The
101
+ # signing secret is not on this read.
102
+ #
103
+ # The same shape `GET /v3/channels/voice` lists, and the same shape `PATCH` on
104
+ # this path accepts and returns, so what comes back can be sent back.
105
+ #
106
+ # The number is the E.164 value in the path with the plus sign URL-encoded
107
+ # (`%2B`).
108
+ #
109
+ # @overload retrieve(number, x_profile_id: nil, request_options: {})
110
+ #
111
+ # @param number [String] The number in E.164 format with the plus sign URL-encoded, e.g. %2B12125550100
112
+ #
113
+ # @param x_profile_id [String] Profile UUID to scope the request to a child profile. Only organization API keys
114
+ #
115
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
116
+ #
117
+ # @return [Sentdm::Models::Channels::APIResponseOfVoiceNumber]
118
+ #
119
+ # @see Sentdm::Models::Channels::VoiceRetrieveParams
120
+ def retrieve(number, params = {})
121
+ parsed, options = Sentdm::Channels::VoiceRetrieveParams.dump_request(params)
122
+ @client.request(
123
+ method: :get,
124
+ path: ["v3/channels/voice/%1$s", number],
125
+ headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
126
+ model: Sentdm::Channels::APIResponseOfVoiceNumber,
127
+ options: options
128
+ )
129
+ end
130
+
131
+ # Some parameter documentations has been truncated, see
132
+ # {Sentdm::Models::Channels::VoiceUpdateParams} for more details.
133
+ #
134
+ # Changes one of your voice numbers and answers with the number as stored, the
135
+ # same shape `GET` on this path returns, so what comes back can be sent back.
136
+ #
137
+ # ## What it changes
138
+ #
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 is kept, and a number that was waiting for its first URL is turned on |
145
+ # | key omitted | left exactly as it is |
146
+ #
147
+ # `status` is matched ignoring case. Any combination is accepted:
148
+ # `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.
151
+ #
152
+ # ## What it will refuse
153
+ #
154
+ # **`default_for_app_calls: false` is `400`.** An account with active voice
155
+ # numbers always has exactly one default, so the default moves by giving it to
156
+ # another number.
157
+ #
158
+ # **Turning the default line off is `409`** while other active voice numbers
159
+ # remain. Move the default to another number first. Turning off your last voice
160
+ # number is allowed; that turns phone calls off.
161
+ #
162
+ # **Making an inactive number the default is `400`.** Send `status: "ACTIVE"` in
163
+ # the same call.
164
+ #
165
+ # A number added without a `callback_url` is `INACTIVE` for that one reason, so
166
+ # sending it a `callback_url` turns it on by itself, and it becomes your default
167
+ # line if you have no other active voice number. A number you turned off while it
168
+ # had a URL stays off.
169
+ #
170
+ # **A number you never turned voice on for is `404`.** Add it with
171
+ # `POST /v3/channels/voice`.
172
+ #
173
+ # The number is the E.164 value in the path with the plus sign URL-encoded
174
+ # (`%2B`).
175
+ #
176
+ # With `sandbox: true` nothing is written: the request is validated against the
177
+ # stored number and the number is reported with `200` as it would read after the
178
+ # change.
179
+ #
180
+ # @overload update(number, callback_url: nil, default_for_app_calls: nil, sandbox: nil, status: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
181
+ #
182
+ # @param number [String] Path param: The number in E.164 format with the plus sign URL-encoded, e.g. %2B1
183
+ #
184
+ # @param callback_url [String, nil] Body param: A new callback URL for the number, active or not: an absolute HTTP o
185
+ #
186
+ # @param default_for_app_calls [Boolean, nil] Body param: true makes this the line app-originated calls are placed from when a
187
+ #
188
+ # @param sandbox [Boolean] Body param: Sandbox flag - when true, the operation is simulated without side ef
189
+ #
190
+ # @param status [Symbol, Sentdm::Models::Channels::VoiceUpdateParams::Status, nil] Body param: ACTIVE turns calls on for the number again, INACTIVE turns them off.
191
+ #
192
+ # @param idempotency_key [String] Header param: Unique key to ensure idempotent request processing. Must be 1-255
193
+ #
194
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
195
+ #
196
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
197
+ #
198
+ # @return [Sentdm::Models::Channels::APIResponseOfVoiceNumber]
199
+ #
200
+ # @see Sentdm::Models::Channels::VoiceUpdateParams
201
+ def update(number, params = {})
202
+ parsed, options = Sentdm::Channels::VoiceUpdateParams.dump_request(params)
203
+ header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
204
+ @client.request(
205
+ method: :patch,
206
+ path: ["v3/channels/voice/%1$s", number],
207
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
208
+ body: parsed.except(*header_params.keys),
209
+ model: Sentdm::Channels::APIResponseOfVoiceNumber,
210
+ options: options
211
+ )
212
+ end
213
+
214
+ # Some parameter documentations has been truncated, see
215
+ # {Sentdm::Models::Channels::VoiceListParams} for more details.
216
+ #
217
+ # Every number you turned phone calls on for, active or inactive, oldest first.
218
+ # Each entry carries the number's status, whether it is the default line for calls
219
+ # placed from your app, and its callback URL. The signing secret is never on a
220
+ # read; it is shown when voice is turned on and by
221
+ # `POST /v3/channels/voice/{number}/rotate-secret`.
222
+ #
223
+ # The same entries `GET /v3/channels` reports under `voice`, and the same shape
224
+ # `GET /v3/channels/voice/{number}` returns for one of them. Change a number with
225
+ # `PATCH /v3/channels/voice/{number}`.
226
+ #
227
+ # @overload list(x_profile_id: nil, request_options: {})
228
+ #
229
+ # @param x_profile_id [String] Profile UUID to scope the request to a child profile. Only organization API keys
230
+ #
231
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
232
+ #
233
+ # @return [Sentdm::Models::Channels::APIResponseOfListOfVoiceNumber]
234
+ #
235
+ # @see Sentdm::Models::Channels::VoiceListParams
236
+ def list(params = {})
237
+ parsed, options = Sentdm::Channels::VoiceListParams.dump_request(params)
238
+ @client.request(
239
+ method: :get,
240
+ path: "v3/channels/voice",
241
+ headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
242
+ model: Sentdm::Channels::APIResponseOfListOfVoiceNumber,
243
+ options: options
244
+ )
245
+ end
246
+
247
+ # Some parameter documentations has been truncated, see
248
+ # {Sentdm::Models::Channels::VoiceCreateTokenParams} for more details.
249
+ #
250
+ # Mints a short-lived token for one of your app users. Call this from your backend
251
+ # and return the token to your app, which passes it to the voice client SDK to
252
+ # register. The identity is bound to the given number, or to your default app-call
253
+ # number when omitted, and calls placed by that identity are routed through the
254
+ # bound number. Minting again re-binds the identity, so an identity can move
255
+ # between numbers.
256
+ #
257
+ # @overload create_token(identity: nil, number: nil, sandbox: nil, ttl: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
258
+ #
259
+ # @param identity [String] Body param: Your identifier for the app user, such as an agent or account id. Le
260
+ #
261
+ # @param number [String, nil] Body param: One of your voice-enabled phone numbers in E.164 format. Calls place
262
+ #
263
+ # @param sandbox [Boolean] Body param: Sandbox flag - when true, the operation is simulated without side ef
264
+ #
265
+ # @param ttl [Integer, nil] Body param: Token lifetime in seconds. Defaults to 600 and cannot exceed 3600.
266
+ #
267
+ # @param idempotency_key [String] Header param: Unique key to ensure idempotent request processing. Must be 1-255
268
+ #
269
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
270
+ #
271
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
272
+ #
273
+ # @return [Sentdm::Models::Channels::APIResponseOfVoiceToken]
274
+ #
275
+ # @see Sentdm::Models::Channels::VoiceCreateTokenParams
276
+ def create_token(params = {})
277
+ parsed, options = Sentdm::Channels::VoiceCreateTokenParams.dump_request(params)
278
+ header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
279
+ @client.request(
280
+ method: :post,
281
+ path: "v3/channels/voice/tokens",
282
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
283
+ body: parsed.except(*header_params.keys),
284
+ model: Sentdm::Channels::APIResponseOfVoiceToken,
285
+ options: options
286
+ )
287
+ end
288
+
289
+ # Some parameter documentations has been truncated, see
290
+ # {Sentdm::Models::Channels::VoiceRotateSecretParams} for more details.
291
+ #
292
+ # Generates a new signing secret for the questions Sent sends to this number's
293
+ # callback URL and returns it. The previous secret stops signing immediately, so
294
+ # update your backend before the next call reaches it. The number is the E.164
295
+ # value in the path with the plus sign URL-encoded (`%2B`).
296
+ #
297
+ # With `sandbox: true` a secret is generated and returned with `202`, and nothing
298
+ # is written.
299
+ #
300
+ # @overload rotate_secret(number, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
301
+ #
302
+ # @param number [String] Path param: The voice number from the route, in E.164 format with the plus sign
303
+ #
304
+ # @param sandbox [Boolean] Body param: Sandbox flag - when true, the operation is simulated without side ef
305
+ #
306
+ # @param idempotency_key [String] Header param: Unique key to ensure idempotent request processing. Must be 1-255
307
+ #
308
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
309
+ #
310
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
311
+ #
312
+ # @return [Sentdm::Models::Channels::APIResponseOfVoiceSecret]
313
+ #
314
+ # @see Sentdm::Models::Channels::VoiceRotateSecretParams
315
+ def rotate_secret(number, params = {})
316
+ parsed, options = Sentdm::Channels::VoiceRotateSecretParams.dump_request(params)
317
+ header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
318
+ @client.request(
319
+ method: :post,
320
+ path: ["v3/channels/voice/%1$s/rotate-secret", number],
321
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
322
+ body: parsed.except(*header_params.keys),
323
+ model: Sentdm::Channels::APIResponseOfVoiceSecret,
324
+ options: options
325
+ )
326
+ end
327
+
328
+ # Some parameter documentations has been truncated, see
329
+ # {Sentdm::Models::Channels::VoiceTestParams} for more details.
330
+ #
331
+ # Sends a synthetic call.request question, flagged "test": true, to the number's
332
+ # callback URL, signed with that number's real secret, and reports what came back.
333
+ # Use it to build and debug your callback endpoint without placing calls: no call
334
+ # is placed, nothing is billed, and nothing is stored. One attempt with the same
335
+ # deadline as a live call, no retry. The outcome is ok when your endpoint answered
336
+ # 2xx with a valid answer; otherwise it is timeout, connection_failed, http_error
337
+ # or invalid_answer, with the reason and, for an invalid answer, the field at
338
+ # fault. The number is the E.164 value in the path with the plus sign URL-encoded
339
+ # (`%2B`).
340
+ #
341
+ # With `sandbox: true` nothing is sent: the verdict comes back ok with `202` and
342
+ # no request or response in it.
343
+ #
344
+ # @overload test_(number, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {})
345
+ #
346
+ # @param number [String] Path param: The voice number from the route, in E.164 format with the plus sign
347
+ #
348
+ # @param sandbox [Boolean] Body param: Sandbox flag - when true, the operation is simulated without side ef
349
+ #
350
+ # @param idempotency_key [String] Header param: Unique key to ensure idempotent request processing. Must be 1-255
351
+ #
352
+ # @param x_profile_id [String] Header param: Profile UUID to scope the request to a child profile. Only organiz
353
+ #
354
+ # @param request_options [Sentdm::RequestOptions, Hash{Symbol=>Object}, nil]
355
+ #
356
+ # @return [Sentdm::Models::Channels::APIResponseOfVoiceCallbackTest]
357
+ #
358
+ # @see Sentdm::Models::Channels::VoiceTestParams
359
+ def test_(number, params = {})
360
+ parsed, options = Sentdm::Channels::VoiceTestParams.dump_request(params)
361
+ header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
362
+ @client.request(
363
+ method: :post,
364
+ path: ["v3/channels/voice/%1$s/test", number],
365
+ headers: parsed.slice(*header_params.keys).transform_keys(header_params),
366
+ body: parsed.except(*header_params.keys),
367
+ model: Sentdm::Channels::APIResponseOfVoiceCallbackTest,
368
+ options: options
369
+ )
370
+ end
371
+
372
+ # @api private
373
+ #
374
+ # @param client [Sentdm::Client]
375
+ def initialize(client:)
376
+ @client = client
377
+ end
378
+ end
379
+ end
380
+ end
381
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sentdm
4
+ module Resources
5
+ class Channels
6
+ # The senders you send from, one per channel.
7
+ #
8
+ # **SMS is a list of markets**, each keyed by `(country, number_type)` — a
9
+ # customer can hold `us/10dlc` and `gb/alphanumeric` at once, so a market is
10
+ # addressed by the pair rather than by country alone. **WhatsApp and RCS are
11
+ # single**: a customer has one business account and one agent. **Voice is per
12
+ # number**: each number you hold can carry phone calls on its own
13
+ # (`POST /v3/channels/voice`), each with the callback URL Sent asks what to do
14
+ # with its calls, one of them is the default line for calls placed from your app,
15
+ # and voice tokens are minted under `POST /v3/channels/voice/tokens`. Read your
16
+ # voice numbers with `GET /v3/channels/voice` and change one with
17
+ # `PATCH /v3/channels/voice/{number}`.
18
+ #
19
+ # ## Compliance lives on the market
20
+ #
21
+ # Adding a market records everything that market registers with, in its
22
+ # `compliance` object. Only **US `TEN_DLC`** registers with a regime — The
23
+ # Campaign Registry — and it is the only market whose compliance carries `brand`
24
+ # and `campaign`. Everywhere else compliance is documents, and many markets ask
25
+ # for none at all.
26
+ #
27
+ # `GET` and `PATCH` on a market return and accept the same shape, so what comes
28
+ # back can be sent back: an omitted key is left alone, and a key reported in
29
+ # `requirements` is the path into the body that clears it.
30
+ #
31
+ # Call `GET /v3/compliance/requirements` first — it answers what a market demands
32
+ # before you hold it, with a body you can fill in and post.
33
+ # @return [Sentdm::Resources::Channels::Voice]
34
+ attr_reader :voice
35
+
36
+ # @api private
37
+ #
38
+ # @param client [Sentdm::Client]
39
+ def initialize(client:)
40
+ @client = client
41
+ @voice = Sentdm::Resources::Channels::Voice.new(client: client)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sentdm
4
- VERSION = "0.34.0"
4
+ VERSION = "0.35.0"
5
5
  end
data/lib/sentdm.rb CHANGED
@@ -52,14 +52,19 @@ require_relative "sentdm/errors"
52
52
  require_relative "sentdm/internal/transport/base_client"
53
53
  require_relative "sentdm/internal/transport/pooled_net_requester"
54
54
  require_relative "sentdm/client"
55
+ require_relative "sentdm/internal/calls_page"
55
56
  require_relative "sentdm/internal/contacts_page"
56
57
  require_relative "sentdm/internal/conversations_page"
57
58
  require_relative "sentdm/internal/templates_page"
58
59
  require_relative "sentdm/internal/webhook_events_page"
59
60
  require_relative "sentdm/internal/webhooks_page"
60
61
  require_relative "sentdm/models/mutation_request"
62
+ require_relative "sentdm/models/channels/voice_number"
61
63
  require_relative "sentdm/models/template_body_content"
62
64
  require_relative "sentdm/models/api_meta"
65
+ require_relative "sentdm/models/api_response_of_call"
66
+ require_relative "sentdm/models/api_response_of_call_recordings"
67
+ require_relative "sentdm/models/api_response_of_calls_list"
63
68
  require_relative "sentdm/models/api_response_of_contact"
64
69
  require_relative "sentdm/models/api_response_of_contact_message_summary"
65
70
  require_relative "sentdm/models/api_response_of_conversation_messages_list"
@@ -73,8 +78,49 @@ require_relative "sentdm/models/brand_business_info"
73
78
  require_relative "sentdm/models/brand_compliance_info"
74
79
  require_relative "sentdm/models/brand_contact_info"
75
80
  require_relative "sentdm/models/brands_brand_data"
81
+ require_relative "sentdm/models/call"
82
+ require_relative "sentdm/models/call_event"
83
+ require_relative "sentdm/models/call_event_payload"
84
+ require_relative "sentdm/models/call_hangup_params"
85
+ require_relative "sentdm/models/call_list_params"
86
+ require_relative "sentdm/models/call_list_recordings_params"
87
+ require_relative "sentdm/models/call_party"
88
+ require_relative "sentdm/models/call_recording"
89
+ require_relative "sentdm/models/call_recordings"
90
+ require_relative "sentdm/models/call_record_params"
91
+ require_relative "sentdm/models/call_retrieve_params"
92
+ require_relative "sentdm/models/calls/api_response_of_list_of_call_participant"
93
+ require_relative "sentdm/models/calls/call_participant"
94
+ require_relative "sentdm/models/calls/call_participant_target"
95
+ require_relative "sentdm/models/calls/participant_add_params"
96
+ require_relative "sentdm/models/calls/participant_list_params"
97
+ require_relative "sentdm/models/calls/participant_remove_all_params"
98
+ require_relative "sentdm/models/calls/participant_remove_params"
99
+ require_relative "sentdm/models/calls/participant_update_params"
100
+ require_relative "sentdm/models/calls_list"
101
+ require_relative "sentdm/models/call_timeline_entry"
76
102
  require_relative "sentdm/models/channel_event"
77
103
  require_relative "sentdm/models/channel_event_payload"
104
+ require_relative "sentdm/models/channels/api_response_of_list_of_voice_number"
105
+ require_relative "sentdm/models/channels/api_response_of_voice_callback_test"
106
+ require_relative "sentdm/models/channels/api_response_of_voice_number"
107
+ require_relative "sentdm/models/channels/api_response_of_voice_number_created"
108
+ require_relative "sentdm/models/channels/api_response_of_voice_secret"
109
+ require_relative "sentdm/models/channels/api_response_of_voice_token"
110
+ require_relative "sentdm/models/channels/voice_callback_test"
111
+ require_relative "sentdm/models/channels/voice_callback_test_error_info"
112
+ require_relative "sentdm/models/channels/voice_callback_test_request_info"
113
+ require_relative "sentdm/models/channels/voice_callback_test_response_info"
114
+ require_relative "sentdm/models/channels/voice_create_params"
115
+ require_relative "sentdm/models/channels/voice_create_token_params"
116
+ require_relative "sentdm/models/channels/voice_list_params"
117
+ require_relative "sentdm/models/channels/voice_number_created"
118
+ require_relative "sentdm/models/channels/voice_retrieve_params"
119
+ require_relative "sentdm/models/channels/voice_rotate_secret_params"
120
+ require_relative "sentdm/models/channels/voice_secret"
121
+ require_relative "sentdm/models/channels/voice_test_params"
122
+ require_relative "sentdm/models/channels/voice_token"
123
+ require_relative "sentdm/models/channels/voice_update_params"
78
124
  require_relative "sentdm/models/contact_create_params"
79
125
  require_relative "sentdm/models/contact_delete_params"
80
126
  require_relative "sentdm/models/contact_event"
@@ -168,6 +214,10 @@ require_relative "sentdm/models/webhook_test_response"
168
214
  require_relative "sentdm/models/webhook_toggle_status_params"
169
215
  require_relative "sentdm/models/webhook_update_params"
170
216
  require_relative "sentdm/models"
217
+ require_relative "sentdm/resources/calls"
218
+ require_relative "sentdm/resources/calls/participants"
219
+ require_relative "sentdm/resources/channels"
220
+ require_relative "sentdm/resources/channels/voice"
171
221
  require_relative "sentdm/resources/contacts"
172
222
  require_relative "sentdm/resources/conversations"
173
223
  require_relative "sentdm/resources/me"
@@ -110,6 +110,29 @@ module Sentdm
110
110
  sig { returns(Sentdm::Resources::Conversations) }
111
111
  attr_reader :conversations
112
112
 
113
+ # Phone calls from the numbers you hold, driven by your own callback URL.
114
+ #
115
+ # `POST /v3/channels/voice` enables a number for calls, with the callback URL Sent
116
+ # asks what to do with each call on it, and `POST /v3/channels/voice/tokens` mints
117
+ # a short-lived token that lets a user of your app place and receive calls as that
118
+ # number. When a call arrives or a caller presses a key, a signed question is
119
+ # POSTed to the callback URL and the answer decides the call;
120
+ # `POST /v3/channels/voice/{number}/test` checks the URL answers the way we need
121
+ # before a real call reaches it, and
122
+ # `POST /v3/channels/voice/{number}/rotate-secret` replaces the signing secret.
123
+ # The call events themselves (`call.completed` and the rest) arrive through your
124
+ # webhooks.
125
+ #
126
+ # Every call is a record under `/v3/calls`: read it, list its recordings once one
127
+ # is ready, hang it up, start or stop recording, and add, mute or remove
128
+ # conference participants while it is live. A leg to a phone number runs for at
129
+ # most what your balance affords at the destination's rate.
130
+ sig { returns(Sentdm::Resources::Calls) }
131
+ attr_reader :calls
132
+
133
+ sig { returns(Sentdm::Resources::Channels) }
134
+ attr_reader :channels
135
+
113
136
  # Who the current key is.
114
137
  #
115
138
  # `GET /v3/me` answers with the account the key authenticates as, which is the
@@ -0,0 +1,71 @@
1
+ # typed: strong
2
+
3
+ module Sentdm
4
+ module Internal
5
+ class CallsPage
6
+ include Sentdm::Internal::Type::BasePage
7
+
8
+ Elem = type_member
9
+
10
+ sig { returns(Data) }
11
+ attr_accessor :data
12
+
13
+ # @api private
14
+ sig { returns(String) }
15
+ def inspect
16
+ end
17
+
18
+ class Data < Sentdm::Internal::Type::BaseModel
19
+ OrHash = T.type_alias { T.any(Data, Sentdm::Internal::AnyHash) }
20
+
21
+ sig { returns(T.nilable(T::Array[T.anything])) }
22
+ attr_reader :calls
23
+
24
+ sig { params(calls: T::Array[T.anything]).void }
25
+ attr_writer :calls
26
+
27
+ sig { returns(T.nilable(Data::Pagination)) }
28
+ attr_reader :pagination
29
+
30
+ sig { params(pagination: Data::Pagination::OrHash).void }
31
+ attr_writer :pagination
32
+
33
+ sig do
34
+ params(
35
+ calls: T::Array[T.anything],
36
+ pagination: Data::Pagination::OrHash
37
+ ).returns(T.attached_class)
38
+ end
39
+ def self.new(calls: nil, pagination: nil)
40
+ end
41
+
42
+ sig do
43
+ override.returns(
44
+ { calls: T::Array[T.anything], pagination: Data::Pagination }
45
+ )
46
+ end
47
+ def to_hash
48
+ end
49
+
50
+ class Pagination < Sentdm::Internal::Type::BaseModel
51
+ OrHash =
52
+ T.type_alias { T.any(Data::Pagination, Sentdm::Internal::AnyHash) }
53
+
54
+ sig { returns(T.nilable(T::Boolean)) }
55
+ attr_reader :has_more
56
+
57
+ sig { params(has_more: T::Boolean).void }
58
+ attr_writer :has_more
59
+
60
+ sig { params(has_more: T::Boolean).returns(T.attached_class) }
61
+ def self.new(has_more: nil)
62
+ end
63
+
64
+ sig { override.returns({ has_more: T::Boolean }) }
65
+ def to_hash
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end