omnievent-outlook 0.1.0.pre2 → 0.1.0.pre3
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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +8 -9
- data/lib/omnievent/outlook/version.rb +1 -1
- data/lib/omnievent/strategies/outlook.rb +94 -13
- 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,7 +1,7 @@
|
|
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
|
|
@@ -24,11 +24,11 @@ GEM
|
|
24
24
|
iso-639 (0.3.6)
|
25
25
|
json (2.7.2)
|
26
26
|
language_server-protocol (3.17.0.3)
|
27
|
-
omnievent (0.1.0.
|
27
|
+
omnievent (0.1.0.pre5)
|
28
28
|
hashie (>= 3.4.6)
|
29
29
|
iso-639 (~> 0.3.5)
|
30
30
|
tzinfo (~> 2.0)
|
31
|
-
omnievent-api (0.1.0.
|
31
|
+
omnievent-api (0.1.0.pre3)
|
32
32
|
excon
|
33
33
|
omnievent
|
34
34
|
parallel (1.26.3)
|
@@ -40,13 +40,13 @@ GEM
|
|
40
40
|
rainbow (3.1.1)
|
41
41
|
rake (13.2.1)
|
42
42
|
regexp_parser (2.9.2)
|
43
|
-
rexml (3.3.
|
43
|
+
rexml (3.3.6)
|
44
44
|
strscan
|
45
45
|
rspec (3.13.0)
|
46
46
|
rspec-core (~> 3.13.0)
|
47
47
|
rspec-expectations (~> 3.13.0)
|
48
48
|
rspec-mocks (~> 3.13.0)
|
49
|
-
rspec-core (3.13.
|
49
|
+
rspec-core (3.13.1)
|
50
50
|
rspec-support (~> 3.13.0)
|
51
51
|
rspec-expectations (3.13.2)
|
52
52
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -55,18 +55,17 @@ GEM
|
|
55
55
|
diff-lcs (>= 1.2.0, < 2.0)
|
56
56
|
rspec-support (~> 3.13.0)
|
57
57
|
rspec-support (3.13.1)
|
58
|
-
rubocop (1.
|
58
|
+
rubocop (1.66.0)
|
59
59
|
json (~> 2.3)
|
60
60
|
language_server-protocol (>= 3.17.0)
|
61
61
|
parallel (~> 1.10)
|
62
62
|
parser (>= 3.3.0.2)
|
63
63
|
rainbow (>= 2.2.2, < 4.0)
|
64
64
|
regexp_parser (>= 2.4, < 3.0)
|
65
|
-
|
66
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
65
|
+
rubocop-ast (>= 1.32.1, < 2.0)
|
67
66
|
ruby-progressbar (~> 1.7)
|
68
67
|
unicode-display_width (>= 2.4.0, < 3.0)
|
69
|
-
rubocop-ast (1.32.
|
68
|
+
rubocop-ast (1.32.2)
|
70
69
|
parser (>= 3.3.1.0)
|
71
70
|
ruby-progressbar (1.13.0)
|
72
71
|
strscan (3.1.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:
|
17
|
+
response = perform_request(path: "#{request_path}/events")
|
18
18
|
events = response["value"]
|
19
19
|
next_link = response["@odata.nextLink"]
|
20
20
|
|
@@ -27,15 +27,62 @@ 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_outlook_datetime(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),
|
@@ -54,23 +101,41 @@ module OmniEvent
|
|
54
101
|
)
|
55
102
|
end
|
56
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
|
+
|
57
126
|
def request_url
|
58
127
|
"https://graph.microsoft.com"
|
59
128
|
end
|
60
129
|
|
61
|
-
def
|
62
|
-
@
|
130
|
+
def request_path
|
131
|
+
@request_path ||= begin
|
63
132
|
path = "/#{API_VERSION}"
|
64
|
-
|
65
|
-
# endpoint
|
66
133
|
path += "/users/#{options.user_id}"
|
67
|
-
|
68
134
|
path += if options.calendar_id
|
69
|
-
"/calendars/#{options.calendar_id}
|
135
|
+
"/calendars/#{options.calendar_id}"
|
70
136
|
else
|
71
|
-
"/calendar
|
137
|
+
"/calendar"
|
72
138
|
end
|
73
|
-
|
74
139
|
path
|
75
140
|
end
|
76
141
|
end
|
@@ -86,13 +151,29 @@ module OmniEvent
|
|
86
151
|
"published"
|
87
152
|
end
|
88
153
|
|
89
|
-
# All start and end times are returned in UTC
|
154
|
+
# All start and end times are returned in UTC unless request headers are set.
|
90
155
|
# See https://learn.microsoft.com/en-us/graph/api/calendar-list-events?view=graph-rest-1.0&tabs=http#request-headers
|
91
|
-
def
|
156
|
+
def format_outlook_datetime_for_omnievent(datetime)
|
92
157
|
# DateTime parses to UTC by default
|
93
158
|
utc_datetime = DateTime.parse(datetime)
|
94
159
|
format_time(utc_datetime.to_s)
|
95
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
|
96
177
|
end
|
97
178
|
end
|
98
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
|