Sha256: d51e4195bf206e421dfb1c684f4e609d3601c6ad42f420995639a47fae35b6c0

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require 'config_newton'
require 'savon'
require "nne_client/version"
require "nne_client/result_attributes"
require "nne_client/fetch"
require "nne_client/request"
require "nne_client/search"
require "nne_client/query"
require "nne_client/question"
require "nne_client/result"
require "nne_client/result_set"
require "nne_client/record_types/finance"
require "nne_client/record_types/ownership"
require "nne_client/record_types/subsidiary"
require "nne_client/record_types/trade"

# Namespace for the library
module NNEClient
  extend self
  include ConfigNewton

  class CompanyMissing < RuntimeError; end

  config :access_key
  config :http_read_timeout

  # Where users start the interaction with the library.
  #
  # The query is hash with one or more of these keys:
  #
  # * :houseNo (string)
  # * :name (string)
  # * :nameStartsWith (boolean)
  # * :street (string)
  # * :zipCode (number)
  # * :tdcId (number)
  #
  # @return [ResultSet] containing the results from the SOAP API
  def search(query)
    NNEClient::Search.new(query).result_set
  end

  def with_timeout(seconds, &block)
    old_timeout = NNEClient.config.http_read_timeout
    NNEClient.config.http_read_timeout = seconds
    yield
  ensure
    NNEClient.config.http_read_timeout = old_timeout
  end

  def retry_timeouts(count, &block)
    retries = 3
    begin
      yield
    rescue Timeout::Error => e
      retries -= 1
      retry if retries > 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nne_client-0.0.7 lib/nne_client.rb