forked from microsoftgraph/msgraph-sdk-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
5,973 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ | |
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
.env | ||
.DS_Store |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
# MicrosoftGraphSdk | ||
|
||
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/microsoft_graph_sdk`. To experiment with that code, run `bin/console` for an interactive prompt. | ||
|
||
TODO: Delete this and the text above, and describe your gem | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
## Usage | ||
|
||
```ruby | ||
gem 'microsoft_graph_sdk' | ||
require 'adal' | ||
require 'microsoft_graph' | ||
|
||
# authenticate using ADAL | ||
username = '[email protected]' | ||
password = 'xxxxxxxxxxxx' | ||
client_id = 'xxxxx-xxxx-xxx-xxxxxx-xxxxxxx' | ||
client_secret = 'xxxXXXxxXXXxxxXXXxxXXXXXXXXxxxxxx=' | ||
tenant = 'tenant.onmicrosoft.com' | ||
user_cred = ADAL::UserCredential.new(username, password) | ||
client_cred = ADAL::ClientCredential.new(client_id, client_secret) | ||
context = ADAL::AuthenticationContext.new(ADAL::Authority::WORLD_WIDE_AUTHORITY, tenant) | ||
tokens = context.acquire_token_for_user(resource, client_cred, user_cred) | ||
|
||
# connect to the API and create the classes (most of this should be defaulted later) | ||
service = OData::Service.new( | ||
base_url: "https://graph.microsoft.com/v1.0/", | ||
namespace: "microsoft.graph", | ||
metadata_file: File.join(MicrosoftGraph::CACHED_METADATA_DIRECTORY, "metadata_v1.0.xml"), | ||
auth_token: tokens.access_token, | ||
) | ||
|
||
graph = MicrosoftGraph.new(service) | ||
|
||
me = graph.me # get the current user | ||
puts "Hello, I am #{me.display_name}." | ||
|
||
me.direct_reports.each do |person| | ||
puts "How's it going, #{person.display_name}?" | ||
end | ||
``` | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install microsoft_graph_sdk | ||
|
||
## Usage | ||
|
||
TODO: Write usage instructions here | ||
|
||
## Development | ||
|
||
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. | ||
gem install bundler | ||
bundle install | ||
|
||
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). | ||
### Running Tests | ||
|
||
## Contributing | ||
#### Unit Tests | ||
|
||
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/microsoft_graph_sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. | ||
Run them like this: | ||
|
||
bundle exec rspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.