Class: Webex::User::File

Inherits:
Object
  • Object
show all
Includes:
Webex, Webex::User
Defined in:
lib/webex/user/file.rb

Overview

comment

Constant Summary

Constants included from Webex::User

PATH_URL

Constants included from Webex

CONFIGURATION, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Webex::User

#post_url

Methods included from Webex

#env_attributes!, #option_required!

Constructor Details

#initialize(attributes = {}) ⇒ File

Returns a new instance of File.



10
11
12
13
14
# File 'lib/webex/user/file.rb', line 10

def initialize(attributes = {})
  attributes.each { |k, v| send("#{k}=", v) }
  env_attributes!
  option_required! :back_url
end

Instance Attribute Details

#back_urlObject

Returns the value of attribute back_url.



8
9
10
# File 'lib/webex/user/file.rb', line 8

def back_url
  @back_url
end

#current_directoryObject

Returns the value of attribute current_directory.



8
9
10
# File 'lib/webex/user/file.rb', line 8

def current_directory
  @current_directory
end

#file_nameObject

Returns the value of attribute file_name.



8
9
10
# File 'lib/webex/user/file.rb', line 8

def file_name
  @file_name
end

Instance Method Details

#downloadObject



16
17
18
19
20
# File 'lib/webex/user/file.rb', line 16

def download
  option_required! :file_name
  res = Net::HTTP.post_form post_url, generate_params(api_type: 'DF')
  Hash[res.body.stringify_string.split('&').map! { |i| i.split('=') }]
end

#generate_params(overwrite_params = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/webex/user/file.rb', line 27

def generate_params(overwrite_params = {})
  result = {}
  result[:AT] = overwrite_params[:api_type]
  result[:BU] = back_url
  result[:FN] = file_name if result[:AT] == 'DF'
  result[:CD] = current_directory if result[:AT] == 'LF'

  result.delete_if { |k, v| v.nil? }
end

#listObject



22
23
24
25
# File 'lib/webex/user/file.rb', line 22

def list
  res = Net::HTTP.post_form post_url, generate_params(api_type: 'LF')
  Hash[res.body.stringify_string.split('&').map! { |i| i.split('=') }]
end