Module: Officepod::Storage

Included in:
Base
Defined in:
lib/officepod/storage.rb

Instance Method Summary collapse

Instance Method Details

#storage_auth_list(lang: nil, cookie: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/officepod/storage.rb', line 4

def storage_auth_list(lang: nil, cookie: nil)
  command = __method__.to_s
  @options[:body] = {
    "command": command,
    "lang": lang
  }
  @options[:headers]["Cookie"] = "SID=#{cookie}"
  ipv4_pattern = /(?:[0-9]{1,3}\.){3}[0-9]{1,3}/
  response = self.class.post(@end_point, @options)
  result = JSON.parse(response.parsed_response)
  result["storagelist"].each do |e|
    e["type"] = "FTP" if e["title"].include? "FTP"
    e["type"] = "SMB" if e["title"].include? "SMB"
    ip = e["filepath"].match ipv4_pattern
    e["ip"]= ip.to_s
  end
  result["storagelist"]
end