Module: GmanClient::CommodityMerchandising::Contracts

Included in:
Gman::Client
Defined in:
lib/gman_client/commodity_merchandising/contracts.rb

Instance Method Summary collapse

Instance Method Details

#clean_filters(filters) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gman_client/commodity_merchandising/contracts.rb', line 20

def clean_filters(filters)
  keep = filters.select do |k, _v|
    %i(
      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

#contracts(filters) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/gman_client/commodity_merchandising/contracts.rb', line 6

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