Module: Wistia

Defined in:
lib/wistia.rb,
lib/wistia/base.rb,
lib/wistia/media.rb,
lib/wistia/config.rb,
lib/wistia/project.rb,
lib/wistia/projects/sharing.rb

Defined Under Namespace

Modules: Config, Projects Classes: Base, Media, Project

Class Method Summary collapse

Class Method Details

.config(&block) ⇒ Object



5
6
7
# File 'lib/wistia/config.rb', line 5

def config(&block)
  Wistia::Config.config(&block)
end

.format=(fmt) ⇒ Object

Set the format that the API uses to either 'json' or 'xml'. Accepts either a String or a Symbol.

Raises:

  • (ArgumentError)


35
36
37
38
39
# File 'lib/wistia.rb', line 35

def self.format=(fmt)
  valid_formats = [ :json, :xml ]
  raise ArgumentError, "Invalid format.  Supported formats: #{valid_formats.join(', ')}." unless valid_formats.include?(fmt.to_sym)
  use_config!(:wistia => { :api => { :format => fmt.to_sym } })
end

.password=(pw) ⇒ Object

Set your API password using this method. For instructions to find your API password, go here: wistia.com/doc/api-enable



29
30
31
# File 'lib/wistia.rb', line 29

def self.password=(pw)
  use_config!(:wistia => { :api => { :key => pw } })
end

.refresh_config!Object

Force each ActiveResource descendant to re-read its configuration from the configatron.



42
43
44
45
46
# File 'lib/wistia.rb', line 42

def self.refresh_config!
  Wistia::Media.refresh_config!
  Wistia::Project.refresh_config!
  Wistia::Projects::Sharing.refresh_config!
end

.use_config!(config) ⇒ Object

Specifies a new configuration to use for the API. Accepts either a Hash or a String pointing to a YAML configuration file.

Example using a Hash:

Wistia.use_config!(:wistia => { :api => { :key => 'your-api-key', :format => 'json-or-xml' } })


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/wistia.rb', line 15

def self.use_config!(config)
  if config.is_a?(String) && File.exists?(config) && File.extname(config) == '.yml'
    configatron.configure_from_yaml(config)
  elsif config.is_a?(Hash)
    configatron.configure_from_hash(config)
  else
    raise ArgumentError, 'Invalid config'
  end

  refresh_config!
end