Class: DropboxApi::Metadata::SharedLink

Inherits:
Base
  • Object
show all
Defined in:
lib/dropbox_api/metadata/shared_link.rb

Constant Summary collapse

VALID_KEYS =
[:url, :password]

Instance Method Summary collapse

Methods inherited from Base

field, #serialized_field

Constructor Details

#initialize(param) ⇒ SharedLink

Returns a new instance of SharedLink.


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dropbox_api/metadata/shared_link.rb', line 5

def initialize(param)
  @shared_link =
    case param
    when String
      {:url => param}
    when Hash
      param
    end

  check_validity
end

Instance Method Details

#check_validityObject


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dropbox_api/metadata/shared_link.rb', line 17

def check_validity
  if @shared_link[:url].nil?
    raise ArgumentError, "Missing `:url` option"
  end

  @shared_link.keys.each do |key|
    unless VALID_KEYS.include? key
      raise ArgumentError, "Invalid option `#{key.inspect}`"
    end
  end
end

#to_hashObject


29
30
31
# File 'lib/dropbox_api/metadata/shared_link.rb', line 29

def to_hash
  @shared_link
end