skydrive 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +46 -1
- data/lib/skydrive/comment.rb +6 -0
- data/lib/skydrive/folder.rb +1 -1
- data/lib/skydrive/object.rb +12 -0
- data/lib/skydrive/operations.rb +22 -0
- data/lib/skydrive/tag.rb +17 -0
- data/lib/skydrive/version.rb +1 -1
- data/spec/skydrive/oauth/client_spec.rb +4 -4
- metadata +3 -2
data/README.md
CHANGED
@@ -16,9 +16,54 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install skydrive
|
18
18
|
|
19
|
+
## Initial steps
|
20
|
+
|
21
|
+
### OAuth2 Authentication
|
22
|
+
|
23
|
+
Skydrive uses OAuth2 authentication. First you will have to initialize a Skydrive::Oauth::Client object with the client id, client secret, callback url and scopes [(explained here)](http://msdn.microsoft.com/en-us/library/live/hh243646.aspx)
|
24
|
+
|
25
|
+
oauth_client = Skydrive::Oauth::Client.new("your_client_id", "your_client_secret", "http://yourcallbackurl", "wl.skydrive_update,wl.offline_access")
|
26
|
+
|
27
|
+
Obtain the authentication url
|
28
|
+
|
29
|
+
auth_url = oauth_client.authorize_url
|
30
|
+
|
31
|
+
Redirect the user to the above obtained auth_url. After user gives access to your app, they will be redirected to the callback url with a 'code' parameter. Extract this code and get the access token by invoking the following method
|
32
|
+
|
33
|
+
access_token = oauth_client.get_access_token("the_extracted_code")
|
34
|
+
|
35
|
+
If you have already stored the access_token details somewhere, you can instantiate the access token without having to authorize again. But this might require you to store the refresh token(if scope 'wl.offline_access' has been requested) as well.
|
36
|
+
|
37
|
+
access_token = oauth_client..get_access_token_from_hash("access_token", {:refresh_token => "refresh_token", :expires_at => 1234567})
|
38
|
+
|
39
|
+
|
40
|
+
### Instantiate a client
|
41
|
+
|
42
|
+
After getting the access token instantiate the Skydrive client
|
43
|
+
|
44
|
+
client = Skydrive::Client.new(:access_token => access_token)
|
45
|
+
|
19
46
|
## Usage
|
20
47
|
|
21
|
-
|
48
|
+
### Get the user's home folder
|
49
|
+
|
50
|
+
To get the details about the acting user's home folder
|
51
|
+
folder = client.my_skydrive
|
52
|
+
|
53
|
+
This returns a Skydrive::Folder object.
|
54
|
+
|
55
|
+
Please refer to the documentation for full details about the operations
|
56
|
+
|
57
|
+
## Features
|
58
|
+
|
59
|
+
1. Every thing is an object. For eg: Skydrive::Folder, Skydrive::File
|
60
|
+
2. I have introduced a new object Skydrive::Collection when the result contains multiple type objects
|
61
|
+
3. Downloading files have been enabled
|
62
|
+
|
63
|
+
## Todo
|
64
|
+
|
65
|
+
1. File upload
|
66
|
+
2. More specs
|
22
67
|
|
23
68
|
## Contributing
|
24
69
|
|
data/lib/skydrive/comment.rb
CHANGED
data/lib/skydrive/folder.rb
CHANGED
data/lib/skydrive/object.rb
CHANGED
@@ -96,5 +96,17 @@ module Skydrive
|
|
96
96
|
object["is_embeddable"]
|
97
97
|
end
|
98
98
|
|
99
|
+
# Comments associated with the object
|
100
|
+
# @return [Skydrive::Collection]
|
101
|
+
def comments
|
102
|
+
client.get("/#{id}/comments")
|
103
|
+
end
|
104
|
+
|
105
|
+
# Make a comment about the object
|
106
|
+
# @params [Hash] options
|
107
|
+
# @option options [String] :message The comment
|
108
|
+
def comment options={}
|
109
|
+
client.post("/#{id}/comments", options)
|
110
|
+
end
|
99
111
|
end
|
100
112
|
end
|
data/lib/skydrive/operations.rb
CHANGED
@@ -120,6 +120,7 @@ module Skydrive
|
|
120
120
|
response = put("/#{object_id}", options)
|
121
121
|
end
|
122
122
|
|
123
|
+
|
123
124
|
alias :update_folder :update_skydrive_object
|
124
125
|
alias :update_album :update_skydrive_object
|
125
126
|
alias :update_file :update_skydrive_object
|
@@ -152,5 +153,26 @@ module Skydrive
|
|
152
153
|
response = post("/me/albums", options)
|
153
154
|
end
|
154
155
|
|
156
|
+
# Get comments associated with an object
|
157
|
+
# @param [String] object_id The ID of the object
|
158
|
+
# @return [Skydrive::Collection]
|
159
|
+
def object_comments object_id
|
160
|
+
response = get("/#{object_id}/comments")
|
161
|
+
end
|
162
|
+
|
163
|
+
# Delete a comment
|
164
|
+
# @param [String] comment_id TD od the comment
|
165
|
+
def delete_comment comment_id
|
166
|
+
response = delete("/#{comment_id}")
|
167
|
+
end
|
168
|
+
|
169
|
+
# Comment about an object
|
170
|
+
# @param [String] object_id ID of the object
|
171
|
+
# @param [Hash] options
|
172
|
+
# @options options [String] :message The comment message
|
173
|
+
def create_comment object_id, options={}
|
174
|
+
response = post("/#{object_id}/comments", options)
|
175
|
+
end
|
176
|
+
|
155
177
|
end
|
156
178
|
end
|
data/lib/skydrive/tag.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Skydrive
|
2
|
+
# Contains info about tags that are associated with a photo or a video on SkyDrive
|
3
|
+
class Tag < Skydrive::Object
|
4
|
+
|
5
|
+
# The center of the tag's horizontal position, measured as a floating-point percentage from 0 to 100, from the left edge of the photo
|
6
|
+
# @return [Integer]
|
7
|
+
def x
|
8
|
+
object["x"]
|
9
|
+
end
|
10
|
+
|
11
|
+
# The center of the tag's vertical position, measured as a floating-point percentage from 0 to 100, from the top edge of the photo
|
12
|
+
def y
|
13
|
+
object["y"]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/skydrive/version.rb
CHANGED
@@ -7,7 +7,7 @@ describe Skydrive::Oauth::Client do
|
|
7
7
|
@uri = URI.parse(subject.authorize_url)
|
8
8
|
@uri_params = CGI.parse(@uri.query)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "should have the correct request token path" do
|
12
12
|
@uri.path.should == "/oauth20_authorize.srf"
|
13
13
|
end
|
@@ -31,15 +31,15 @@ describe Skydrive::Oauth::Client do
|
|
31
31
|
"code" => "code",
|
32
32
|
"grant_type" => "authorization_code",
|
33
33
|
"redirect_uri" => "http://callback_demo"
|
34
|
-
},
|
34
|
+
},
|
35
35
|
:headers => {
|
36
36
|
'Accept' => '*/*',
|
37
37
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
38
|
-
'User-Agent' => '
|
38
|
+
'User-Agent' => 'Faraday v0.8.7'
|
39
39
|
}
|
40
40
|
).to_return(
|
41
41
|
:status => 200, :body => {
|
42
|
-
"token_type" => "bearer",
|
42
|
+
"token_type" => "bearer",
|
43
43
|
"expires_in" => 3600,
|
44
44
|
"scope" => "wl.skydrive_update,wl.offline_access",
|
45
45
|
"access_token" => "access_token",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skydrive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -311,6 +311,7 @@ files:
|
|
311
311
|
- lib/skydrive/object.rb
|
312
312
|
- lib/skydrive/operations.rb
|
313
313
|
- lib/skydrive/photo.rb
|
314
|
+
- lib/skydrive/tag.rb
|
314
315
|
- lib/skydrive/user.rb
|
315
316
|
- lib/skydrive/version.rb
|
316
317
|
- lib/skydrive/video.rb
|