Class: WCC::Media::Client::Resource
- Inherits:
-
Struct
- Object
- Struct
- WCC::Media::Client::Resource
- Defined in:
- lib/wcc/media/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#model ⇒ Object
Returns the value of attribute model.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client
50 51 52 |
# File 'lib/wcc/media/client.rb', line 50 def client @client end |
#model ⇒ Object
Returns the value of attribute model
50 51 52 |
# File 'lib/wcc/media/client.rb', line 50 def model @model end |
#options ⇒ Object
Returns the value of attribute options
50 51 52 |
# File 'lib/wcc/media/client.rb', line 50 def @options end |
Instance Method Details
#find(id) ⇒ Object
52 53 54 55 56 |
# File 'lib/wcc/media/client.rb', line 52 def find(id) resp = client.get("#{model.endpoint}/#{id}") resp.assert_ok! model.new(resp.body[model.key], resp.headers.freeze) end |
#list(**filters) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/wcc/media/client.rb', line 58 def list(**filters) query = extract_params(filters) query = query.merge!(apply_filters(filters, model.filters)) resp = client.get(model.endpoint, query) resp.assert_ok! resp.items.map { |s| model.new(s) } end |