Sha256: 1f071126115fd4f87139ad37e1d0a006f2b03719fee0f5b0b30f6aa592ad2df2

Contents?: true

Size: 956 Bytes

Versions: 7

Compression:

Stored size: 956 Bytes

Contents

# frozen_string_literal: true

module Zerobounce
  class Request
    # Request methods specific to V2 of the API.
    module V2Request
      # Valid v2 query params
      VALID_GET_PARAMS = %i[api_key ip_address email].freeze

      # Validate the email address.
      #
      # @param [Hash] params
      # @option params [String] :email
      # @option params [String] :ip_address
      # @option params [String] :api_key
      # @return [Zerobounce::Response]
      def validate(params)
        Response.new(get('validate', params), self)
      end

      private

      # @param [Hash] params
      # @return [Hash]
      def get_params(params)
        params[:ip_address] ||= '' # ip_address must be in query string
        params[:api_key] = params.delete(:apikey) if params.key?(:apikey) # normalize api_key param
        { api_key: Zerobounce.config.apikey }.merge(params.select { |k, _| VALID_GET_PARAMS.include?(k) })
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
zerobounce-0.3.1 lib/zerobounce/request/v2_request.rb
zerobounce-0.3.0 lib/zerobounce/request/v2_request.rb
zerobounce-0.2.2 lib/zerobounce/request/v2_request.rb
zerobounce-0.2.0 lib/zerobounce/request/v2_request.rb
zerobounce-0.1.2 lib/zerobounce/request/v2_request.rb
zerobounce-0.1.1 lib/zerobounce/request/v2_request.rb
zerobounce-0.1.0 lib/zerobounce/request/v2_request.rb