didit-sdk 2.28.0 → 2.30.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.
@@ -0,0 +1,299 @@
1
+ # Code generated by codegen from openapi/*.json. DO NOT EDIT.
2
+ # frozen_string_literal: true
3
+
4
+ module Didit
5
+ module Resources
6
+ # The +messages+ resource.
7
+ class Messages < Didit::Resource
8
+ # Cancel a scheduled message
9
+ #
10
+ # Cancel a message scheduled with `schedule_at`, before its time: only a `scheduled` message can be cancelled,
11
+ # and nothing is charged for it. A `queued` or `sending` message is already going out and settles within seconds
12
+ # (`sent`, `delivered` or `failed`): it cannot be cancelled.
13
+ #
14
+ # A scoped API key needs write access to messages.
15
+ #
16
+ # +POST /v3/messages/{message_id}/cancel/+
17
+ #
18
+ # @param message_id [String] The message's id, or the id of any of its attempts.
19
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
20
+ # @return [Didit::Types::Message]
21
+ def cancel(message_id, request_options: nil)
22
+ @client.request(
23
+ :post,
24
+ "/v3/messages/{message_id}/cancel/",
25
+ path_params: { "message_id" => message_id },
26
+ response: Types::Message,
27
+ request_options: request_options
28
+ )
29
+ end
30
+
31
+ # Delete a message
32
+ #
33
+ # Delete the message, every attempt, its text and its recipient. Deletion is irreversible. A message that has
34
+ # not gone out yet cannot be deleted (`409`): cancel a `scheduled` one first; a `queued` or `sending` one
35
+ # settles within seconds. An SMS already `sent` and waiting for its delivery report can be deleted, except
36
+ # during the moment it is handed to another route (`409`, retry within seconds); what it owes is charged first,
37
+ # and its delivery report then finds nothing. Usage already billed stays on your invoice; it holds no text or
38
+ # address.
39
+ #
40
+ # A scoped API key needs write access to messages.
41
+ #
42
+ # +DELETE /v3/messages/{message_id}/+
43
+ #
44
+ # @param message_id [String] The message's id, or the id of any of its attempts.
45
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
46
+ # @return [nil]
47
+ def delete(message_id, request_options: nil)
48
+ @client.request(
49
+ :delete,
50
+ "/v3/messages/{message_id}/",
51
+ path_params: { "message_id" => message_id },
52
+ request_options: request_options
53
+ )
54
+ end
55
+
56
+ # List messages
57
+ #
58
+ # Your messages, newest first, with every attempt.
59
+ #
60
+ # A scoped API key needs read access to messages.
61
+ #
62
+ # +GET /v3/messages/+
63
+ #
64
+ # @param limit [Integer]
65
+ # @param offset [Integer]
66
+ # @param status [String]
67
+ # @param channel [String] The channel of the latest attempt.
68
+ # @param to [String] Recipient, exact. A message whose recipient was erased is not found by it.
69
+ # @param correlation_id [String]
70
+ # @param created_after [Time, String]
71
+ # @param created_before [Time, String]
72
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
73
+ # @return [Didit::Page<Didit::Types::Message>]
74
+ def list(
75
+ limit: OMIT,
76
+ offset: OMIT,
77
+ status: OMIT,
78
+ channel: OMIT,
79
+ to: OMIT,
80
+ correlation_id: OMIT,
81
+ created_after: OMIT,
82
+ created_before: OMIT,
83
+ request_options: nil
84
+ )
85
+ @client.request(
86
+ :get,
87
+ "/v3/messages/",
88
+ query: {
89
+ "limit" => limit,
90
+ "offset" => offset,
91
+ "status" => status,
92
+ "channel" => channel,
93
+ "to" => to,
94
+ "correlation_id" => correlation_id,
95
+ "created_after" => created_after,
96
+ "created_before" => created_before
97
+ },
98
+ page: Types::Message,
99
+ request_options: request_options
100
+ )
101
+ end
102
+
103
+ # List message prices for a country
104
+ #
105
+ # What one message costs your organization on each channel to a country: SMS per segment (carrier price plus
106
+ # Didit's fee), WhatsApp per message (WhatsApp's utility rate plus Didit's fee from Didit's number; from your
107
+ # own connected WhatsApp Business account, `carrier` is `0.0000`: WhatsApp bills its rate to your account
108
+ # directly and Didit charges only its fee), email flat. Your plan's discount is applied to the fee. The SMS
109
+ # carrier part is an estimate; the billed one is the price the carrier reports.
110
+ #
111
+ # A scoped API key needs read access to messages.
112
+ #
113
+ # +GET /v3/messages/prices/+
114
+ #
115
+ # @param country [String] ISO 3166-1 alpha-2 country of the recipient.
116
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
117
+ # @return [Didit::Types::MessagePrices]
118
+ def list_prices(country:, request_options: nil)
119
+ @client.request(
120
+ :get,
121
+ "/v3/messages/prices/",
122
+ query: {
123
+ "country" => country
124
+ },
125
+ response: Types::MessagePrices,
126
+ request_options: request_options
127
+ )
128
+ end
129
+
130
+ # Retrieve a message
131
+ #
132
+ # One message with every attempt, by its id or the id of any of its attempts.
133
+ #
134
+ # A scoped API key needs read access to messages.
135
+ #
136
+ # +GET /v3/messages/{message_id}/+
137
+ #
138
+ # @param message_id [String] The message's id, or the id of any of its attempts.
139
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
140
+ # @return [Didit::Types::Message]
141
+ def retrieve(message_id, request_options: nil)
142
+ @client.request(
143
+ :get,
144
+ "/v3/messages/{message_id}/",
145
+ path_params: { "message_id" => message_id },
146
+ response: Types::Message,
147
+ request_options: request_options
148
+ )
149
+ end
150
+
151
+ # Retrieve the Messages API settings
152
+ #
153
+ # Your application's Messages API settings: how many days a message keeps its text and recipient.
154
+ #
155
+ # A scoped API key needs read access to application settings.
156
+ #
157
+ # +GET /v3/messages/settings/+
158
+ #
159
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
160
+ # @return [Didit::Types::MessagesSettings]
161
+ def retrieve_settings(request_options: nil)
162
+ @client.request(
163
+ :get,
164
+ "/v3/messages/settings/",
165
+ response: Types::MessagesSettings,
166
+ request_options: request_options
167
+ )
168
+ end
169
+
170
+ # Send a message
171
+ #
172
+ # Send a transactional SMS, WhatsApp or email message to a phone number or an email address, now or scheduled,
173
+ # from one of your templates or as free text. Free text goes out on SMS and email; WhatsApp delivers only an
174
+ # approved template, except inside a 24-hour reply window (the person wrote to you first), so a message that
175
+ # lists WhatsApp uses `template_id` for it to go out there.
176
+ #
177
+ # **Fallback.** List several `channels`: each is tried in order, and the next one is used when a channel cannot
178
+ # take the message (switched off, the recipient opted out, no approved WhatsApp template, balance) or when the
179
+ # message fails on it later (rejected, undeliverable, expired). Every attempt is in `attempts`; a skipped
180
+ # channel is a `failed` attempt with its `error` and no price.
181
+ #
182
+ # **Statuses** reach your webhook destinations subscribed to `message.status.updated`.
183
+ #
184
+ # **Billing.** SMS: the carrier's price plus Didit's fee, per segment. WhatsApp from Didit's number: WhatsApp's
185
+ # rate for the market plus Didit's fee; from your own connected WhatsApp Business account, WhatsApp bills its
186
+ # rate to your account directly and Didit charges only its fee. Email: a flat price. Your plan's discount
187
+ # applies to the fee, never to the carrier's or WhatsApp's part. A failed SMS or WhatsApp attempt, a skipped one
188
+ # and a cancelled one are free; an email is charged once the receiving mail system accepts it, so an email that
189
+ # bounces later is charged. SMS and WhatsApp open after your first top-up (`403 plan_locked`); a sandbox
190
+ # application simulates every message and charges nothing. See the [prices per
191
+ # country](/getting-started/pricing).
192
+ #
193
+ # **Retention.** Didit erases a message's text and recipient `retention_days` after its last event (created,
194
+ # sent, delivered, read, failed or cancelled; 30 days unless you set another value with `PATCH
195
+ # /v3/messages/settings/`); the message itself, its status, channel, country, segments, price and timestamps
196
+ # stay, so lists and invoices still add up. A message still waiting to go out (`scheduled`, `queued`, `sending`)
197
+ # keeps them until it goes out; one cancelled before it went out counts from its cancellation. A request no
198
+ # channel can take is refused and nothing of it is stored. To erase a message sooner, delete it with `DELETE
199
+ # /v3/messages/{message_id}/` once it went out or ended: cancel a `scheduled` message first; a `queued` or
200
+ # `sending` one settles within seconds.
201
+ #
202
+ # A scoped API key needs write access to messages.
203
+ #
204
+ # +POST /v3/messages/+
205
+ #
206
+ # @param to [String] Recipient: an E.164 phone number (`+447700900123`), or an email address for email.
207
+ # @param to_email [String] The email address for the `email` channel when `to` is a phone number.
208
+ # @param channels [Array<String>] Channels to try, in order. The next one is used when a channel cannot take the
209
+ # message (switched off, opted out, no approved WhatsApp template...) or the message fails on it. Default
210
+ # `["sms"]` for a phone number, `["email"]` for an email address.
211
+ # @param body [String] Free text, sent as written, for SMS and email. On WhatsApp free text goes out only inside
212
+ # a 24-hour reply window (the person wrote to you first); outside it WhatsApp delivers only an approved
213
+ # template, so use `template_id`, or a free-text WhatsApp attempt falls back to the next channel. Limits: SMS
214
+ # 1,000, WhatsApp 4,096, email 10,000 characters.
215
+ # @param template_id [String] One of your message templates; each channel uses the template's text for that
216
+ # channel.
217
+ # @param variables [Hash{String => String}] Values for the template's `{{variables}}`. Every variable of the
218
+ # text used needs one.
219
+ # @param locale [String] BCP-47 language of the template text. Default: the recipient country's language, then
220
+ # English.
221
+ # @param subject [String] Subject of a free-text email.
222
+ # @param schedule_at [Time, String] When to send it, up to 90 days ahead. Default: now.
223
+ # @param expires_at [Time, String] Validity: never sent after it. After the send time, at most 72 hours after
224
+ # it.
225
+ # @param correlation_id [String] Your reference, returned in every response and webhook, filterable in the list.
226
+ # @param options [Hash]
227
+ # @param idempotency_key [String] sent as the Idempotency-Key header
228
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
229
+ # @return [Didit::Types::Message]
230
+ def send_message(
231
+ to:,
232
+ to_email: OMIT,
233
+ channels: OMIT,
234
+ body: OMIT,
235
+ template_id: OMIT,
236
+ variables: OMIT,
237
+ locale: OMIT,
238
+ subject: OMIT,
239
+ schedule_at: OMIT,
240
+ expires_at: OMIT,
241
+ correlation_id: OMIT,
242
+ options: OMIT,
243
+ idempotency_key: OMIT,
244
+ request_options: nil
245
+ )
246
+ @client.request(
247
+ :post,
248
+ "/v3/messages/",
249
+ body: {
250
+ "to" => to,
251
+ "to_email" => to_email,
252
+ "channels" => channels,
253
+ "body" => body,
254
+ "template_id" => template_id,
255
+ "variables" => variables,
256
+ "locale" => locale,
257
+ "subject" => subject,
258
+ "schedule_at" => schedule_at,
259
+ "expires_at" => expires_at,
260
+ "correlation_id" => correlation_id,
261
+ "options" => options
262
+ },
263
+ headers: { "Idempotency-Key" => idempotency_key },
264
+ response: Types::Message,
265
+ request_options: request_options
266
+ )
267
+ end
268
+
269
+ # Update the Messages API settings
270
+ #
271
+ # Set how many days a message keeps its text and recipient, from 2 to 365 (default 30). Shortening the retention
272
+ # erases, within the hour, the text and recipient of every message already past the new one (irreversible); the
273
+ # messages themselves, with their status, channel, country, segments, price and timestamps, stay. Lengthening it
274
+ # applies to the messages not erased yet.
275
+ #
276
+ # A scoped API key needs write access to application settings.
277
+ #
278
+ # +PATCH /v3/messages/settings/+
279
+ #
280
+ # @param retention_days [Integer] Days after a message's last event (created, sent, delivered, read, failed or
281
+ # cancelled) before Didit erases its text and recipient (`to`, `body`, `subject` and template variables read
282
+ # `null` from then on). Status, channel, country, segments, price and timestamps stay. A message still waiting
283
+ # to go out (`scheduled`, `queued`, `sending`) is erased only after it went out; one cancelled before it wen...
284
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
285
+ # @return [Didit::Types::MessagesSettings]
286
+ def update_settings(retention_days:, request_options: nil)
287
+ @client.request(
288
+ :patch,
289
+ "/v3/messages/settings/",
290
+ body: {
291
+ "retention_days" => retention_days
292
+ },
293
+ response: Types::MessagesSettings,
294
+ request_options: request_options
295
+ )
296
+ end
297
+ end
298
+ end
299
+ end
@@ -8,9 +8,9 @@ module Didit
8
8
  # Get bank verification prices (public, unauthenticated)
