class OneDriveForBusiness::Folder

Attributes

child_count[R]
children[R]

Public Class Methods

create_with_parent_id!(drive, parent_id, name) click to toggle source

@return Folder

# File lib/onedrive_for_business/folder.rb, line 13
def self.create_with_parent_id!(drive, parent_id, name)
  url = "#{drive.url}/files/#{parent_id}/children/#{name}"
  resp =
    http(url).put(url, nil, 'authorization' => "Bearer #{drive.access_token}")
  Folder.new(drive, JSON.parse(resp.body))
end
create_with_path!(drive, path) click to toggle source

@return Folder

# File lib/onedrive_for_business/folder.rb, line 21
def self.create_with_path!(drive, path)
  url = "#{drive.url}/files/getbypath('#{path}')"
  resp = http(url).put(
    url, nil, 'authorization' => "Bearer #{drive.access_token}")
  Folder.new(drive, JSON.parse(resp.body))
end
get_by_id(drive, id) click to toggle source

@return Folder

# File lib/onedrive_for_business/folder.rb, line 29
def self.get_by_id(drive, id)
  url = "#{drive.url}/files/#{id}"
  resp = http(url).get(
    url, 'authorization' => "Bearer #{drive.access_token}")
  Folder.new(drive, JSON.parse(resp.body))
end
get_by_path(drive, path) click to toggle source

@return Folder

# File lib/onedrive_for_business/folder.rb, line 37
def self.get_by_path(drive, path)
  url = "#{drive.url}/files/getbypath('#{path}')"
  resp = http(url).get(
    url, 'authorization' => "Bearer #{drive.access_token}")
  Folder.new(drive, JSON.parse(resp.body))
end
new(drive, fields) click to toggle source
Calls superclass method
# File lib/onedrive_for_business/folder.rb, line 44
def initialize(drive, fields)
  @child_count = fields['childCount']
  @children = fields['children']
  super
end

Public Instance Methods

contents() click to toggle source
# File lib/onedrive_for_business/folder.rb, line 53
def contents
  @contents ||= contents!
end
contents!() click to toggle source
# File lib/onedrive_for_business/folder.rb, line 57
def contents!
  url = "#{drive.url}/Files/#{id}/children"
  resp = http(url).get(
    url, 'authorization' => "Bearer #{drive.access_token}")
  JSON.parse(resp.body)['value'].select do |o|
    o['type'] == 'File'
  end.map do |o|
    File.new(drive, o)
  end
end