omnievent-outlook 0.1.0.pre1 → 0.1.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/Gemfile.lock +11 -17
- data/lib/omnievent/outlook/version.rb +1 -1
- data/lib/omnievent/strategies/outlook.rb +100 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06b741b2ee92037e24559210747854d0ff17e9edc1417cbf99cf37f3c2f73e05
|
4
|
+
data.tar.gz: 51d4d7b559e69f95a75936bb1d6bb011b57d4af38095cb20977114f9add65ad2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57dfb4066765f11cca472188d5c4ac149f72e016c91aa8f05bedf3ebe808ec9a34af8bdbc0bf5f5525d09806a5104f56f4765c3002355d6bf798443be5a0c265
|
7
|
+
data.tar.gz: abe1e80a5170f3b24a7083b0cdf4092973cef68f28e3fd570bba7e832e9755b4187189d2f13c2e0855fe3c58992a04e6cd9eefd4df77fad0720fb35d0156effc
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
omnievent-outlook (0.1.0.
|
4
|
+
omnievent-outlook (0.1.0.pre2)
|
5
5
|
omnievent
|
6
6
|
omnievent-api
|
7
7
|
|
8
|
-
PATH
|
9
|
-
remote: /Users/angus/omnievent/omnievent
|
10
|
-
specs:
|
11
|
-
omnievent (0.1.0.pre3)
|
12
|
-
hashie (>= 3.4.6)
|
13
|
-
iso-639 (~> 0.3.5)
|
14
|
-
tzinfo (~> 2.0)
|
15
|
-
|
16
8
|
GEM
|
17
9
|
remote: https://rubygems.org/
|
18
10
|
specs:
|
@@ -32,7 +24,11 @@ GEM
|
|
32
24
|
iso-639 (0.3.6)
|
33
25
|
json (2.7.2)
|
34
26
|
language_server-protocol (3.17.0.3)
|
35
|
-
omnievent
|
27
|
+
omnievent (0.1.0.pre5)
|
28
|
+
hashie (>= 3.4.6)
|
29
|
+
iso-639 (~> 0.3.5)
|
30
|
+
tzinfo (~> 2.0)
|
31
|
+
omnievent-api (0.1.0.pre3)
|
36
32
|
excon
|
37
33
|
omnievent
|
38
34
|
parallel (1.26.3)
|
@@ -44,13 +40,13 @@ GEM
|
|
44
40
|
rainbow (3.1.1)
|
45
41
|
rake (13.2.1)
|
46
42
|
regexp_parser (2.9.2)
|
47
|
-
rexml (3.3.
|
43
|
+
rexml (3.3.6)
|
48
44
|
strscan
|
49
45
|
rspec (3.13.0)
|
50
46
|
rspec-core (~> 3.13.0)
|
51
47
|
rspec-expectations (~> 3.13.0)
|
52
48
|
rspec-mocks (~> 3.13.0)
|
53
|
-
rspec-core (3.13.
|
49
|
+
rspec-core (3.13.1)
|
54
50
|
rspec-support (~> 3.13.0)
|
55
51
|
rspec-expectations (3.13.2)
|
56
52
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -59,18 +55,17 @@ GEM
|
|
59
55
|
diff-lcs (>= 1.2.0, < 2.0)
|
60
56
|
rspec-support (~> 3.13.0)
|
61
57
|
rspec-support (3.13.1)
|
62
|
-
rubocop (1.
|
58
|
+
rubocop (1.66.0)
|
63
59
|
json (~> 2.3)
|
64
60
|
language_server-protocol (>= 3.17.0)
|
65
61
|
parallel (~> 1.10)
|
66
62
|
parser (>= 3.3.0.2)
|
67
63
|
rainbow (>= 2.2.2, < 4.0)
|
68
64
|
regexp_parser (>= 2.4, < 3.0)
|
69
|
-
|
70
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
65
|
+
rubocop-ast (>= 1.32.1, < 2.0)
|
71
66
|
ruby-progressbar (~> 1.7)
|
72
67
|
unicode-display_width (>= 2.4.0, < 3.0)
|
73
|
-
rubocop-ast (1.32.
|
68
|
+
rubocop-ast (1.32.2)
|
74
69
|
parser (>= 3.3.1.0)
|
75
70
|
ruby-progressbar (1.13.0)
|
76
71
|
strscan (3.1.0)
|
@@ -87,7 +82,6 @@ PLATFORMS
|
|
87
82
|
|
88
83
|
DEPENDENCIES
|
89
84
|
byebug
|
90
|
-
omnievent!
|
91
85
|
omnievent-outlook!
|
92
86
|
rake (~> 13.0)
|
93
87
|
rspec (~> 3.0)
|
@@ -14,7 +14,7 @@ module OmniEvent
|
|
14
14
|
API_VERSION = "v1.0"
|
15
15
|
|
16
16
|
def raw_events
|
17
|
-
response = perform_request(path: request_path)
|
17
|
+
response = perform_request(path: "#{request_path}/events")
|
18
18
|
events = response["value"]
|
19
19
|
next_link = response["@odata.nextLink"]
|
20
20
|
|
@@ -27,18 +27,67 @@ module OmniEvent
|
|
27
27
|
events
|
28
28
|
end
|
29
29
|
|
30
|
+
def create_event
|
31
|
+
body = create_event_body.to_json
|
32
|
+
|
33
|
+
response = perform_request(
|
34
|
+
method: "POST",
|
35
|
+
path: "#{request_path}/events",
|
36
|
+
content_type: "application/json",
|
37
|
+
body: body
|
38
|
+
)
|
39
|
+
return false unless response
|
40
|
+
|
41
|
+
event = event_hash(response)
|
42
|
+
return false unless event.valid?
|
43
|
+
|
44
|
+
event
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_event
|
48
|
+
event_id = options.event.metadata&.uid
|
49
|
+
raise ArgumentError, "Event id is required." unless event_id
|
50
|
+
|
51
|
+
body = update_event_body
|
52
|
+
raise ArgumentError, "Evend data is required." if body.empty?
|
53
|
+
|
54
|
+
response = perform_request(
|
55
|
+
method: "PATCH",
|
56
|
+
path: "#{request_path}/events/#{options.event.metadata.uid}",
|
57
|
+
content_type: "application/json",
|
58
|
+
body: body.to_json
|
59
|
+
)
|
60
|
+
return false unless response
|
61
|
+
|
62
|
+
event_hash(response)
|
63
|
+
end
|
64
|
+
|
65
|
+
def destroy_event
|
66
|
+
event_id = options.event.metadata&.uid
|
67
|
+
raise ArgumentError, "Event id is required." unless event_id
|
68
|
+
|
69
|
+
response = perform_request(
|
70
|
+
method: "DELETE",
|
71
|
+
path: "#{request_path}/events/#{options.event.metadata.uid}"
|
72
|
+
)
|
73
|
+
!!response
|
74
|
+
end
|
75
|
+
|
30
76
|
def event_hash(raw_event)
|
31
77
|
data = {
|
32
|
-
start_time:
|
33
|
-
end_time: format_time(raw_event["end"]["dateTime"]),
|
78
|
+
start_time: format_outlook_datetime_for_omnievent(raw_event["start"]["dateTime"]),
|
34
79
|
name: raw_event["subject"],
|
35
80
|
description: raw_event["bodyPreview"],
|
36
81
|
url: raw_event["webLink"]
|
37
82
|
}
|
38
83
|
|
84
|
+
data[:end_time] = format_outlook_datetime_for_omnievent(raw_event["end"]["dateTime"]) if raw_event["end"]
|
85
|
+
|
39
86
|
metadata = {
|
40
87
|
uid: raw_event["id"],
|
41
88
|
status: convert_status(raw_event),
|
89
|
+
# created and modified datetime are already in ISO format
|
90
|
+
# https://learn.microsoft.com/en-us/graph/api/resources/event?view=graph-rest-1.0#properties
|
42
91
|
created_at: format_time(raw_event["createdDateTime"]),
|
43
92
|
updated_at: format_time(raw_event["lastModifiedDateTime"])
|
44
93
|
}
|
@@ -52,6 +101,28 @@ module OmniEvent
|
|
52
101
|
)
|
53
102
|
end
|
54
103
|
|
104
|
+
def create_event_body
|
105
|
+
{
|
106
|
+
"subject": options.event.data.name,
|
107
|
+
"body": format_omnievent_description_for_outlook(options.event.data.description),
|
108
|
+
"start": format_omnievent_datetime_for_outlook(options.event.data.start_time),
|
109
|
+
"end": format_omnievent_datetime_for_outlook(options.event.data.end_time)
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
def update_event_body
|
114
|
+
body = {}
|
115
|
+
body["subject"] = options.event.data.name if options.event.data.name
|
116
|
+
if options.event.data.description
|
117
|
+
body["body"] = format_omnievent_description_for_outlook(options.event.data.description)
|
118
|
+
end
|
119
|
+
if options.event.data.start_time
|
120
|
+
body["start"] = format_omnievent_datetime_for_outlook(options.event.data.start_time)
|
121
|
+
end
|
122
|
+
body["end"] = format_omnievent_datetime_for_outlook(options.event.data.end_time) if options.event.data.end_time
|
123
|
+
body
|
124
|
+
end
|
125
|
+
|
55
126
|
def request_url
|
56
127
|
"https://graph.microsoft.com"
|
57
128
|
end
|
@@ -59,16 +130,12 @@ module OmniEvent
|
|
59
130
|
def request_path
|
60
131
|
@request_path ||= begin
|
61
132
|
path = "/#{API_VERSION}"
|
62
|
-
|
63
|
-
# endpoint
|
64
133
|
path += "/users/#{options.user_id}"
|
65
|
-
|
66
134
|
path += if options.calendar_id
|
67
|
-
"/calendars/#{options.calendar_id}
|
135
|
+
"/calendars/#{options.calendar_id}"
|
68
136
|
else
|
69
|
-
"/calendar
|
137
|
+
"/calendar"
|
70
138
|
end
|
71
|
-
|
72
139
|
path
|
73
140
|
end
|
74
141
|
end
|
@@ -83,6 +150,30 @@ module OmniEvent
|
|
83
150
|
|
84
151
|
"published"
|
85
152
|
end
|
153
|
+
|
154
|
+
# All start and end times are returned in UTC unless request headers are set.
|
155
|
+
# See https://learn.microsoft.com/en-us/graph/api/calendar-list-events?view=graph-rest-1.0&tabs=http#request-headers
|
156
|
+
def format_outlook_datetime_for_omnievent(datetime)
|
157
|
+
# DateTime parses to UTC by default
|
158
|
+
utc_datetime = DateTime.parse(datetime)
|
159
|
+
format_time(utc_datetime.to_s)
|
160
|
+
end
|
161
|
+
|
162
|
+
# See https://learn.microsoft.com/en-us/graph/api/resources/datetimetimezone?view=graph-rest-1.0
|
163
|
+
def format_omnievent_datetime_for_outlook(datetime)
|
164
|
+
{
|
165
|
+
"dateTime": DateTime.parse(datetime),
|
166
|
+
"timeZone": "UTC"
|
167
|
+
}
|
168
|
+
end
|
169
|
+
|
170
|
+
# https://learn.microsoft.com/en-us/graph/api/resources/itembody?view=graph-rest-1.0
|
171
|
+
def format_omnievent_description_for_outlook(description)
|
172
|
+
{
|
173
|
+
"contentType": "HTML",
|
174
|
+
"content": description
|
175
|
+
}
|
176
|
+
end
|
86
177
|
end
|
87
178
|
end
|
88
179
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omnievent-outlook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Angus McLeod
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omnievent
|