Sha256: cbbf0591229415cc1f8fd1440cc3924da0d1be4a281841ee68029f0467034f4b

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

module Telnyx
  class Verification < APIResource
    # Type for verification responses
    class Response < TelnyxObject; end

    extend APIOperations::Create
    extend APIOperations::NestedResource

    class << self
      private :create
    end

    nested_resource_class_methods "by_telephone",
                                  path: "by_tn",
                                  operations: [:retrieve],
                                  instance_methods: {
                                    retrieve: "by_telephone",
                                  }

    def self.submit_code(phone_number: nil, code: nil)
      url = "#{resource_url}/by_phone_number/#{CGI.escape phone_number}/actions/verify"
      resp, _opts = request(:post, url, code: code)
      Response.construct_from resp.data[:data]
    end

    # Trigger a call verification.
    def self.call(params = {}, opts = {})
      create(params, { **opts, resource_url: "#{resource_url}/call" })
    end

    # Trigger an SMS verification.
    def self.sms(params = {}, opts = {})
      create(params, { **opts, resource_url: "#{resource_url}/sms" })
    end

    # Trigger a PSD2 verification.
    def self.psd2(params = {}, opts = {})
      create(params, { **opts, resource_url: "#{resource_url}/psd2" })
    end

    # Trigger a flashcall verification.
    def self.flashcall(params = {}, opts = {})
      create(params, { **opts, resource_url: "#{resource_url}/flashcall" })
    end

    # Trigger a whatsapp verification.
    def self.whatsapp(params = {}, opts = {})
      create(params, { **opts, resource_url: "#{resource_url}/whatsapp" })
    end

    OBJECT_NAME = "verify_verification".freeze
    RESOURCE_PATH = "verifications".freeze
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telnyx-2.9.0 lib/telnyx/verification.rb
telnyx-2.8.0 lib/telnyx/verification.rb