Method: Cin7API::PaymentResource#where

Defined in:
lib/cin7_api/resources/payment_resource.rb

#where(**params) ⇒ Object

@client.payment.where(order_id: 2223, order_ref: “CRN-2223”)



6
7
8
9
10
11
12
13
# File 'lib/cin7_api/resources/payment_resource.rb', line 6

def where(**params)
  response_body = get_request("Payments", params: params).body
  payments = response_body.map { |attributes| Payment.new(attributes) }
  # Doing a filter here because Cin7 is doing a binary OR check for the filter params
  payments.filter do |payment|
    params.reduce(true) { |acc, (key, value)| acc && payment[key] == value }
  end
end