didit-sdk 2.34.0 → 2.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.
@@ -5,6 +5,26 @@ module Didit
5
5
  module Resources
6
6
  # The +phone+ resource.
7
7
  class Phone < Didit::Resource
8
+ # @return [Didit::Resources::Phone::Factors]
9
+ def factors
10
+ @factors ||= Factors.new(@client)
11
+ end
12
+
13
+ # @return [Didit::Resources::Phone::Network]
14
+ def network
15
+ @network ||= Network.new(@client)
16
+ end
17
+
18
+ # @return [Didit::Resources::Phone::SdkKeys]
19
+ def sdk_keys
20
+ @sdk_keys ||= SdkKeys.new(@client)
21
+ end
22
+
23
+ # @return [Didit::Resources::Phone::Silent]
24
+ def silent
25
+ @silent ||= Silent.new(@client)
26
+ end
27
+
8
28
  # Risk-score a phone number
9
29
  #
10
30
  # Resolve a phone number and return carrier, line-type, porting, disposable-number, cross-session match, and
@@ -19,7 +39,12 @@ module Didit
19
39
  # `phone.enrichment`. Both keys are absent when no usable intelligence data was returned.
20
40
  #
21
41
  # **Billing.** Live calls use Phone Risk API pricing. The request is billable once the lookup starts, even when
22
- # some best-effort fields are unavailable.
42
+ # some best-effort fields are unavailable. Phone Risk, including the optional `enable_social` add-on, is Phone
43
+ # usage: the free credit pays it only up to $1 a month, shared with phone verification codes, messages and the
44
+ # other Phone lookups. On the Free plan, what the $1 does not cover is paid from your top-up balance; Growth and
45
+ # Scale included credit pays for Phone in full. The request is refused with `403` only when the credit available
46
+ # to Phone, including the add-on, cannot cover it. Phone Risk has no first-top-up requirement; a top-up is
47
+ # needed only when the credit available to Phone (the free $1 or paid credit) cannot cover the lookup.
23
48
  #
24
49
  # **Sandbox.** Sandbox keys validate the request and return deterministic approved data without sending an OTP,
25
50
  # consuming credits, creating a session, or contributing to Networks.
@@ -131,12 +156,12 @@ module Didit
131
156
  #
132
157
  # +POST /v3/phone/check/+
133
158
  #
134
- # @param phone_number [String] The same phone number used in the matching [`POST
135
- # /v3/phone/send/`](/standalone-apis/phone-send) call, in E.164 format. This is what links the check to the
136
- # send.
137
159
  # @param code [String] The OTP the end user received. Must be 4-8 numeric digits - anything else returns `400`
138
160
  # without consuming an attempt. A well-formed but wrong code returns `200` with `status: "Failed"` and consumes
139
161
  # one of the 3 attempts.
162
+ # @param phone_number [String] The same phone number used in the matching [`POST
163
+ # /v3/phone/send/`](/standalone-apis/phone-send) call, in E.164 format. This is what links the check to the
164
+ # send.
140
165
  # @param duplicated_phone_number_action [String] What to do when the same number was already used by a different
141
166
  # user (different `vendor_data`) of your application. `DECLINE` flips the final `status` to `Declined`;
142
167
  # `NO_ACTION` records the risk in `phone.warnings` and fills `phone.matches`.
@@ -168,12 +193,16 @@ module Didit
168
193
  # @param phone_no_social_presence_action [String] Action when the social footprint check finds the number
169
194
  # registered on none of the platforms it covers. Only NO_ACTION and DECLINE are accepted on this endpoint;
170
195
  # REVIEW is available on the workflow configuration key of the same name.
196
+ # @param factor_id [String] A TOTP factor being checked instead of a phone code, as returned when it was
197
+ # enrolled; send the 4-8 digit `code` its authenticator app shows. The answer is `{verification_id, status,
198
+ # attempts}` with `status` `verified` or `failed`; a factor that is `disabled` answers `400 factor_disabled`, an
199
+ # unknown one `404 not_found`.
171
200
  # @param idempotency_key [String] sent as the Idempotency-Key header
172
201
  # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
173
- # @return [Didit::Types::PhoneVerificationCheckResponse]
202
+ # @return [Didit::Types::PhoneCheckCodeResponse]
174
203
  def check_code(
175
- phone_number:,
176
204
  code:,
205
+ phone_number: OMIT,
177
206
  duplicated_phone_number_action: OMIT,
178
207
  disposable_number_action: OMIT,
179
208
  voip_number_action: OMIT,
@@ -184,6 +213,7 @@ module Didit
184
213
  low_phone_trust_action: OMIT,
185
214
  enable_social: OMIT,
186
215
  phone_no_social_presence_action: OMIT,
216
+ factor_id: OMIT,
187
217
  idempotency_key: OMIT,
188
218
  request_options: nil
189
219
  )
