Sha256: 5709ce50e1dde33d543e558e34113ccc65ec09fe5f5f1a7d4742c4326ed837d0

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

require 'excon'
require 'json'
require 'numverify/version'
require 'numverify/configuration'
require 'numverify/request'

module NumverifyClient
  class << self
    attr_accessor :configuration

    def configure
      self.configuration ||= Configuration.new
      yield configuration
    end

    def validate(number:, country_code: nil)
      request(build_query(number, country_code, access_key)).perform(method: :get)
    end

    private

    def access_key
      configuration.access_key || ENV['NUMVERIFY_ACCESS_KEY']
    end

    def build_query(number, country_code, access_key)
      {
        number: number,
        country_code: country_code,
        access_key: access_key
      }
    end

    def request(query)
      NumverifyClient::Request.new(query: query, https: configuration.https)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
numverify-0.3.2 lib/numverify.rb