omnievent-outlook 0.1.0.pre3 → 0.1.0.pre5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06b741b2ee92037e24559210747854d0ff17e9edc1417cbf99cf37f3c2f73e05
4
- data.tar.gz: 51d4d7b559e69f95a75936bb1d6bb011b57d4af38095cb20977114f9add65ad2
3
+ metadata.gz: d854e155be65942ba10f083f8ce99c2b445ce2633dfb3bb86e929b3d11212855
4
+ data.tar.gz: 21d135106721c9afb1cb3eeef7330e246d644211d6c3fef46a3aa265fad5dd85
5
5
  SHA512:
6
- metadata.gz: 57dfb4066765f11cca472188d5c4ac149f72e016c91aa8f05bedf3ebe808ec9a34af8bdbc0bf5f5525d09806a5104f56f4765c3002355d6bf798443be5a0c265
7
- data.tar.gz: abe1e80a5170f3b24a7083b0cdf4092973cef68f28e3fd570bba7e832e9755b4187189d2f13c2e0855fe3c58992a04e6cd9eefd4df77fad0720fb35d0156effc
6
+ metadata.gz: 258d8096e13f0b452257ff51d6ff67e3a8416f55d2e584cdfa52d93879c3dff3adc112e6c25bf62af227674a9a5f3fe8061add0a67512e848a8f3ab05bf75ae7
7
+ data.tar.gz: 9ba47485eb53d99f8e2a603632e87f6884111ea4c517d7fa6bd5e462c7970eb03f7d04f8908379b1533f7d8e3fcf7a7dcbc286f600012e100b88460204bb24b4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omnievent-outlook (0.1.0.pre2)
4
+ omnievent-outlook (0.1.0.pre4)
5
5
  omnievent
6
6
  omnievent-api
7
7
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniEvent
4
4
  module Outlook
5
- VERSION = "0.1.0.pre3"
5
+ VERSION = "0.1.0.pre5"
6
6
  end
7
7
  end
@@ -28,15 +28,19 @@ module OmniEvent
28
28
  end
29
29
 
30
30
  def create_event
31
- body = create_event_body.to_json
31
+ %w[subject start].each do |attr|
32
+ raise ArgumentError, "Event #{attr} is required." unless request_body[attr]
33
+ end
32
34
 
33
35
  response = perform_request(
34
36
  method: "POST",
35
37
  path: "#{request_path}/events",
36
- content_type: "application/json",
37
- body: body
38
+ headers: {
39
+ "Content-Type": "application/json"
40
+ },
41
+ body: request_body.to_json
38
42
  )
39
- return false unless response
43
+ return false if !response || response["error"]
40
44
 
41
45
  event = event_hash(response)
42
46
  return false unless event.valid?
@@ -47,17 +51,17 @@ module OmniEvent
47
51
  def update_event
48
52
  event_id = options.event.metadata&.uid
49
53
  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?
54
+ raise ArgumentError, "Event body is required." if request_body.empty?
53
55
 
54
56
  response = perform_request(
55
57
  method: "PATCH",
56
58
  path: "#{request_path}/events/#{options.event.metadata.uid}",
57
- content_type: "application/json",
58
- body: body.to_json
59
+ headers: {
60
+ "Content-Type": "application/json"
61
+ },
62
+ body: request_body.to_json
59
63
  )
60
- return false unless response
64
+ return false if !response || response["error"]
61
65
 
62
66
  event_hash(response)
63
67
  end
@@ -70,7 +74,7 @@ module OmniEvent
70
74
  method: "DELETE",
71
75
  path: "#{request_path}/events/#{options.event.metadata.uid}"
72
76
  )
73
- !!response
77
+ response && !response["error"]
74
78
  end
75
79
 
76
80
  def event_hash(raw_event)
@@ -101,26 +105,21 @@ module OmniEvent
101
105
  )
102
106
  end
103
107
 
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)
108
+ def request_body
109
+ @request_body ||= begin
110
+ body = {}
111
+ body["subject"] = options.event.data.name if options.event.data.name
112
+ if options.event.data.description
113
+ body["body"] = format_omnievent_description_for_outlook(options.event.data.description)
114
+ end
115
+ if options.event.data.start_time
116
+ body["start"] = format_omnievent_datetime_for_outlook(options.event.data.start_time)
117
+ end
118
+ if options.event.data.end_time
119
+ body["end"] = format_omnievent_datetime_for_outlook(options.event.data.end_time)
120
+ end
121
+ body
121
122
  end
122
- body["end"] = format_omnievent_datetime_for_outlook(options.event.data.end_time) if options.event.data.end_time
123
- body
124
123
  end
125
124
 
126
125
  def request_url
@@ -162,7 +161,7 @@ module OmniEvent
162
161
  # See https://learn.microsoft.com/en-us/graph/api/resources/datetimetimezone?view=graph-rest-1.0
163
162
  def format_omnievent_datetime_for_outlook(datetime)
164
163
  {
165
- "dateTime": DateTime.parse(datetime),
164
+ "dateTime": Time.parse(datetime).utc.iso8601,
166
165
  "timeZone": "UTC"
167
166
  }
168
167
  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.pre3
4
+ version: 0.1.0.pre5
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-09-03 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omnievent