Sha256: 9c07dbaae1865a347e32ab72ca335e0fb5a3a672b0400554cb76562bf3ff342f

Contents?: true

Size: 579 Bytes

Versions: 2

Compression:

Stored size: 579 Bytes

Contents

require 'valnzbn/lookup'

class Valnzbn
  def initialize(number)
    @number = number.to_s.gsub(/\W/, '')
  end

  def exists?(options = {})
    response = Valnzbn::Lookup.validate(@number, options)

    if !response.nil? && !response['entityStatusCode'].nil? && !%w(62 80).include?(response['entityStatusCode'])
      options[:detail] == true ? response : true
    elsif !response.nil? && (%w(62 80).include?(response['entityStatusCode']) || !response['entityStatusCode'].nil? || {}.empty?)
      options[:detail] == true ? response : false
    else
      nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
valnzbn-0.1.2 lib/valnzbn.rb
valnzbn-0.1.1 lib/valnzbn.rb