omnievent-google 0.1.0.pre3 → 0.1.0.pre8

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: 17457c1afa0cc309b5145db2aa4671ab5c66805a154ce75337227a93f1518329
4
- data.tar.gz: 2c54e783679fa7738b5e8ed9a7ff88253e83f0a769c203e6d7214939ac9a68e4
3
+ metadata.gz: c27cea477531aef1fc66a13555b4b0edae51a40900ad67f39e589908bf1dd3b9
4
+ data.tar.gz: 4daa816ca5235d338dfd6da7ef9c1b40f9837ee583dfeab589554e441e61b664
5
5
  SHA512:
6
- metadata.gz: 54e9e976df87da13faa174b269cdd62d33a53db1dc0bfe21f2099d2915c87381ea210c8e7444a2836dfa6c85ca1f4b1e3c55ebc7ac384e3e6e462df6326cb29b
7
- data.tar.gz: 72adbcaebd73a3ffe8130222c800410bcfc84e3b38682b9f442307774c7a5bb99fb1f35db568064edabe0317aa965bd9c94c03a3be68314234ab7526ab346935
6
+ metadata.gz: b1345db0b10103218aff0070bd72bf86ca81cc9a4912b023eadec0dc5a9135e20f5e2cea5c8f9ee9ee8d0b17a38523e5e5f0257df4ce8e0eef80d8c07fa09d69
7
+ data.tar.gz: 40138bf32bd1fc2dbc7e65cd6ddb6331f3b3377bd1f15d9a8d519572b3619c1c39b7b7c8d60cddf89cb586292aa3d4775ca9ebc1b0fb74cce5c9273a7070b31c
data/.rubocop.yml CHANGED
@@ -46,3 +46,6 @@ Style/OptionalBooleanParameter:
46
46
 
47
47
  Style/MultilineBlockChain:
48
48
  Enabled: false
49
+
50
+ Style/HashLikeCase:
51
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omnievent-google (0.1.0.pre2)
4
+ omnievent-google (0.1.0.pre8)
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.pre6)
27
+ omnievent (0.1.0.pre7)
28
28
  hashie (>= 3.4.6)
29
29
  iso-639 (~> 0.3.5)
30
30
  tzinfo (~> 2.0)
31
- omnievent-api (0.1.0.pre3)
31
+ omnievent-api (0.1.0.pre4)
32
32
  excon
33
33
  omnievent
34
34
  parallel (1.26.3)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniEvent
4
4
  module Google
5
- VERSION = "0.1.0.pre3"
5
+ VERSION = "0.1.0.pre8"
6
6
  end
7
7
  end
@@ -12,10 +12,18 @@ module OmniEvent
12
12
  option :name, "google"
13
13
 
14
14
  API_VERSION = "v3"
15
+ STATUS_MAP = {
16
+ "needsAction" => "invited",
17
+ "accepted" => "confirmed",
18
+ "declined" => "declined",
19
+ "tentative" => "tentative"
20
+ }.freeze
15
21
 
16
22
  def raw_events
17
- response = perform_request(path: request_path_with_params(list_params))
18
- events = response && response["items"]
23
+ response = perform_request(path: path_with_params(request_path, list_params))
24
+ return [] unless response.is_a?(Hash) && response["items"]
25
+
26
+ events = response["items"]
19
27
 
20
28
  next_link = build_next_link(response, list_params)
21
29
  while next_link
@@ -30,7 +38,7 @@ module OmniEvent
30
38
  def build_next_link(response, params)
31
39
  return nil unless response && response["nextPageToken"]
32
40
 
33
- request_path_with_params(params.merge(pageToken: response["nextPageToken"]))
41
+ path_with_params(request_path, params.merge(pageToken: response["nextPageToken"]))
34
42
  end
35
43
 
36
44
  def create_event
@@ -101,10 +109,16 @@ module OmniEvent
101
109
  updated_at: format_time(raw_event["updated"])
102
110
  }
103
111
 
112
+ associated_data = {
113
+ registrations: get_registrations(raw_event),
114
+ virtual_location: get_virtual_location(raw_event)
115
+ }
116
+
104
117
  OmniEvent::EventHash.new(
105
118
  provider: name,
106
119
  data: data,
107
- metadata: metadata
120
+ metadata: metadata,
121
+ associated_data: associated_data
108
122
  )
109
123
  end
110
124
 
@@ -117,17 +131,13 @@ module OmniEvent
117
131
  body["start"] = format_omnievent_datetime_for_google(options.event.data.start_time)
118
132
  end
119
133
  body["end"] = format_omnievent_datetime_for_google(options.event.data.end_time) if options.event.data.end_time
134
+ if options.event.associated_data&.registrations
135
+ body["attendees"] = convert_registrations_to_attendees(options.event.associated_data.registrations)
136
+ end
120
137
  body
121
138
  end
122
139
  end
123
140
 
124
- def request_path_with_params(params = {})
125
- uri = URI.parse(request_path)
126
- params.reject! { |_k, v| v.to_s.strip.empty? }
127
- uri.query = URI.encode_www_form(params) unless params.empty?
128
- uri.to_s
129
- end
130
-
131
141
  def request_url
132
142
  "https://www.googleapis.com"
133
143
  end
@@ -167,9 +177,57 @@ module OmniEvent
167
177
  params = {}
168
178
  params[:timeMin] = options.from_time if options.from_time
169
179
  params[:timeMax] = options.to_time if options.to_time
180
+ params[:q] = options.match_name if options.match_name
170
181
  params
171
182
  end
172
183
  end
184
+
185
+ def convert_registrations_to_attendees(registrations)
186
+ return nil unless registrations
187
+
188
+ registrations.map do |registration|
189
+ result = {}
190
+ result[:id] = registration[:uid] if registration[:uid]
191
+ result[:displayName] = registration[:name] if registration[:name]
192
+ result[:email] = registration[:email] if registration[:email]
193
+ result[:responseStatus] = STATUS_MAP.key(registration[:status].to_s) if registration[:status]
194
+ result
195
+ end
196
+ end
197
+
198
+ def get_registrations(raw_event)
199
+ return [] unless raw_event && raw_event["attendees"]
200
+
201
+ raw_event["attendees"].map do |attendee|
202
+ {
203
+ uid: attendee["id"],
204
+ name: attendee["displayName"],
205
+ email: attendee["email"],
206
+ status: STATUS_MAP[attendee["responseStatus"].to_s]
207
+ }
208
+ end
209
+ end
210
+
211
+ def get_virtual_location(raw_event)
212
+ video_url = if raw_event["hangoutLink"]
213
+ raw_event["hangoutLink"]
214
+ elsif OmniEvent::Utils.valid_url?(raw_event["location"])
215
+ raw_event["location"]
216
+ end
217
+
218
+ return unless video_url
219
+
220
+ {
221
+ entry_points: [
222
+ {
223
+ type: "video",
224
+ uri: video_url,
225
+ label: "",
226
+ code: ""
227
+ }
228
+ ]
229
+ }
230
+ end
173
231
  end
174
232
  end
175
233
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnievent-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre3
4
+ version: 0.1.0.pre8
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-14 00:00:00.000000000 Z
11
+ date: 2024-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omnievent