ruby-office365 0.1.5 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86ee47df4ac96c36024adb5c0595afa78889dc9659aebcdbdf01a59e407a0db9
4
- data.tar.gz: 42ab9271c0d32b6035ad9caecc837137774bde57d0894fd49f34782d8c0f1f1b
3
+ metadata.gz: b25c6ebfd49566d52252acf88d545334c3836df70727334f6fe7dc420b3ec2d2
4
+ data.tar.gz: f7513d00478b3db8206dade494d02d401ebf998b9e22b2707c19a0ee8d017b12
5
5
  SHA512:
6
- metadata.gz: 8dd5a3b6d974b91bf6c2846b1b9b3f433fcc1abe11d6dfc85f3fe3a7b023313db0079b6056a1e27d3d8a36506a434a4ef0e45f327f4d2dd25b0416f681ff5906
7
- data.tar.gz: fc2997832814ec584184584546ca7443841914191056f5fd3c080017cf21b273a05f9dd5612b928ad7570fb3cbc202ff0cbaba01e86a62b250c409f1e87776b9
6
+ metadata.gz: 84ebf0fc3fb83ea4a529a38880ea4dc10c932dbb7c0b6a57804d0e53b337dba1ff7669981af84c5b04cfff519a1e9062199c5d9f70cdd506906460b3b1cd7ca0
7
+ data.tar.gz: 7af1f230a6ba4e5f76a23f1cd28ad0399efd64ff1c91a1da9c05c2c903806b070dbc860a82945c527b8c5efd581e0c611a6db530424c3a9e5fb6b0ceffd05cf0
data/CHANGELOG.md CHANGED
@@ -15,12 +15,12 @@
15
15
 
16
16
  - Integrate REST API to get mailbox with pagination
17
17
  - get mailbox data with next link `client.messages({next_link: 'xxx'})`
18
- - get mailbox data with next link `client.calenders({next_link: 'xxx'})`
18
+ - get calenders data with next link `client.calenders({next_link: 'xxx'})`
19
19
 
20
20
  ## [0.1.3] - (2022-10-26)
21
21
 
22
22
  - Integrate REST API to get contacts
23
- - get profile `client.contacts`
23
+ - get contacts `client.contacts`
24
24
  - get contacts data with next link `client.contacts({next_link: 'xxx'})`
25
25
 
26
26
  ## [0.1.5] - (2022-10-27)
@@ -28,4 +28,10 @@
28
28
  - Generate URLs for token and able to refresh token
29
29
  - get authorize URL `client.authorize_url`
30
30
  - get token URL `client.token_url`
31
- - be able to refresh token `client.refresh_token!`
31
+ - be able to refresh token `client.refresh_token!`
32
+
33
+ ## [0.1.6] - (2022-11-01)
34
+
35
+ - Integrate REST API to get events
36
+ - get events `client.events`
37
+ - get events data with next link `client.events({next_link: 'xxx'})`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-office365 (0.1.5)
4
+ ruby-office365 (0.1.6)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Office 365
1
+ # Office 365 (2022)
2
2
 
3
3
  A simple ruby library to interact with Microsoft Graph and Office 365 API.
4
4
 
@@ -18,31 +18,48 @@ If bundler is not being used to manage dependencies, install the gem by executin
18
18
 
19
19
  You can pass configuration options as a block to `Office365::REST::Client.new`.
20
20
 
21
+ - tenant_id: optional, only required for refresh_token
22
+ - client_id: optional, only required for refresh_token
23
+ - client_secret: optional, only required for refresh_token
24
+ - access_token: required for fetch mailbox, calendars, contacts data
25
+ - refresh_token: optional, only required for refresh_token
26
+ - debug: optional, default false, output the request information
27
+
28
+ ### Used to get data from MS Graph API
29
+
30
+ ```ruby
31
+ client = Office365::REST::Client.new do |config|
32
+ config.access_token = "YOUR_ACCESS_TOKEN"
33
+ config.debug = "true/false" # Optional, default to false, output the information in the request
34
+ end
35
+ ```
36
+
37
+ ### For refresh token
38
+
21
39
  ```ruby
22
40
  client = Office365::REST::Client.new do |config|
23
- config.tenant_id = "YOUR_ORG_TENANT_ID"
24
- config.client_id = "YOUR_APP_CLIENT_ID"
25
- config.client_secret = "YOUR_APP_CLIENT_SECRET"
26
- config.redirect_uri = "YOUR_APP_REDIRECT_URL"
27
- config.access_token = "YOUR_ACCESS_TOKEN"
28
- config.refresh_token = "YOUR_REFRESH_TOKEN"
41
+ config.tenant_id = "YOUR_ORG_TENANT_ID"
42
+ config.client_id = "YOUR_APP_CLIENT_ID"
43
+ config.client_secret = "YOUR_APP_CLIENT_SECRET"
44
+ config.refresh_token = "YOUR_REFRESH_TOKEN"
45
+ config.debug = "true/false" # Optional, default to false, output the information in the request
29
46
  end
30
47
  ```
31
48
 
32
- ## Usage Examples
49
+ ## Usage
33
50
 
34
51
  After configuring a `client`, you can do the following things.
35
52
 
36
- **response**
53
+ **Response structure**
37
54
 
38
- - `results`: wrap all data into results
39
- - `next_link`: get the new link for the next page of data
55
+ - results: wrap all data into results
56
+ - next_link: get the new link for the next page of data
40
57
 
41
- **to JSON**
58
+ **A simple way to convert an office365 object to JSON**
42
59
 
