class EDIS::Client

Public Class Methods

new(config = {}) click to toggle source

Construct a new instance. The following options are available:

  • :proxy_uri

  • :proxy_user

  • :proxy_pass

  • :timeout - Defaults to 10s

Example:

'require 'edis_client'

edis = EDIS::Client.new({
  timeout: 5s,
  proxy: {  
    uri:      'https://my.domain.com',
    user:     'matz',
    password: 'changeit'
  }
})
# File lib/edis_client.rb, line 34
def initialize(config = {})
  config[:timeout] = 10 unless config[:timeout]
  if config[:proxy]
    config[:proxy][:uri] = URI.parse(config[:proxy][:uri])
  end
  
  @config = config
end

Public Instance Methods

download_attachment(options = {}) { |chunk| ... } click to toggle source

Fetch a document. The result is streamed and therefore clients must provide a block to read each chunk of the response. The following options are available:

  • :document_id - the document id [REQUIRED]

  • :attachment_id - the actual attachment id [REQUIRED]

  • :digest - the authorization digest returned from gen_digest [REQUIRED]

# File lib/edis_client.rb, line 133
def download_attachment(options = {})
  raise ArgumentError, "Missing block." unless block_given?
  validate_download options
  path = build_path '/download', options, download_paths
  stream_resource(path, options) { |chunk| yield chunk }
end
find_attachments(options = {}) click to toggle source

Fetch a document’s attachments. Returns a hash rooted at the rest API’s results node. Accepts an hash for the following options:

  • :document_id - the document id [REQUIRED]

  • :digest - The authorization digest returned from gen_digest

# File lib/edis_client.rb, line 119
def find_attachments(options = {})
  validate_presence_of [:document_id], options
  get_resource "/attachment/#{options[:document_id]}", options
end
find_documents(options = {}) click to toggle source

Fetch document metadata. The following options are available:

  • :document_id - the document id.

  • :security_level - the security level name.

  • :investigation_number - the investigation number.

  • :investigation_phase - the name of the investigation phase.

  • :document_type - the document type

  • :official_received_date - the document’s official received date comparision. this should be a hash of the following keys:

    :type => :between, :before, :after or :exact
      when the type is :exact, :before, :after then
        the hash must also contain :date
      for :between the hash must contain the 2 following
        keys :from_date, :to_date
  • :modified_date - the docuemnt’s last modified date comparision.

    this should be a hash of the following keys:
    :comparision_type => :between, :before, :after or :exact
      when the type is :exact, :before, :after then
        the hash must also contain :date
      for :between the hash must contain the 2 following
        keys :from_date, :to_date
  • :firm_org - the firm that filed the doc

  • :page - the page number for result pagination.

  • :digest - the authorization digest returned from gen_digest

# File lib/edis_client.rb, line 105
def find_documents(options = {})
  path   = build_path '/document', options, [:document_id]
  params = build_params(options, document_params).merge \
    build_date_params options, document_date_params
  get_resource path, options, params
end
find_investigations(options = {}) click to toggle source

Find investigations. The following options are available:

  • :investigation_number - the investigation number.

  • :investigation_phase - the name of the investigation phase. :investgation_number is required when using this option

  • :investigation_type - the name of the investigation type

  • :investigation_status - the name of the investigation status

  • :page - the page number for result pagination.

  • :digest - the authorization digest returned from gen_digest

# File lib/edis_client.rb, line 73
def find_investigations(options = {})
  validate_investigation_options options
  path   = build_path '/investigation', options, investigation_paths
  params = build_params options, investigation_params
  get_resource path, params, options
end
gen_digest(username, password, retain = true) click to toggle source

Generates a digest for api usage. Users must be preregistered with the edis app. The digest can be retained (default) for the life of this instance (session), ensuring all subseqent api calls pass the digest to the endpoint. In this mode clients need not worry about retaining and passing this to other api calls.

  • :username - your EDIS registered username [REQUIRED]

  • :password - your EDIS registered password [REQUIRED]

  • :retain - retain your digest for subsequent api calls [Defaults to true]

# File lib/edis_client.rb, line 54
def gen_digest(username, password, retain = true)
  results = post_resource "/secretKey/#{username}", { password: password }
  raise ArgumentError, results.errors if results.errors
  secret_key = results.results.secretKey
  digest = Base64.strict_encode64 "#{username}:#{secret_key}"
  @config[:digest] = digest if retain
  digest
end