Sha256: ab49f9dd30a05c5385ec1ce626375f5218e18c99ea1d448e3db7dd3909fd81f9

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

module FindByCiNumber
  # Returns Debtors that have the given ci_number. The Debtor objects will only
  # be partially loaded
  def find_by_ci_number(ci_number)
    # Get a list of handles from e-conomic
    response = request(:find_by_ci_number, "ciNumber" => ci_number)

    # Make sure we always have an array of handles even if the result only
    # contains one
    handle_key = "#{entity_class_name.downcase}_handle".intern
    handles = [response[handle_key]].flatten.reject(&:blank?)

    # Create partial Debtor entities
    handles.collect do |handle|
      entity = build
      entity.partial = true
      entity.persisted = true
      entity.handle = handle
      entity.number = handle[:number]
      entity
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rconomic-0.7.0 lib/economic/proxies/actions/find_by_ci_number.rb
rconomic-0.6.1 lib/economic/proxies/actions/find_by_ci_number.rb
rconomic-0.6.0 lib/economic/proxies/actions/find_by_ci_number.rb