Sha256: 7b55f84c1de278600b0d1f5c8f334e5c4de2832e78a496aa85a93afbb01aa815

Contents?: true

Size: 911 Bytes

Versions: 3

Compression:

Stored size: 911 Bytes

Contents

require "economic/proxies/entity_proxy"

module Economic
  class CreditorEntryProxy < EntityProxy
    def find_by_invoice_number(invoice_number)
      response = request("FindByInvoiceNumber", "invoiceNumber" => invoice_number)

      response[:creditor_entry_handle].map do |creditor_entry_handle|
        # Kinda ugly, but we get an array instead of a hash when there's only one result. :)
        Hash[*creditor_entry_handle.to_a.flatten][:serial_number].to_i
      end
    end

    def find(serial_number)
      response = request("GetData", "entityHandle" => {
                           "SerialNumber" => serial_number
                         })

      build(response)
    end

    def match(*serial_numbers)
      request("MatchEntries", :entries => {
        "CreditorEntryHandle" => serial_numbers.map { |serial_number|
          {"SerialNumber" => serial_number}
        }
      })
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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