@@ -191,8 +221,8 @@ module Didit
191
221
  :post,
192
222
  "/v3/phone/check/",
193
223
  body: {
194
- "phone_number" => phone_number,
195
224
  "code" => code,
225
+ "phone_number" => phone_number,
196
226
  "duplicated_phone_number_action" => duplicated_phone_number_action,
197
227
  "disposable_number_action" => disposable_number_action,
198
228
  "voip_number_action" => voip_number_action,
@@ -202,10 +232,11 @@ module Didit
202
232
  "recent_port_action" => recent_port_action,
203
233
  "low_phone_trust_action" => low_phone_trust_action,
204
234
  "enable_social" => enable_social,
205
- "phone_no_social_presence_action" => phone_no_social_presence_action
235
+ "phone_no_social_presence_action" => phone_no_social_presence_action,
236
+ "factor_id" => factor_id
206
237
  },
207
238
  headers: { "Idempotency-Key" => idempotency_key },
208
- response: Types::PhoneVerificationCheckResponse,
239
+ response: Types::PhoneCheckCodeResponse,
209
240
  request_options: request_options
210
241
  )
211
242
  end
@@ -301,6 +332,701 @@ module Didit
301
332
  request_options: request_options
302
333
  )
303
334
  end
335
+
336
+ # The +phone.factors+ resource.
337
+ class Factors < Didit::Resource
338
+ # Enroll a TOTP factor
339
+ #
340
+ # Enroll a TOTP factor for one of your users, so they confirm a verification with an authenticator app instead
341
+ # of a code. `type` is `totp` and `user_id` is your id for the user.
342
+ #
343
+ # The answer carries `totp.uri`, the `otpauth://` URI to show as a QR code; the authenticator app scans it and
344
+ # starts producing codes.
345
+ #
346
+ # **State.** A new factor is `unverified` until its first code passes `POST /v3/phone/check/`, then
347
+ # `verified`.
348
+ #
349
+ # **One of each type.** A user holds at most one factor: a second one answers `409 factor_exists`.
350
+ #
351
+ # **Authentication.** Send your application's API key in `x-api-key`.
352
+ #
353
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
354
+ #
355
+ # +POST /v3/phone/factors/+
356
+ #
357
+ # @param type [String] The factor to enroll: `totp`, for an authenticator app.
358
+ # @param user_id [String] Your id for the user the factor belongs to; a check names the factor and the user.
359
+ # @param friendly_name [String] Shown in the authenticator app and in the factor list.
360
+ # @param metadata [Hash{String => String}] Up to 10 keys and values of your own, returned with the factor.
361
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
362
+ # @return [Didit::Types::PhoneFactorEnrollment]
363
+ def create(type:, user_id:, friendly_name: OMIT, metadata: OMIT, request_options: nil)
364
+ @client.request(
365
+ :post,
366
+ "/v3/phone/factors/",
367
+ body: {
368
+ "type" => type,
369
+ "user_id" => user_id,
370
+ "friendly_name" => friendly_name,
371
+ "metadata" => metadata
372
+ },
373
+ response: Types::PhoneFactorEnrollment,
374
+ request_options: request_options
375
+ )
376
+ end
377
+
378
+ # Remove a factor
379
+ #
380
+ # Delete an enrolled factor. The factor is deleted at once: its `factor_id` stops working and the TOTP secret
381
+ # it held stop verifying, and the deletion cannot be undone. Verifications the factor already completed stay
382
+ # verified, and the user's other factors are not affected.
383
+ #
384
+ # Enroll the user again with `POST /v3/phone/factors/` to give them a new factor.
385
+ #
386
+ # **Authentication.** Send your application's API key in `x-api-key`.
387
+ #
388
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
389
+ #
390
+ # +DELETE /v3/phone/factors/{factor_id}/+
391
+ #
392
+ # @param factor_id [String] The factor to delete.
393
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
394
+ # @return [nil]
395
+ def delete(factor_id, request_options: nil)
396
+ @client.request(
397
+ :delete,
398
+ "/v3/phone/factors/{factor_id}/",
399
+ path_params: { "factor_id" => factor_id },
400
+ request_options: request_options
401
+ )
402
+ end
403
+
404
+ # List a user's enrolled factors
405
+ #
406
+ # List the factors enrolled for one of your users, so your app can show them and let the user pick the one to
407
+ # check with. `user_id` is required; `type` and `status` narrow the list.
408
+ #
409
+ # The answer is a page: `count`, `next`, `previous` and `results`, each result a factor as Retrieve returns
410
+ # it.
411
+ #
412
+ # **Export.** `format: csv` answers every row that matches the filters as a CSV file.
413
+ #
414
+ # **Paging.** `limit` is 20 by default and 100 at most.
415
+ #
416
+ # **Authentication.** Send your application's API key in `x-api-key`.
417
+ #
418
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
419
+ #
420
+ # +GET /v3/phone/factors/+
421
+ #
422
+ # @param user_id [String] The user whose factors to list: required.
423
+ # @param type [String] Only factors of this type.
424
+ # @param status [String] Only factors in this state.
425
+ # @param limit [Integer] Page size: 20 by default, 100 at most.
426
+ # @param offset [Integer] Zero-based index of the first row. Prefer following `next`.
427
+ # @param format [String] `json` (default) for a page, or `csv` to export every row that matches the filters as
428
+ # CSV.
429
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
430
+ # @return [Didit::Page<Didit::Types::PhoneFactor>]
431
+ def list(user_id:, type: OMIT, status: OMIT, limit: OMIT, offset: OMIT, format: OMIT, request_options: nil)
432
+ @client.request(
433
+ :get,
434
+ "/v3/phone/factors/",
435
+ query: {
436
+ "user_id" => user_id,
437
+ "type" => type,
438
+ "status" => status,
439
+ "limit" => limit,
440
+ "offset" => offset,
441
+ "format" => format
442
+ },
443
+ page: Types::PhoneFactor,
444
+ request_options: request_options
445
+ )
446
+ end
447
+
448
+ # Retrieve one enrolled factor
449
+ #
450
+ # One enrolled factor: its type, state, user, name, metadata and when it was last used. Read it to show a
451
+ # factor's state after a check changed it, or after it was disabled, without reading the whole list.
452
+ #
453
+ # **Authentication.** Send your application's API key in `x-api-key`.
454
+ #
455
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
456
+ #
457
+ # +GET /v3/phone/factors/{factor_id}/+
458
+ #
459
+ # @param factor_id [String] The factor.
460
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
461
+ # @return [Didit::Types::PhoneFactor]
462
+ def retrieve(factor_id, request_options: nil)
463
+ @client.request(
464
+ :get,
465
+ "/v3/phone/factors/{factor_id}/",
466
+ path_params: { "factor_id" => factor_id },
467
+ response: Types::PhoneFactor,
468
+ request_options: request_options
469
+ )
470
+ end
471
+
472
+ # Change a factor's name, metadata or state
473
+ #
474
+ # Change a factor without enrolling it again: rename it (`friendly_name`), replace your `metadata`, or disable
475
+ # it or turn it back on (`status`). The answer is the factor as it now stands.
476
+ #
477
+ # `disabled` stops the factor's checks and `verified` turns a disabled factor back on. A factor that was never
478
+ # verified cannot be turned on: finish its first check instead, or the call answers `409 factor_unverified`.
479
+ #
480
+ # `metadata` replaces the keys and values you sent before: up to 10 keys, each value at most 500 characters,
481
+ # or the call answers `400 invalid_metadata`.
482
+ #
483
+ # **Authentication.** Send your application's API key in `x-api-key`.
484
+ #
485
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
486
+ #
487
+ # +PATCH /v3/phone/factors/{factor_id}/+
488
+ #
489
+ # @param factor_id [String] The factor to change.
490
+ # @param friendly_name [String] A new name for the authenticator app.
491
+ # @param metadata [Hash{String => String}] Replaces your keys and values with these, up to 10.
492
+ # @param status [String] `disabled` stops the factor's checks; `verified` turns a disabled factor back on.
493
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
494
+ # @return [Didit::Types::PhoneFactor]
495
+ def update(factor_id, friendly_name: OMIT, metadata: OMIT, status: OMIT, request_options: nil)
496
+ @client.request(
497
+ :patch,
498
+ "/v3/phone/factors/{factor_id}/",
499
+ path_params: { "factor_id" => factor_id },
500
+ body: {
501
+ "friendly_name" => friendly_name,
502
+ "metadata" => metadata,
503
+ "status" => status
504
+ },
505
+ response: Types::PhoneFactor,
506
+ request_options: request_options
507
+ )
508
+ end
509
+ end
510
+
511
+ # The +phone.network+ resource.
512
+ class Network < Didit::Resource
513
+ # @return [Didit::Resources::Phone::Network::Registrations]
514
+ def registrations
515
+ @registrations ||= Registrations.new(@client)
516
+ end
517
+
518
+ # The +phone.network.registrations+ resource.
519
+ class Registrations < Didit::Resource
520
+ # @return [Didit::Resources::Phone::Network::Registrations::TestNumbers]
521
+ def test_numbers
522
+ @test_numbers ||= TestNumbers.new(@client)
523
+ end
524
+
525
+ # Ask the networks to approve a network feature
526
+ #
527
+ # Ask the mobile networks to approve a network feature for one country, so your application can use it for
528
+ # production traffic there: `feature` (`silent_verification`, `sim_swap` or `number_verification`),
529
+ # `country`, `use_case`, `company_name` and the `website` where the flow runs, plus optionally the
530
+ # `networks` to ask, a `purpose` shown to them and your expected `monthly_volume`.
531
+ #
532
+ # The answer is the registration with each network's decision (`networks[].status`) and the overall
533
+ # `status`: `submitted`, `in_review`, `approved`, `partly_approved` or `rejected`.
534
+ #
535
+ # **Test access.** While the networks review, `test_access` is `on`: the feature answers for the
536
+ # registration's verified test numbers and marks those answers `test: true`. Add up to 5 with `POST
537
+ # /v3/phone/network/registrations/{registration_id}/test-numbers/`. It turns `off` once the registration is
538
+ # approved or rejected.
539
+ #
540
+ # **One per feature, use case and country.** The same three again while one is open answers `409
541
+ # registration_exists`.
542
+ #
543
+ # **Authentication.** Send your application's API key in `x-api-key`.
544
+ #
545
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
546
+ #
547
+ # +POST /v3/phone/network/registrations/+
548
+ #
549
+ # @param feature [String] The network feature to ask approval for.
550
+ # @param country [String] The ISO 3166-1 alpha-2 country it runs in.
551
+ # @param use_case [String] What you use the feature for.
552
+ # @param company_name [String] Your legal company name, as the networks see it.
553
+ # @param website [String] Where the flow runs, so the networks can review it.
554
+ # @param networks [Array<String>] Only these mobile networks; left out, every network in the country.
555
+ # @param purpose [String] Why the flow needs the feature, shown to the networks.
556
+ # @param monthly_volume [Integer] Expected requests a month.
557
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
558
+ # @return [Didit::Types::PhoneNetworkRegistration]
559
+ def create(
560
+ feature:,
561
+ country:,
562
+ use_case:,
563
+ company_name:,
564
+ website:,
565
+ networks: OMIT,
566
+ purpose: OMIT,
567
+ monthly_volume: OMIT,
568
+ request_options: nil
569
+ )
570
+ @client.request(
571
+ :post,
572
+ "/v3/phone/network/registrations/",
573
+ body: {
574
+ "feature" => feature,
575
+ "country" => country,
576
+ "use_case" => use_case,
577
+ "company_name" => company_name,
578
+ "website" => website,
579
+ "networks" => networks,
580
+ "purpose" => purpose,
581
+ "monthly_volume" => monthly_volume
582
+ },
583
+ response: Types::PhoneNetworkRegistration,
584
+ request_options: request_options
585
+ )
586
+ end
587
+
588
+ # List your network feature registrations
589
+ #
590
+ # List your network feature registrations, newest first, with each one's feature, country, use case and
591
+ # status. `feature`, `country` and `status` narrow the list, and `format: csv` exports every row that
592
+ # matches the filters instead of a page. Read one in full with `GET
593
+ # /v3/phone/network/registrations/{registration_id}/`.
594
+ #
595
+ # **Paging.** `limit` is 20 by default and 100 at most.
596
+ #
597
+ # **Authentication.** Send your application's API key in `x-api-key`.
598
+ #
599
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
600
+ #
601
+ # +GET /v3/phone/network/registrations/+
602
+ #
603
+ # @param feature [String] Only registrations of this network feature.
604
+ # @param country [String] Only this ISO 3166-1 alpha-2 country.
605
+ # @param status [String] Only rows in this state.
606
+ # @param limit [Integer] Page size: 20 by default, 100 at most.
607
+ # @param offset [Integer] Zero-based index of the first row. Prefer following `next`.
608
+ # @param format [String] `json` (default) for a page, or `csv` to export every row that matches the filters
609
+ # as CSV.
610
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
611
+ # @return [Didit::Page<Didit::Types::PhoneNetworkRegistrationSummary>]
612
+ def list(
613
+ feature: OMIT,
614
+ country: OMIT,
615
+ status: OMIT,
616
+ limit: OMIT,
617
+ offset: OMIT,
618
+ format: OMIT,
619
+ request_options: nil
620
+ )
621
+ @client.request(
622
+ :get,
623
+ "/v3/phone/network/registrations/",
624
+ query: {
625
+ "feature" => feature,
626
+ "country" => country,
627
+ "status" => status,
628
+ "limit" => limit,
629
+ "offset" => offset,
630
+ "format" => format
631
+ },
632
+ page: Types::PhoneNetworkRegistrationSummary,
633
+ request_options: request_options
634
+ )
635
+ end
636
+
637
+ # Track a feature approval, network by network
638
+ #
639
+ # Track one feature approval, network by network: the feature, country and use case you submitted, the
640
+ # overall `status`, each mobile network's decision (`status`, `decided_at` and, when it rejected the
641
+ # request, `reason`), `live_at` once the feature is live for you in the country, and the `test_numbers` that
642
+ # answer it while `test_access` is `on`.
643
+ #
644
+ # **Authentication.** Send your application's API key in `x-api-key`.
645
+ #
646
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
647
+ #
648
+ # +GET /v3/phone/network/registrations/{registration_id}/+
649
+ #
650
+ # @param registration_id [String] The network feature registration.
651
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
652
+ # @return [Didit::Types::PhoneNetworkRegistration]
653
+ def retrieve(registration_id, request_options: nil)
654
+ @client.request(
655
+ :get,
656
+ "/v3/phone/network/registrations/{registration_id}/",
657
+ path_params: { "registration_id" => registration_id },
658
+ response: Types::PhoneNetworkRegistration,
659
+ request_options: request_options
660
+ )
661
+ end
662
+
663
+ # The +phone.network.registrations.test_numbers+ resource.
664
+ class TestNumbers < Didit::Resource
665
+ # Add a test number while the networks review
666
+ #
667
+ # Add a number you hold as a test number while the networks review a registration, so you can try the
668
+ # feature before it is approved: send it in E.164 (`phone_number`).
669
+ #
670
+ # Didit sends it a code and answers with `verification_id` and `status: code_sent`; check the code with
671
+ # `POST /v3/phone/check/` and the number. Once the code is checked the number is `verified`, and the
672
+ # feature answers for it under test access, marked `test: true`.
673
+ #
674
+ # **Limits.** A registration takes up to 5 test numbers (`409 too_many_test_numbers`), and test access
675
+ # ends when the networks decide (`409 review_finished`).
676
+ #
677
+ # **Authentication.** Send your application's API key in `x-api-key`.
678
+ #
679
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
680
+ #
681
+ # +POST /v3/phone/network/registrations/{registration_id}/test-numbers/+
682
+ #
683
+ # @param registration_id [String] The network feature registration.
684
+ # @param phone_number [String] A number you hold, in E.164. Didit sends it a code to confirm it.
685
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
686
+ # @return [Didit::Types::PhoneNetworkRegistrationTestNumber]
687
+ def create(registration_id, phone_number:, request_options: nil)
688
+ @client.request(
689
+ :post,
690
+ "/v3/phone/network/registrations/{registration_id}/test-numbers/",
691
+ path_params: { "registration_id" => registration_id },
692
+ body: {
693
+ "phone_number" => phone_number
694
+ },
695
+ response: Types::PhoneNetworkRegistrationTestNumber,
696
+ request_options: request_options
697
+ )
698
+ end
699
+
700
+ # Remove a test number
701
+ #
702
+ # Remove a test number from a registration: it is deleted at once, the feature stops answering for it, and
703
+ # the number can be added again while test access is on.
704
+ #
705
+ # The number is in the path in E.164, URL-encoded: `+34600000012` becomes `%2B34600000012`.
706
+ #
707
+ # **Authentication.** Send your application's API key in `x-api-key`.
708
+ #
709
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
710
+ #
711
+ # +DELETE /v3/phone/network/registrations/{registration_id}/test-numbers/{phone_number}/+
712
+ #
713
+ # @param registration_id [String] The network feature registration.
714
+ # @param phone_number [String] The test number, in E.164 and URL-encoded.
715
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
716
+ # @return [nil]
717
+ def delete(registration_id, phone_number, request_options: nil)
718
+ @client.request(
719
+ :delete,
720
+ "/v3/phone/network/registrations/{registration_id}/test-numbers/{phone_number}/",
721
+ path_params: { "registration_id" => registration_id, "phone_number" => phone_number },
722
+ request_options: request_options
723
+ )
724
+ end
725
+ end
726
+ end
727
+ end
728
+
729
+ # The +phone.sdk_keys+ resource.
730
+ class SdkKeys < Didit::Resource
731
+ # Issue a publishable key for a client SDK
732
+ #
733
+ # Issue a publishable key for the iOS, Android or web build of your app: `platform`, the `app_ids` it may run
734
+ # in (bundle ids, package names or `https` origins) and an optional `name` shown in API keys. The answer
735
+ # carries `publishable_key`, which is safe to ship inside the app because it can only start the client SDK's
736
+ # checks.
737
+ #
738
+ # **Rotation.** To replace a key in an app that is already installed, rotate it (`POST
739
+ # /v3/phone/sdk-keys/{key_id}/rotate/`) rather than issuing a second one: the old value keeps working while
740
+ # your update ships.
741
+ #
742
+ # **Permissions.** Only an Owner or Admin API key may issue a publishable key.
743
+ #
744
+ # **Authentication.** Send your application's API key in `x-api-key`.
745
+ #
746
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
747
+ #
748
+ # +POST /v3/phone/sdk-keys/+
749
+ #
750
+ # @param platform [String] The platform the key is for: `ios`, `android` or `web`.
751
+ # @param app_ids [Array<String>] The bundle ids, package names or `https` origins the key works for.
752
+ # @param name [String] Shown in API keys.
753
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
754
+ # @return [Didit::Types::PhoneSdkKey]
755
+ def create(platform:, app_ids:, name: OMIT, request_options: nil)
756
+ @client.request(
757
+ :post,
758
+ "/v3/phone/sdk-keys/",
759
+ body: {
760
+ "platform" => platform,
761
+ "app_ids" => app_ids,
762
+ "name" => name
763
+ },
764
+ response: Types::PhoneSdkKey,
765
+ request_options: request_options
766
+ )
767
+ end
768
+
769
+ # List the publishable keys of your client SDKs
770
+ #
771
+ # List the key ID, platform and status of each client SDK key for your application.
772
+ #
773
+ # `platform` narrows the list to one platform.
774
+ #
775
+ # **Permissions.** Only an Owner or Admin API key may read publishable keys.
776
+ #
777
+ # **Authentication.** Send your application's API key in `x-api-key`.
778
+ #
779
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
780
+ #
781
+ # +GET /v3/phone/sdk-keys/+
782
+ #
783
+ # @param platform [String] Only keys for this platform.
784
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
785
+ # @return [Didit::Types::PhoneSdkKeysPage]
786
+ def list(platform: OMIT, request_options: nil)
787
+ @client.request(
788
+ :get,
789
+ "/v3/phone/sdk-keys/",
790
+ query: {
791
+ "platform" => platform
792
+ },
793
+ response: Types::PhoneSdkKeysPage,
794
+ request_options: request_options
795
+ )
796
+ end
797
+
798
+ # Revoke a publishable key
799
+ #
800
+ # Revoke a publishable key at once: it stops starting the client SDK's checks immediately, its status becomes
801
+ # `revoked`, and it can neither be restored nor rotated. Apps that still ship it fail until they are updated,
802
+ # so issue the replacement first (`POST /v3/phone/sdk-keys/`).
803
+ #
804
+ # **Permissions.** Only an Owner or Admin API key may revoke a publishable key.
805
+ #
806
+ # **Authentication.** Send your application's API key in `x-api-key`.
807
+ #
808
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
809
+ #
810
+ # +DELETE /v3/phone/sdk-keys/{key_id}/+
811
+ #
812
+ # @param key_id [String] The publishable key to revoke.
813
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
814
+ # @return [nil]
815
+ def revoke(key_id, request_options: nil)
816
+ @client.request(
817
+ :delete,
818
+ "/v3/phone/sdk-keys/{key_id}/",
819
+ path_params: { "key_id" => key_id },
820
+ request_options: request_options
821
+ )
822
+ end
823
+
824
+ # Rotate a publishable key with an overlap
825
+ #
826
+ # Rotate a publishable key without breaking the app versions already installed: Didit issues a new value and
827
+ # keeps the old one working for `overlap_hours` (0 to 168), long enough for your update to ship. The answer is
828
+ # the key with its new `publishable_key`, and `previous_expires_at` is when the value it replaced stops
829
+ # working.
830
+ #
831
+ # Ship the new value, then let the overlap end. A revoked key cannot be rotated: the call answers `409
832
+ # revoked`.
833
+ #
834
+ # **Permissions.** Only an Owner or Admin API key may rotate a publishable key.
835
+ #
836
+ # **Authentication.** Send your application's API key in `x-api-key`.
837
+ #
838
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
839
+ #
840
+ # +POST /v3/phone/sdk-keys/{key_id}/rotate/+
841
+ #
842
+ # @param key_id [String] The publishable key to rotate.
843
+ # @param overlap_hours [Integer] How long the value being replaced keeps working, from 0 to 168 hours, while
844
+ # the app update ships.
845
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
846
+ # @return [Didit::Types::PhoneSdkKeyRotated]
847
+ def rotate(key_id, overlap_hours: OMIT, request_options: nil)
848
+ @client.request(
849
+ :post,
850
+ "/v3/phone/sdk-keys/{key_id}/rotate/",
851
+ path_params: { "key_id" => key_id },
852
+ body: {
853
+ "overlap_hours" => overlap_hours
854
+ },
855
+ response: Types::PhoneSdkKeyRotated,
856
+ request_options: request_options
857
+ )
858
+ end
859
+ end
860
+
861
+ # The +phone.silent+ resource.
862
+ class Silent < Didit::Resource
863
+ # @return [Didit::Resources::Phone::Silent::Registrations]
864
+ def registrations
865
+ @registrations ||= Registrations.new(@client)
866
+ end
867
+
868
+ # List where silent verification runs
869
+ #
870
+ # Where silent verification runs: every country where at least one mobile network can run the check, and per
871
+ # country the networks that can. Read this instead of hardcoding a list, because coverage grows as networks
872
+ # approve the feature.
873
+ #
874
+ # `approval` says whether a network answers for production traffic (`live`) or only while it approves
875
+ # production use (`test`), in which case it answers for the verified test numbers of a registration. `wifi`
876
+ # says whether the SIM check also runs over Wi-Fi, so a device without mobile data can still complete it.
877
+ #
878
+ # **Narrowing.** `country` answers for one ISO 3166-1 alpha-2 country.
879
+ #
880
+ # **Before you start.** `POST /v3/phone/silent/eligibility/` answers for one number, and a silent check that
881
+ # cannot run falls back to the verification's code channels.
882
+ #
883
+ # **Authentication.** Send your application's API key in `x-api-key`.
884
+ #
885
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
886
+ #
887
+ # +GET /v3/phone/silent/coverage/+
888
+ #
889
+ # @param country [String] Only this ISO 3166-1 alpha-2 country.
890
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
891
+ # @return [Didit::Types::PhoneSilentCoverage]
892
+ def coverage(country: OMIT, request_options: nil)
893
+ @client.request(
894
+ :get,
895
+ "/v3/phone/silent/coverage/",
896
+ query: {
897
+ "country" => country
898
+ },
899
+ response: Types::PhoneSilentCoverage,
900
+ request_options: request_options
901
+ )
902
+ end
903
+
904
+ # Check silent eligibility before you start
905
+ #
906
+ # Whether a silent check can run for one number now, so you can decide whether to offer it before you start a
907
+ # verification. `eligible` is the answer and, when it is `false`, `reason` says why: `unsupported_network`
908
+ # (the number's mobile network cannot run the check), `not_mobile_data` (the device is not on mobile data) or
909
+ # `country_not_covered` (silent verification does not run in the number's country).
910
+ #
911
+ # `network` is the mobile network the number belongs to, `country` its ISO 3166-1 alpha-2 code, and
912
+ # `wifi_possible` whether the SIM check can still run over Wi-Fi when the device has no mobile data.
913
+ #
914
+ # **Mobile data.** Send `ip_address`, the phone's public IP, to have the answer also confirm the device is on
915
+ # mobile data. Without it, the answer is about the network alone.
916
+ #
917
+ # **What follows.** A verification that runs the silent check first falls back to its next code channel when
918
+ # the check cannot run.
919
+ #
920
+ # **Authentication.** Send your application's API key in `x-api-key`. To check a client SDK's publishable key
921
+ # as well, include it in `X-Publishable-Key`.
922
+ #
923
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
924
+ #
925
+ # +POST /v3/phone/silent/eligibility/+
926
+ #
927
+ # @param phone_number [String] The number in international format (E.164), for example `+34600000012`.
928
+ # @param ip_address [String] The phone's public IP, so the answer also confirms the device is on mobile data.
929
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
930
+ # @return [Didit::Types::PhoneSilentEligibility]
931
+ def eligibility(phone_number:, ip_address: OMIT, request_options: nil)
932
+ @client.request(
933
+ :post,
934
+ "/v3/phone/silent/eligibility/",
935
+ body: {
936
+ "phone_number" => phone_number,
937
+ "ip_address" => ip_address
938
+ },
939
+ response: Types::PhoneSilentEligibility,
940
+ request_options: request_options
941
+ )
942
+ end
943
+
944
+ # The +phone.silent.registrations+ resource.
945
+ class Registrations < Didit::Resource
946
+ # Submit a country for carrier approval of silent verification
947
+ #
948
+ # Submit a country for carrier approval of silent verification, so silent checks run for your application's
949
+ # production traffic there: `country`, the `use_case` it runs in, your `company_name` and the `website`
950
+ # where the flow runs. Optionally name the `networks` to ask, your expected `monthly_volume` and links to
951
+ # `flow_screenshots`.
952
+ #
953
+ # The answer is the registration. `status` starts `submitted`, moves to `in_review`, and ends as `approved`,
954
+ # `partly_approved` (some networks approved and some rejected) or `rejected`. `networks` lists each mobile
955
+ # network's own decision and `live_at` is when silent verification went live for you in the country.
956
+ #
957
+ # **One per country.** A country with an open registration answers `409 registration_exists`: track that one
958
+ # with `GET /v3/phone/silent/registrations/{registration_id}/` instead.
959
+ #
960
+ # **Authentication.** Send your application's API key in `x-api-key`.
961
+ #
962
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
963
+ #
964
+ # +POST /v3/phone/silent/registrations/+
965
+ #
966
+ # @param country [String] The ISO 3166-1 alpha-2 country to ask approval for.
967
+ # @param use_case [String] What silent verification is used for.
968
+ # @param company_name [String] Your legal company name, as the networks see it.
969
+ # @param website [String] Where the flow runs, so the networks can review it.
970
+ # @param networks [Array<String>] Only these mobile networks; left out, every network in the country.
971
+ # @param monthly_volume [Integer] Expected silent checks a month.
972
+ # @param flow_screenshots [Array<String>] Links to screens of the flow, as the networks ask for them.
973
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
974
+ # @return [Didit::Types::PhoneSilentRegistration]
975
+ def create(
976
+ country:,
977
+ use_case:,
978
+ company_name:,
979
+ website:,
980
+ networks: OMIT,
981
+ monthly_volume: OMIT,
982
+ flow_screenshots: OMIT,
983
+ request_options: nil
984
+ )
985
+ @client.request(
986
+ :post,
987
+ "/v3/phone/silent/registrations/",
988
+ body: {
989
+ "country" => country,
990
+ "use_case" => use_case,
991
+ "company_name" => company_name,
992
+ "website" => website,
993
+ "networks" => networks,
994
+ "monthly_volume" => monthly_volume,
995
+ "flow_screenshots" => flow_screenshots
996
+ },
997
+ response: Types::PhoneSilentRegistration,
998
+ request_options: request_options
999
+ )
1000
+ end
1001
+
1002
+ # Track a carrier approval, network by network
1003
+ #
1004
+ # Track a carrier approval, network by network: the registration's `status`, each mobile network's decision
1005
+ # (`status`, `decided_at` and, when it rejected the request, `reason`), and `live_at` once silent
1006
+ # verification is live for you in the country.
1007
+ #
1008
+ # A registration that is `partly_approved` runs silent verification on the networks that approved it.
1009
+ #
1010
+ # **Authentication.** Send your application's API key in `x-api-key`.
1011
+ #
1012
+ # **Rate limit.** Requests count against the key's budget; over it the answer is `429` with `Retry-After`.
1013
+ #
1014
+ # +GET /v3/phone/silent/registrations/{registration_id}/+
1015
+ #
1016
+ # @param registration_id [String] The silent verification registration.
1017
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
1018
+ # @return [Didit::Types::PhoneSilentRegistration]
1019
+ def retrieve(registration_id, request_options: nil)
1020
+ @client.request(
1021
+ :get,
1022
+ "/v3/phone/silent/registrations/{registration_id}/",
1023
+ path_params: { "registration_id" => registration_id },
1024
+ response: Types::PhoneSilentRegistration,
1025
+ request_options: request_options
1026
+ )
1027
+ end
1028
+ end
1029
+ end
304
1030
  end
305
1031
  end
306
1032
  end