Class: WCC::Media::Client

Inherits:
API::RestClient
  • Object
show all
Defined in:
lib/wcc/media/client.rb,
lib/wcc/media/client/response.rb

Defined Under Namespace

Classes: Resource, Response

Constant Summary collapse

PARAMS =
%w[
  limit
  offset
  order_by
  sort
  target
].freeze
CONFIGURABLE_PARAMS =
PARAMS - %w[
  offset
]
RESOURCES =
{
  'messages' => WCC::Media::Message,
  'series' => WCC::Media::Series,
  'speakers' => WCC::Media::Speaker,
  'tags' => WCC::Media::Tag,
  'playlists' => WCC::Media::Playlist,
  'streams' => WCC::Media::LiveStream
}.freeze

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Client

Returns a new instance of Client.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/wcc/media/client.rb', line 48

def initialize(**options)
  options = {
    api_url: 'https://media.watermark.org/api/v1/',
    response_class: Response,
    adapter: :typhoeus
  }.merge!(options)
  super(**options)

  RESOURCES.each do |(endpoint, model)|
    instance_variable_set(:"@#{endpoint}", Resource.new(self, model, @options))
  end
end

Class Attribute Details

.defaultObject

The default client. Set this in an initializer to change the client used by all the WCC::Media models



21
22
23
# File 'lib/wcc/media/client.rb', line 21

def default
  @default ||= new
end