9
9
  #
10
10
  # Returns the list price of each Bank Verification method in every country: bank sign-in with its balance and
11
- # transactions add-ons, and the account check. A method a country does not offer today shows as not available,
12
- # with no price. Use it to quote a bank step before you build a workflow, or to show bank prices in your own
13
- # product.
11
+ # transactions add-ons, ongoing access to bank data, and the account check. A method a country does not offer
12
+ # today shows as not available, with no price. Use it to quote a bank step before you build a workflow, or to
13
+ # show bank prices in your own product.
14
14
  #
15
15
  # Public: send no auth header. The response contains no organization data and is the same for every caller. It
16
16
  # is cached publicly for one hour and carries an `ETag`, so send `If-None-Match` to get a `304 Not Modified`
@@ -712,8 +712,8 @@ module Didit
712
712
  # @param ownership_validation_mode [String] See the response field of the same name.
713
713
  # @param simplified_validation_threshold [String] Decimal string, 0 or more.
714
714
  # @param data_sharing_fields [Hash] Merged per entity type: an entity type you leave out keeps its current
715
- # choice. A choice that cannot meet the originator obligations of your `jurisdiction` regime (EU TFR or FATF
716
- # Recommendation 16), an empty list included, is refused with `400`.
715
+ # choice. A choice that cannot meet the originator obligations of your `jurisdiction` regime (EU TFR, FINTRAC
716
+ # for `canada`, FinCEN for `us`, or FATF Recommendation 16), an empty list included, is refused with `400`.
717
717
  # @param matching_rules [Hash] Merged per entity type, and per field inside it. A field that entity type does
