O365RubyEasy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/O365RubyEasy.gemspec +28 -0
- data/README.md +127 -0
- data/Rakefile +2 -0
- data/lib/O365RubyEasy.rb +8 -0
- data/lib/O365RubyEasy/version.rb +3 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80c775dfcdbcd29e3be2f2951897aee0f5fb1971
|
4
|
+
data.tar.gz: 22c1595cc024dc83b749d0780387448d362b531f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: abae390cddc7547129bb52c7321bb7a227d479c5132a285809148569df00c7b67627692d79c6164e62b78b190c1cc0532ca51c09f36a09d10d3de0aaaeb518d7
|
7
|
+
data.tar.gz: d6f74ecb43268757adeda649006c537d003a95d6aca580434333ff07d5bae4a38d4e909941fe4f39ddbea526cbd1fc94ceebcb6872bfe10f35040d6836cbf3ed
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 sumurthy
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'O365RubyEasy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "O365RubyEasy"
|
8
|
+
spec.version = O365RubyEasy::VERSION
|
9
|
+
spec.authors = ["sumurthy"]
|
10
|
+
spec.email = ["su.api@hotmail.com"]
|
11
|
+
spec.summary = %q{Ruby Library to access Office 365 APIs.}
|
12
|
+
spec.description = %q{Refer to readme file.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.6"
|
24
|
+
|
25
|
+
spec.add_dependency "activesupport"
|
26
|
+
|
27
|
+
|
28
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# O365rubylib
|
2
|
+
|
3
|
+
This Ruby Gem is intended for Ruby web application developers to access Office 365 Services, which includes OneDrive for Business, Outlook, etc. This initial version targets subset of v1.0 OneDrive Business Files APIs.
|
4
|
+
The details of the Office 365 REST APIs can be found at http://dev.office.com under documentation section.
|
5
|
+
|
6
|
+
This library is will evolve over time. We encourage developer community engagement and feedback to improve the quality and enhance the features.
|
7
|
+
|
8
|
+
## Pre-requisites
|
9
|
+
|
10
|
+
In order to use the SDK against Office 365 service the developer will need a Office 365 tenant and Azure account that is linked to Office 365 tenant.
|
11
|
+
|
12
|
+
This allows App registration and configuration, which is a key input into creating a client.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'o365rubylib'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install o365rubylib
|
29
|
+
|
30
|
+
In your Application require o365rubylib
|
31
|
+
|
32
|
+
## Setup
|
33
|
+
```ruby
|
34
|
+
require 'o365rubylib'
|
35
|
+
```
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
### Authentication
|
40
|
+
This library supports Oauth2 protocol. The first step is to supply the following application configuration required to create a session.
|
41
|
+
1. Client Id
|
42
|
+
2. Secret
|
43
|
+
3. Reply URL(s)
|
44
|
+
todo: The Office 365 discovery service needs to be incorporated. Until that time the resource URL needs to be supplied as an input.
|
45
|
+
|
46
|
+
To create a Session object, supply the input configuration details.
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
APP_CONFIG = {
|
50
|
+
client_id: "32ea5265-35bc-49c7-bf03-fa7928bc07dc",
|
51
|
+
redirect_uri: "http://localhost:4567/go",
|
52
|
+
secret: "C+WTbpXIt26drLsv3lXY/qyOQn6hPfGcLHo8IYnHO1Q=",
|
53
|
+
resource_uri: "https://<tenant-name>-my.sharepoint.com/",
|
54
|
+
fileservice_uri: "https://<tenant-name>-my.sharepoint.com/_api/v1.0/me/"
|
55
|
+
}
|
56
|
+
```
|
57
|
+
|
58
|
+
Next, create a session by passing the configuration information to the session object.
|
59
|
+
```ruby
|
60
|
+
session = O365rubylib::Session.new (APP_CONFIG)
|
61
|
+
```
|
62
|
+
When the user visits your application, ensure that you have the required consent. You can redirect the user to Azure authentication service and have them consent the necessary permissions needed by your App.
|
63
|
+
|
64
|
+
You can create an authorization URL as follows
|
65
|
+
```ruby
|
66
|
+
auth_url = session.get_auth_url
|
67
|
+
```
|
68
|
+
After consent, Azure will redirect to the URL supplied in the "redirect_uri". In that page/service, create the Oauth2 access token OneDrive Files client.
|
69
|
+
```ruby
|
70
|
+
accesstoken = session.get_access_token(params[:code])
|
71
|
+
fileClient = O365rubylib::OneDriveClient.new (session)
|
72
|
+
```
|
73
|
+
Now armed with the client, you can access O365 Files APIs.
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
accesstoken = session.get_access_token(params[:code])
|
77
|
+
fileClient = O365rubylib::OneDriveClient.new (session)
|
78
|
+
```
|
79
|
+
|
80
|
+
### APIs
|
81
|
+
|
82
|
+
Get File or Folder metadata. You'll receive a hash of the item:
|
83
|
+
```ruby
|
84
|
+
enc_path = URI::encode('resource-path')
|
85
|
+
item = fileClient.getItemByPath(enc_path)
|
86
|
+
print item ['name']
|
87
|
+
```
|
88
|
+
|
89
|
+
List the children of a folder:
|
90
|
+
```ruby
|
91
|
+
enc_path = URI::encode('resource-path')
|
92
|
+
resp = fileClient.getChildrenByPath(enc_path)
|
93
|
+
resphash = resp["value"]
|
94
|
+
resphash.each do |arr|
|
95
|
+
print arr['name']
|
96
|
+
print arr['parentReference']['path']
|
97
|
+
...
|
98
|
+
end
|
99
|
+
```
|
100
|
+
|
101
|
+
Delete a resource:
|
102
|
+
```ruby
|
103
|
+
enc_path = URI::encode('resource-path')
|
104
|
+
fileClient.deleteItem(enc_path)
|
105
|
+
```
|
106
|
+
|
107
|
+
Download a file to a local destination:
|
108
|
+
```ruby
|
109
|
+
enc_path = URI::encode('resource-path')
|
110
|
+
fileClient.downloadFile(enc_path, local_path)
|
111
|
+
```
|
112
|
+
|
113
|
+
Upload a file:
|
114
|
+
```ruby
|
115
|
+
enc_path = URI::encode('resource-path')
|
116
|
+
fileClient.uploadFileToPath(enc_path, local_path)
|
117
|
+
```
|
118
|
+
|
119
|
+
More coming...
|
120
|
+
|
121
|
+
## Contributing
|
122
|
+
|
123
|
+
1. Fork it ( https://github.com/[my-github-username]/o365rubylib/fork )
|
124
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
125
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
126
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
127
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/O365RubyEasy.rb
ADDED
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: O365RubyEasy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sumurthy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Refer to readme file.
|
70
|
+
email:
|
71
|
+
- su.api@hotmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- O365RubyEasy.gemspec
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/O365RubyEasy.rb
|
83
|
+
- lib/O365RubyEasy/version.rb
|
84
|
+
homepage: ''
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.2.2
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Ruby Library to access Office 365 APIs.
|
108
|
+
test_files: []
|