Module: Skydrive::Operations

Included in:
Client
Defined in:
lib/skydrive/operations.rb

Overview

The basic operations

Instance Method Summary collapse

Instance Method Details

#create_album(options = {}) ⇒ Skydrive::Album

Create a new album. Albums can only be created in the path ‘/me/albums’, so no need to pass the path as a parameter

Parameters:

  • options (Hash) (defaults to: {})

    the details of the new album

Options Hash (options):

  • :name (String)

    required, the name of the new album

  • :description (String)

    the description about the album

Returns:



157
158
159
# File 'lib/skydrive/operations.rb', line 157

def create_album options={}
  response = post("/me/albums", options)
end

#create_comment(object_id, options = {}) ⇒ Object

Comment about an object

Parameters:

  • object_id (String)

    ID of the object

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :message (String)

    The comment message



178
179
180
# File 'lib/skydrive/operations.rb', line 178

def create_comment object_id, options={}
  response = post("/#{object_id}/comments", options)
end

#create_folder(path, options = {}) ⇒ Skydrive::Folder

Create a new folder

Parameters:

  • path (String)

    the path where the new folder should be created

  • options (Hash) (defaults to: {})

    the details of the new folder

Options Hash (options):

  • :name (String)

    required, the name of the new folder

  • :description (String)

    the description about the folder

Returns:



148
149
150
# File 'lib/skydrive/operations.rb', line 148

def create_folder path, options={}
  response = post("/#{path}", options)
end

#delete_comment(comment_id) ⇒ Object

Delete a comment

Parameters:

  • comment_id (String)

    TD od the comment



170
171
172
# File 'lib/skydrive/operations.rb', line 170

def delete_comment comment_id
  response = delete("/#{comment_id}")
end

#delete_skydrive_object(object_id) ⇒ Object Also known as: delete_folder, delete_album, delete_file, delete_video, delete_audio, delete_photo

Delete an object with given id

Parameters:

  • object_id (String)

    the id of the object to be deleted



110
111
112
# File 'lib/skydrive/operations.rb', line 110

def delete_skydrive_object object_id
  response = delete("/#{object_id}")
end

#get_skydrive_object_by_id(id) ⇒ Object

Get an object by its id

Parameters:

  • id (String)

    The id of the object you want



125
126
127
# File 'lib/skydrive/operations.rb', line 125

def get_skydrive_object_by_id id
  response = get("/#{id}")
end

#my_camera_rollSkydrive::Folder

Your camera_roll folder

Returns:



20
21
22
# File 'lib/skydrive/operations.rb', line 20

def my_camera_roll
  response = get("/me/skydrive/camera_roll")
end

#my_documentsSkydrive::Folder

Your documents

Returns:



33
34
35
# File 'lib/skydrive/operations.rb', line 33

def my_documents
  response = get("/me/skydrive/my_documents")
end

#my_photosSkydrive::Album

Your default album

Returns:



46
47
48
# File 'lib/skydrive/operations.rb', line 46

def my_photos
  response = get("/me/skydrive/my_photos")
end

#my_public_documentsSkydrive::Folder

Your public documents

Returns:



59
60
61
# File 'lib/skydrive/operations.rb', line 59

def my_public_documents
  response = get("/me/skydrive/public_documents")
end

#my_recent_documentsSkydrive::Collection

Your recent documents

Parameters:

  • user_id (String)

    ID of the user

Returns:



85
86
87
# File 'lib/skydrive/operations.rb', line 85

def my_recent_documents
  response = get("/me/skydrive/recent_docs")
end

#my_shared_stuffSkydrive::Collection

Your shared items



72
73
74
# File 'lib/skydrive/operations.rb', line 72

def my_shared_stuff
  response = get("/me/skydrive/shared")
end

#my_skydriveSkydrive::Folder

Your home folder

Returns:



7
8
9
# File 'lib/skydrive/operations.rb', line 7

def my_skydrive
  response = get("/me/skydrive")
end

#my_storage_quotaHash

Your total and remaining storage quota

Returns:

  • (Hash)

    contains keys quota and available



