module Officepod::Storage

Public Instance Methods

storage_auth_list(lang: nil, cookie: nil) click to toggle source
# 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