43
- - `as_json`: convert office365 object to JSON format
60
+ - as_json: convert office365 object to JSON format
44
61
 
45
- **Get Profile (as the authenticated user)**
62
+ **Get my profile by access token**
46
63
 
47
64
  ```ruby
48
65
  irb(main):004:0> response = client.me
@@ -65,7 +82,7 @@ irb(main):004:0> response.as_json
65
82
  }
66
83
  ```
67
84
 
68
- **Get my calendars**
85
+ **Get my calendars by access token**
69
86
 
70
87
  ```ruby
71
88
  irb(main):005:0> client.calendars
@@ -73,7 +90,15 @@ irb(main):005:0> client.calendars[:results]
73
90
  irb(main):005:0> client.calendars[:next_link]
74
91
  ```
75
92
 
76
- **Get my mails**
93
+ **Get my events by access token**
94
+
95
+ ```ruby
96
+ irb(main):005:0> client.events
97
+ irb(main):005:0> client.events[:results]
98
+ irb(main):005:0> client.events[:next_link]
99
+ ```
100
+
101
+ **Get my mails by access token**
77
102
 
78
103
  ```ruby
79
104
  irb(main):005:0> client.messages
@@ -82,7 +107,7 @@ irb(main):005:0> client.messages({ filter: "createdDateTime lt 2022-01-01" })
82
107
  irb(main):005:0> client.messages({ filter: "createdDateTime lt 2022-01-01", next_link: 'https://....' })
83
108
  ```
84
109
 
85
- **Get my contacts**
110
+ **Get my contacts by access token**
86
111
 
87
112
  ```ruby
88
113
  irb(main):018:0> response = client.contacts
@@ -132,7 +157,7 @@ irb(main):018:0> response[:results][0].as_json
132
157
  }
133
158
  ```
134
159
 
135
- **Refresh User Token**
160
+ **Refresh access token by refresh token**
136
161
 
137
162
  ```ruby
138
163
  irb(main):005:0> response = client.refresh_token!
@@ -144,6 +169,12 @@ irb(main):005:0> response.refresh_token
144
169
  => "0.ARgA7EiQdLv1qECnFqPfrznKsT9ERYaGfG9Ki5WzQtEllj8YAJk.AgABAAEAAAD--DLA3VO7QrddgJg7WevrAgDs_wQA9P-Q1ODlBsrdZi-5s2mfLtEsavBgiEhGcz1KEf26fMrGFU3LM_og5l6wjSAtQ83XHLuje0_KYGol26_LGV_uH0F1MwCFR1N3ctwg4_...."
145
170
  ```
146
171
 
172
+ ## Development
173
+
174
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
175
+
176
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
177
+
147
178
  ## Copyright
148
179
 
149
180
  Copyright (c) 2022 Encore Shao. See LICENSE for details.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Office365
4
+ module Models
5
+ class Event < Base
6
+ end
7
+ end
8
+ end
@@ -11,5 +11,6 @@ module Office365
11
11
  autoload :EmailAddress, "office365/models/email_address"
12
12
  autoload :Contact, "office365/models/contact"
13
13
  autoload :AccessToken, "office365/models/access_token"
14
+ autoload :Event, "office365/models/event"
14
15
  end
15
16
  end
@@ -5,6 +5,7 @@ require_relative "./mailbox"
5
5
  require_relative "./calendar"
6
6
  require_relative "./contact"
7
7
  require_relative "./token"
8
+ require_relative "./event"
8
9
 
9
10
  module Office365
10
11
  module REST
@@ -14,6 +15,7 @@ module Office365
14
15
  include Office365::REST::Calendar
15
16
  include Office365::REST::Contact
16
17
  include Office365::REST::Token
18
+ include Office365::REST::Event
17
19
  end
18
20
  end
19
21
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./concerns/base"
4
+
5
+ module Office365
6
+ module REST
7
+ module Event
8
+ include Concerns::Base
9
+
10
+ # params: args => { next_link: (nil / next_page_url) }
11
+ # response { results: [], next_link: '...' }
12
+ def events(args = {})
13
+ response = message_response(args: args.merge(base_uri: "/me/events"))
14
+
15
+ {
16
+ results: response["value"].map { |v| Models::Event.new(v) },
17
+ next_link: response["@odata.nextLink"]
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Office365
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-office365
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Encore Shao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-27 00:00:00.000000000 Z
11
+ date: 2022-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -119,6 +119,7 @@ files:
119
119
  - lib/office365/models/contact.rb
120
120
  - lib/office365/models/directory.rb
121
121
  - lib/office365/models/email_address.rb
122
+ - lib/office365/models/event.rb
122
123
  - lib/office365/models/mailbox.rb
123
124
  - lib/office365/models/owner.rb
124
125
  - lib/office365/models/user.rb
@@ -128,6 +129,7 @@ files:
128
129
  - lib/office365/rest/client.rb
129
130
  - lib/office365/rest/concerns/base.rb
130
131
  - lib/office365/rest/contact.rb
132
+ - lib/office365/rest/event.rb
131
133
  - lib/office365/rest/mailbox.rb
132
134
  - lib/office365/rest/request.rb
133
135
  - lib/office365/rest/token.rb
@@ -161,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
163
  - !ruby/object:Gem::Version
162
164
  version: '0'
163
165
  requirements: []
164
- rubygems_version: 3.1.6
166
+ rubygems_version: 3.2.3
165
167
  signing_key:
166
168
  specification_version: 4
167
169
  summary: A simple ruby library to interact with Microsoft Graph and Office 365 API.