lib/wcc/media/client.rb in wcc-media-client-0.4.2 vs lib/wcc/media/client.rb in wcc-media-client-0.4.3
- old
+ new
@@ -53,12 +53,15 @@
end
end
Resource =
Struct.new(:client, :model, :options) do
- def find(id)
- resp = client.get("#{model.endpoint}/#{id}")
+ def find(id, **params)
+ resp = client.get(
+ "#{model.endpoint}/#{id}",
+ default_params('target').merge(params)
+ )
resp.assert_ok!
model.new(resp.body[model.key], resp.headers.freeze)
end
def list(**filters)
@@ -76,13 +79,13 @@
k_s = k.to_s
h[k_s] = filters.delete(k) if PARAMS.include?(k_s)
end
end
- def default_params
+ def default_params(keys = CONFIGURABLE_PARAMS)
options.each_with_object({}) do |(k, v), h|
k = k.to_s
- h[k] = v if !v.nil? && CONFIGURABLE_PARAMS.include?(k)
+ h[k] = v if !v.nil? && keys.include?(k)
end
end
def apply_filters(filters, expected_filters)
defaults = default_filters(expected_filters) || {}