98
99
100
# File 'lib/skydrive/operations.rb', line 98

def my_storage_quota
  response = get("/me/skydrive/quota")
end

#object_comments(object_id) ⇒ Skydrive::Collection

Get comments associated with an object

Parameters:

  • object_id (String)

    The ID of the object

Returns:



164
165
166
# File 'lib/skydrive/operations.rb', line 164

def object_comments object_id
  response = get("/#{object_id}/comments")
end

#update_skydrive_object(object_id, options = {}) ⇒ Object Also known as: update_folder, update_album, update_file, update_video, update_audio, update_photo

Update a skydrive object

Parameters:

  • object_id (String)

    the id of the object to be updated

  • options (Hash) (defaults to: {})

    The properties to be updated

Options Hash (options):

  • :name (String)

    The friendly name of the object

  • :description (String)

    The description text about the object



119
120
121
# File 'lib/skydrive/operations.rb', line 119

def update_skydrive_object object_id, options={}
  response = put("/#{object_id}", options)
end

#upload(folder_path, filename, file, options = {}) ⇒ Skydrive::File

Upload a file

Parameters:

  • folder_path (String)

    Either ‘me/skydrive’ or FOLDER_ID(id of the parent folder)

  • filename (String)

    Name of the new file

  • The (File)

    actual file to be uploaded

  • options (Hash) (defaults to: {})

    Any additional options to be passed

Options Hash (options):

  • :overwrite (Boolean)

    whether to overwrite the file

Returns:



189
190
191
# File 'lib/skydrive/operations.rb', line 189

def upload folder_path, filename, file, options={}
  response = put("/#{folder_path}/files/#{filename}", file.read, options)
end

#user_camera_roll(user_id) ⇒ Skydrive::Folder

Get the camera_roll folder of a particular user

Parameters:

  • user_id (String)

    ID of the user

Returns:



27
28
29
# File 'lib/skydrive/operations.rb', line 27

def user_camera_roll user_id
  response = get("/#{user_id}/camera_roll")
end

#user_documents(user_id) ⇒ Skydrive::Folder

User’s documents

Parameters:

  • user_id (String)

    ID of the user

Returns:



40
41
42
# File 'lib/skydrive/operations.rb', line 40

def user_documents user_id
  response = get("/#{user_id}/skydrive/my_documents")
end

#user_photos(user_id) ⇒ Skydrive::Folder

User’s photos

Parameters:

  • user_id (String)

    ID of the user

Returns:



53
54
55
# File 'lib/skydrive/operations.rb', line 53

def user_photos user_id
  response = get("/#{user_id}/skydrive/my_photos")
end

#user_public_documents(user_id) ⇒ Skydrive::Folder

User’s public documents

Parameters:

  • user_id (String)

    ID of the user

Returns:



66
67
68
# File 'lib/skydrive/operations.rb', line 66

def user_public_documents user_id
  response = get("/#{user_id}/skydrive/public_documents")
end

#user_recent_documents(user_id) ⇒ Skydrive::Collection

User’s recent documents

Parameters:

  • user_id (String)

    ID of the user

Returns:



92
93
94
# File 'lib/skydrive/operations.rb', line 92

def user_recent_documents user_id
  response = get("/#{user_id}/skydrive/recent_docs")
end

#user_shared_stuffSkydrive::Collection

User’s shared items



78
79
80
# File 'lib/skydrive/operations.rb', line 78

def user_shared_stuff
  response = get("/#{id}/skydrive/shared")
end

#user_skydrive(user_id) ⇒ Skydrive::Folder

Get the home folder of a particular user

Parameters:

  • user_id (String)

    ID of the user

Returns:



14
15
16
# File 'lib/skydrive/operations.rb', line 14

def user_skydrive user_id
  response = get("/#{user_id}/skydrive")
end

#user_storage_quotaHash

User’s total and remaining storage quota

Returns:

  • (Hash)

    contains keys quota and available



104
105
106
# File 'lib/skydrive/operations.rb', line 104

def user_storage_quota
  response = get("/me/skydrive/quota")
end