718
718
  # not compare (for example `date_of_birth` for `company`) is refused with `400`.
719
719
  # @param inbound_auto_accept [Boolean]
@@ -31,6 +31,7 @@ module Didit
31
31
  autoload :Ip, "didit/resources/ip"
32
32
  autoload :Kyb, "didit/resources/kyb"
33
33
  autoload :Lists, "didit/resources/lists"
34
+ autoload :Messages, "didit/resources/messages"
34
35
  autoload :MonitoringEvents, "didit/resources/monitoring_events"
35
36
  autoload :Networks, "didit/resources/networks"
36
37
  autoload :PassiveLiveness, "didit/resources/passive_liveness"
@@ -187,6 +188,11 @@ module Didit
187
188
  @lists ||= Resources::Lists.new(self)
188
189
  end
189
190
 
191
+ # @return [Didit::Resources::Messages]
192
+ def messages
193
+ @messages ||= Resources::Messages.new(self)
194
+ end
195
+
190
196
  # @return [Didit::Resources::MonitoringEvents]
191
197
  def monitoring_events
192
198
  @monitoring_events ||= Resources::MonitoringEvents.new(self)
@@ -3,6 +3,132 @@
3
3
 
4
4
  module Didit
5
5
  module Types
6
+ # `one_time` (default) reads the data once. `ongoing` keeps access open until the consent ends or someone stops
7
+ # it. With `institution_id` set, a bank that cannot keep access open answers `400 ongoing_access_not_available`
8
+ # before any screen. Without it, the bank picker lists only banks that can.
9
+ module BankCreateLinkParamsAccess
10
+ ONE_TIME = "one_time"
11
+ ONGOING = "ongoing"
6
12
 
