Class: WCC::Media::Client

Inherits:
RestClient show all
Defined in:
lib/wcc/media/client.rb,
lib/wcc/media/client/version.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
RESOURCES =
{
  'messages' => WCC::Media::Message,
  'series' => WCC::Media::Series,
  'speakers' => WCC::Media::Speaker,
  'tags' => WCC::Media::Tag
}.freeze
VERSION =
'0.2.1'.freeze

Constants inherited from RestClient

RestClient::ADAPTERS

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from RestClient

#api_url

Instance Method Summary collapse

Methods inherited from RestClient

#get, load_adapter

Constructor Details

#initialize(**options) ⇒ Client

Returns a new instance of Client.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/wcc/media/client.rb', line 38

def initialize(**options)
  options = {
    api_url: 'https://media.watermark.org/api/v1/',
    response_class: Response
  }.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



15
16
17
# File 'lib/wcc/media/client.rb', line 15

def default
  @default ||= new
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



36
37
38
# File 'lib/wcc/media/client.rb', line 36

def options
  @options
end