Sha256: b3f62ea0ebe5e4e3fe1d0a72d4c9a6d08ff8393f086db946293c1f87a5b4e6e7

Contents?: true

Size: 719 Bytes

Versions: 3

Compression:

Stored size: 719 Bytes

Contents

module GmanClient
  module CommodityMerchandising
    module Contracts
      def contracts(filters)
        response = attempt(@retry_attempts) do
          request
            .api
            .v1
            .commodity_merchandising
            .contracts
            .get(params: { q: clean_filters(filters) })
        end

        response
          .map(&:to_h)
      end

      def clean_filters(filters)
        keep = filters.select do |k, _v|
          [
            :commodity_id_eq,
            :contract_type_eq,
            :customer_id_eq,
            :inv_contract_id_eq,
            :location_id_eq
          ].include?(k)
        end

        Hash[filters.to_a & keep.to_a]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gman_client-0.3.1 lib/gman_client/commodity_merchandising/contracts.rb
gman_client-0.3.0 lib/gman_client/commodity_merchandising/contracts.rb
gman_client-0.2.1 lib/gman_client/commodity_merchandising/contracts.rb