13
+ VALUES = [ONE_TIME, ONGOING].freeze
14
+ end
15
+
16
+ # Known values of an open enum: the API may send others.
17
+ module BankCreateLinkParamsData
18
+ ACCOUNTS = "accounts"
19
+ BALANCES = "balances"
20
+ TRANSACTIONS = "transactions"
21
+
22
+ VALUES = [ACCOUNTS, BALANCES, TRANSACTIONS].freeze
23
+ end
24
+
25
+ # `reuse` (default) completes a link that resolves to accounts you already share as a renewal of that connection.
26
+ # `allow` creates an independent second connection.
27
+ module BankCreateLinkParamsDuplicates
28
+ REUSE = "reuse"
29
+ ALLOW = "allow"
30
+
31
+ VALUES = [REUSE, ALLOW].freeze
32
+ end
33
+
34
+ # `allow_extra_auth` lets a bank that asks for one more confirmation release older history.
35
+ module BankCreateLinkParamsExtendedHistory
36
+ STANDARD = "standard"
37
+ ALLOW_EXTRA_AUTH = "allow_extra_auth"
38
+
39
+ VALUES = [STANDARD, ALLOW_EXTRA_AUTH].freeze
40
+ end
41
+
42
+ # `connect` (default) creates a new connection. `renew` needs `connection_id` and reuses that connection's
43
+ # settings.
44
+ module BankCreateLinkParamsMode
45
+ CONNECT = "connect"
46
+ RENEW = "renew"
47
+
48
+ VALUES = [CONNECT, RENEW].freeze
49
+ end
50
+
51
+ # The Test Bank customer: `personal_basic` (one current account, 60 movements), `business_multi` (three accounts
52
+ # held by a company), `long_history` (one account with 400 days and 1,400 movements; a read returns the last 365
53
+ # days, so set `history_days` to 365), `pending` (includes pending transactions), `sparse_fields` (no value date,
54
+ # no counterparty IBAN, no bank reference) or `no_ongoing` (a bank that only allows one-time access: use
55
+ # `allow_one_time_fallback`).
56
+ module BankCreateLinkParamsSandboxPersona
57
+ PERSONAL_BASIC = "personal_basic"
58
+ BUSINESS_MULTI = "business_multi"
59
+ LONG_HISTORY = "long_history"
60
+ PENDING = "pending"
61
+ SPARSE_FIELDS = "sparse_fields"
62
+ NO_ONGOING = "no_ongoing"
63
+
64
+ VALUES = [PERSONAL_BASIC, BUSINESS_MULTI, LONG_HISTORY, PENDING, SPARSE_FIELDS, NO_ONGOING].freeze
65
+ end
66
+
67
+ # Known values of an open enum: the API may send others.
68
+ module BankCreateLinkParamsSandboxSwitches
69
+ PARTIAL_GRANT = "partial_grant"
70
+ RENEWAL_OTHER_LOGIN = "renewal_other_login"
71
+ EXPIRED_CURSOR = "expired_cursor"
72
+ WEBHOOK_TWICE = "webhook_twice"
73
+ MIDNIGHT_BOOKING = "midnight_booking"
74
+ BLOCKED_POPUP = "blocked_popup"
75
+ BANK_APP_RETURN = "bank_app_return"
76
+
77
+ VALUES = [PARTIAL_GRANT, RENEWAL_OTHER_LOGIN, EXPIRED_CURSOR, WEBHOOK_TWICE, MIDNIGHT_BOOKING, BLOCKED_POPUP, BANK_APP_RETURN].freeze
78
+ end
79
+
80
+ # Filters the picker and tells the bank which login to open where the bank separates them. Default `any`.
81
+ module BankCreateLinkParamsSegment
82
+ PERSONAL = "personal"
83
+ BUSINESS = "business"
84
+ ANY = "any"
85
+
86
+ VALUES = [PERSONAL, BUSINESS, ANY].freeze
87
+ end
88
+
89
+ # Known values of an open enum: the API may send others.
90
+ module BankListConnectionsParamsAccess
91
+ ONE_TIME = "one_time"
92
+ ONGOING = "ongoing"
93
+
94
+ VALUES = [ONE_TIME, ONGOING].freeze
95
+ end
96
+
97
+ # Known values of an open enum: the API may send others.
98
+ module BankListConnectionsParamsStatus
99
+ PENDING = "pending"
100
+ ACTIVE = "active"
101
+ RENEWAL_REQUIRED = "renewal_required"
102
+ PAUSED = "paused"
103
+ REVOKED = "revoked"
104
+ DELETED = "deleted"
105
+ FAILED = "failed"
106
+
107
+ VALUES = [PENDING, ACTIVE, RENEWAL_REQUIRED, PAUSED, REVOKED, DELETED, FAILED].freeze
108
+ end
109
+
110
+ # Known values of an open enum: the API may send others.
111
+ module BankListInstitutionsParamsAccess
112
+ ONE_TIME = "one_time"
113
+ ONGOING = "ongoing"
114
+
115
+ VALUES = [ONE_TIME, ONGOING].freeze
116
+ end
117
+
118
+ # Known values of an open enum: the API may send others.
119
+ module BankListInstitutionsParamsSegment
120
+ PERSONAL = "personal"
121
+ BUSINESS = "business"
122
+
123
+ VALUES = [PERSONAL, BUSINESS].freeze
124
+ end
125
+
126
+ # Known values of an open enum: the API may send others.
127
+ module BankListTransactionsParamsStatus
128
+ BOOKED = "booked"
129
+ PENDING = "pending"
130
+
131
+ VALUES = [BOOKED, PENDING].freeze
132
+ end
7
133
  end
8
134
  end