mobiscroll-connect 1.6.0 → 1.6.1

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: bfda16db0b33649065d21a3df62ae7f3b6962adaa0e57fd11944b5e0edce780f
4
- data.tar.gz: 476dd4536d5bae00d3e169d26c30bb98ac3ab24aa82fe4b4b65a47b55cb57bea
3
+ metadata.gz: ef1573ac2afaa4ddba1a958938b7811cf392ce7186ead74fa12c2639ed1c1f20
4
+ data.tar.gz: 0fe20784ecce947f01f403ee21c59faece8030089bfa0b456f316502babaa3bb
5
5
  SHA512:
6
- metadata.gz: 6ffcf4cddf3cfafe432cb53bff0ebda0b0f8af4fc9d113e18fd5540cddc3328fe32d40d47b5ce8922cb32e4e758198e24a804c939e4676aa842991ebe98334e5
7
- data.tar.gz: 35f100a37e7fdc727c8bf824726c907100286d41b4738e7aa78fe2d4f9e9fe05bdcdeef296f3898ecbe14193842957132e1bc2ccddcb8ab86448015ff49a9232
6
+ metadata.gz: 8709962bfbeea45cb19bdbb156296caf2904f9fb5d9440707b3fd00447df26b7b331ba15e0b722c38c4fe5106d6e06448d1cab6ced1be3523368694d4b4d7915
7
+ data.tar.gz: 5b8c9d1e44203df175ea3b61e05d625163ac4538eda4e68d0d0923824cfac94f368354c379fdfeeb1b93a34097741f0efafb99703747cd91b3bd7727455b6bc1
data/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to the Mobiscroll Connect Ruby SDK (RubyGems: `mobiscroll-co
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this SDK's major.minor always matches the Connect API's (for example API 1.5.x → SDK 1.5.x): each release bumps only the patch, including releases with breaking changes. Patch numbers are independent per SDK, so this file covers the Ruby SDK only.
6
6
 
7
+ ## [1.6.1] — 2026-11-11
8
+
9
+ ### Fixed
10
+
11
+ - We added the missing `auth.revoke(token = nil)` for `POST /api/oauth/revoke`: it revokes the user's Connect access and refresh tokens.
12
+ - We fixed `generate_auth_url` not accepting `theme:`. It now accepts `'light'`, `'dark'` or `'auto'`, which sets the color scheme of the Connect pages.
13
+ - We added the missing `account` (the connected account the calendar belongs to) and `read_only` (`true` when the connection cannot write to it) to `Calendar` objects.
14
+ - We fixed `events.create` and `events.update` leaving out `status` and `conference_data:`. They now send `status`, and `conference_data:` as `conferenceData` (for example `{ 'autoGenerate' => true }`).
15
+ - We fixed `events.create` and `events.update` silently leaving out `conferenceData:`, `allDay:`, `recurringEventId:` and `updateMode:`, the API's spelling of `conference_data:`, `all_day:`, `recurring_event_id:` and `update_mode:`. They now accept both spellings.
16
+ - `events.create` and `events.update` now send `attendees` as email strings, as the API expects; an `Attendee` or a Hash is reduced to its email.
17
+ - `events.create` and `events.update` no longer send `color`, which the API does not accept on writes.
18
+
7
19
  ## [1.6.0] — 2026-10-08
8
20
 
9
21
  ### Added
data/README.md CHANGED
@@ -40,6 +40,7 @@ client = Mobiscroll::Connect::Client.new(
40
40
  url = client.auth.generate_auth_url(
41
41
  user_id: 'user-123',
42
42
  lng: 'es', # optional: Connect page language, see https://mobiscroll.com/docs/connect/localization#supported-languages
43
+ theme: 'dark', # optional: Connect page color scheme, 'light' | 'dark' | 'auto'
43
44
  providers: [
44
45
  Mobiscroll::Connect::Provider::GOOGLE,
45
46
  Mobiscroll::Connect::Provider::MICROSOFT
@@ -84,10 +85,24 @@ end
84
85
 
85
86
  ### 5. Disconnect a provider
86
87
 
88
+ Disconnect one account (its `id` from `get_connection_status`), or every account of a provider. This stops the account's webhook subscriptions and deletes its provider credentials; it does not revoke the user's Connect tokens.
89
+
90
+ ```ruby
91
+ client.auth.disconnect(provider: Mobiscroll::Connect::Provider::GOOGLE, account: 'user@gmail.com')
92
+ client.auth.disconnect(provider: Mobiscroll::Connect::Provider::MICROSOFT)
93
+ ```
94
+
95
+ ### 6. Revoke tokens
96
+
97
+ `revoke` revokes the whole grant: every Connect access and refresh token of the user. It does not disconnect calendar accounts or stop webhooks, so to remove a user entirely, disconnect each provider first (that needs a valid access token), then revoke.
98
+
87
99
  ```ruby
88
- client.auth.disconnect(provider: Mobiscroll::Connect::Provider::GOOGLE)
100
+ client.auth.revoke # stored refresh token, else access token; clears the stored credentials
101
+ client.auth.revoke(stored_refresh_token) # a token you pass; stored credentials are kept
89
102
  ```
90
103
 
104
+ It returns a `RevokeResponse` with `success: true` for any token, including an unknown or already revoked one. With no argument and no stored credentials it raises `ValidationError` without making a request.
105
+
91
106
  ## Token refresh
92
107
 
93
108
  The SDK automatically refreshes expired access tokens. When a request returns 401 and a `refresh_token` is available, the SDK:
@@ -180,10 +195,12 @@ client.events.delete(
180
195
 
181
196
  ### Subscribe to calendar change notifications
182
197
 
198
+ Pass the calendar's real ID from `calendars.list`; an alias such as `primary` creates a duplicate subscription. A `channel_id` you supply that another user already holds is rejected with `Mobiscroll::Connect::Error` (HTTP 409).
199
+
183
200
  ```ruby
184
201
  result = client.webhooks.subscribe_webhook(
185
202
  provider: Mobiscroll::Connect::Provider::GOOGLE,
186
- calendar_id: 'primary'
203
+ calendar_id: 'work@company.com'
187
204
  )
188
205
  puts result.channel_id
189
206
  puts result.server_webhook_url
@@ -191,6 +208,8 @@ puts result.server_webhook_url
191
208
 
192
209
  ### Unsubscribe
193
210
 
211
+ Connect replaces the channel ID when it renews a subscription, so use the current one from the latest delivery's `metadata.channel_id`.
212
+
194
213
  ```ruby
195
214
  client.webhooks.unsubscribe_webhook(
196
215
  provider: 'google',
@@ -216,6 +235,8 @@ post '/webhooks/mobiscroll' do
216
235
  end
217
236
  ```
218
237
 
238
+ Each event's `conference` is exactly what the delivery carried, not the join-URL string `events.list` returns: a Hash with the keys `url`, `provider`, `meetingProvider` and `data` (as sent, camelCase), or nil when absent. `conference_data` is the delivery's `conferenceData` (Connect 1.6.1 and later), the same object `events.list` returns, passed through unchanged.
239
+
219
240
  `headers` can be a Hash with any key casing, a Rack env (`HTTP_WEBHOOK_ID` keys), or Rails' `request.headers` (pass `request.raw_post` as the body in Rails).
220
241
 
221
242
  The public keys are fetched from `https://connect.mobiscroll.com/.well-known/webhook-keys` on the first delivery and cached for the whole process as the endpoint's `Cache-Control` allows. If no signature matches, the keys are fetched again (at most once a minute) before the delivery is rejected, so key rotations need no action on your side.
@@ -40,6 +40,10 @@ module Mobiscroll
40
40
  @monitor.synchronize { @credentials }
41
41
  end
42
42
 
43
+ def clear_credentials
44
+ @monitor.synchronize { @credentials = nil }
45
+ end
46
+
43
47
  def on_tokens_refreshed(&block)
44
48
  @on_tokens_refreshed = block
45
49
  end
@@ -48,8 +52,9 @@ module Mobiscroll
48
52
  execute(:get, path, query: query, body: nil, headers: headers)
49
53
  end
50
54
 
51
- def post(path, body: nil, query: nil, headers: nil)
52
- execute(:post, path, query: query, body: body, headers: headers)
55
+ # `skip_refresh: true` surfaces a 401 as-is instead of refreshing and retrying.
56
+ def post(path, body: nil, query: nil, headers: nil, skip_refresh: false)
57
+ execute(:post, path, query: query, body: body, headers: headers, retried: skip_refresh)
53
58
  end
54
59
 
55
60
  def put(path, body: nil, query: nil, headers: nil)
@@ -78,7 +78,9 @@ module Mobiscroll
78
78
  end
79
79
  end
80
80
 
81
- # Raised when a webhook delivery fails verification. Respond with a 4xx and do not process it.
81
+ # Raised when a webhook delivery fails verification. Do not process it. Respond with 503
82
+ # when +reason+ is 'no_public_keys' (the keys could not be fetched, so Connect retries) and
83
+ # with 401 otherwise.
82
84
  #
83
85
  # +reason+ is one of 'missing_headers', 'invalid_timestamp', 'timestamp_out_of_tolerance',
84
86
  # 'no_public_keys', 'no_matching_signature' or 'invalid_payload'.
@@ -104,8 +104,18 @@ module Mobiscroll
104
104
  end
105
105
  end
106
106
 
107
- # A calendar exposed by one of the supported providers.
108
- Calendar = Struct.new(:provider, :id, :title, :time_zone, :color, :description, :original, keyword_init: true) do
107
+ RevokeResponse = Struct.new(:success, keyword_init: true) do
108
+ def self.from_h(hash)
109
+ return nil if hash.nil?
110
+
111
+ new(success: hash['success'] || hash[:success])
112
+ end
113
+ end
114
+
115
+ # A calendar exposed by one of the supported providers. `account` is the connected account
116
+ # it belongs to; `read_only` is true when the authenticated connection cannot write to it.
117
+ Calendar = Struct.new(:provider, :id, :title, :time_zone, :color, :description, :original,
118
+ :account, :read_only, keyword_init: true) do
109
119
  def self.from_h(hash)
110
120
  return nil if hash.nil?
111
121
 
@@ -116,7 +126,9 @@ module Mobiscroll
116
126
  time_zone: hash['timeZone'] || hash[:timeZone] || hash['time_zone'],
117
127
  color: hash['color'] || hash[:color],
118
128
  description: hash['description'] || hash[:description],
119
- original: hash['original'] || hash[:original]
129
+ original: hash['original'] || hash[:original],
130
+ account: hash['account'] || hash[:account],
131
+ read_only: (hash.key?('readOnly') ? hash['readOnly'] : hash[:readOnly]) == true
120
132
  )
121
133
  end
122
134
  end
@@ -243,7 +255,10 @@ module Mobiscroll
243
255
  end
244
256
 
245
257
  # A changed event in a webhook delivery: every CalendarEvent field plus `change_type`
246
- # ('created', 'updated' or 'deleted').
258
+ # ('created', 'updated' or 'deleted'). `conference` is the raw Hash as delivered (Events#list
259
+ # returns a join-URL String instead). Deleted placeholders lack `original` (and, in deliveries
260
+ # sent before Connect 1.6.1, `calendar_id`); rely only on `id`, `provider`, `calendar_id`,
261
+ # `change_type`.
247
262
  WebhookEvent = Struct.new(*CalendarEvent.members, :change_type, keyword_init: true) do
248
263
  def self.from_h(hash)
249
264
  return nil if hash.nil?
@@ -11,7 +11,10 @@ module Mobiscroll
11
11
  @api_client = api_client
12
12
  end
13
13
 
14
- def generate_auth_url(user_id:, scope: nil, state: nil, providers: nil, lng: nil)
14
+ # Builds the consent URL to redirect the user to. `lng` is the Connect page language
15
+ # (e.g. 'es'); `theme` is the Connect page color scheme: 'light', 'dark' or 'auto'
16
+ # (follows the device setting), the project's default theme when nil.
17
+ def generate_auth_url(user_id:, scope: nil, state: nil, providers: nil, lng: nil, theme: nil)
15
18
  params = {
16
19
  'response_type' => 'code',
17
20
  'client_id' => @config.client_id,
@@ -21,6 +24,7 @@ module Mobiscroll
21
24
  params['scope'] = scope if scope
22
25
  params['state'] = state if state
23
26
  params['lng'] = lng if lng
27
+ params['theme'] = theme if theme
24
28
 
25
29
  query = URI.encode_www_form(params)
26
30
 
@@ -57,6 +61,21 @@ module Mobiscroll
57
61
  ConnectionStatus.from_h(parsed)
58
62
  end
59
63
 
64
+ # Disconnects a calendar provider account.
65
+ #
66
+ # Removes the account (or, without +account+, every account of the provider)
67
+ # from the user: stops its webhook subscriptions and deletes the stored
68
+ # provider credentials. It does not revoke the user's Connect access or
69
+ # refresh tokens (see #revoke), nor the grant at Google or Microsoft.
70
+ #
71
+ # @param provider [String] a Provider constant
72
+ # @param account [String, nil] the +id+ of an account from #get_connection_status
73
+ # (<tt>connections[provider][].id</tt>)
74
+ # @return [DisconnectResponse]
75
+ #
76
+ # @example
77
+ # client.auth.disconnect(provider: Mobiscroll::Connect::Provider::GOOGLE, account: 'user@gmail.com')
78
+ # client.auth.disconnect(provider: Mobiscroll::Connect::Provider::MICROSOFT)
60
79
  def disconnect(provider:, account: nil)
61
80
  query = { 'provider' => provider }
62
81
  query['account'] = account if account
@@ -68,6 +87,38 @@ module Mobiscroll
68
87
  end
69
88
  DisconnectResponse.from_h(parsed)
70
89
  end
90
+
91
+ # Revokes the user's Connect access and refresh tokens.
92
+ #
93
+ # Revokes the whole grant: every access and refresh token issued for this
94
+ # user. It does not disconnect calendar accounts or stop webhook
95
+ # subscriptions. To remove a user entirely, call #disconnect for each
96
+ # provider first (it needs a valid access token), then #revoke.
97
+ #
98
+ # @param token [String, nil] access or refresh token to revoke. Defaults to
99
+ # the stored refresh token, else the stored access token; the stored
100
+ # credentials are then cleared.
101
+ # @return [RevokeResponse] success is true, also for an unknown or already
102
+ # revoked token
103
+ # @raise [ValidationError] when no token is given and none is stored
104
+ #
105
+ # @example
106
+ # client.auth.disconnect(provider: Mobiscroll::Connect::Provider::GOOGLE)
107
+ # client.auth.revoke
108
+ #
109
+ # # Or revoke a token you stored yourself
110
+ # client.auth.revoke(stored_refresh_token)
111
+ def revoke(token = nil)
112
+ stored = @api_client.credentials
113
+ revoke_token = token || [stored&.refresh_token, stored&.access_token].find { |t| t && !t.empty? }
114
+ if revoke_token.nil? || revoke_token.empty?
115
+ raise ValidationError, 'No token to revoke: pass one or set credentials first'
116
+ end
117
+
118
+ parsed = @api_client.post('/oauth/revoke', body: { 'token' => revoke_token }, skip_refresh: true)
119
+ @api_client.clear_credentials if token.nil?
120
+ RevokeResponse.from_h(parsed)
121
+ end
71
122
  end
72
123
  end
73
124
  end
@@ -10,6 +10,12 @@ module Mobiscroll
10
10
  @api_client = api_client
11
11
  end
12
12
 
13
+ # The wire (camelCase) spelling of an optional field is accepted too, as the Python SDK does.
14
+ WIRE_KEYS = {
15
+ allDay: :all_day, recurringEventId: :recurring_event_id, updateMode: :update_mode,
16
+ conferenceData: :conference_data
17
+ }.freeze
18
+
13
19
  def list(start: nil, end: nil, calendar_ids: nil, page_size: nil,
14
20
  next_page_token: nil, single_events: nil)
15
21
  end_time = binding.local_variable_get(:end)
@@ -68,6 +74,7 @@ module Mobiscroll
68
74
  private
69
75
 
70
76
  def build_event_body(params)
77
+ params = params.to_h { |key, value| [WIRE_KEYS.fetch(key.to_sym, key.to_sym), value] }
71
78
  body = {}
72
79
  body['provider'] = params[:provider] if params.key?(:provider)
73
80
  body['calendarId'] = params[:calendar_id] if params.key?(:calendar_id)
@@ -77,26 +84,34 @@ module Mobiscroll
77
84
  body['end'] = params[:end] if params.key?(:end)
78
85
  body['allDay'] = params[:all_day] if params.key?(:all_day)
79
86
  body['description'] = params[:description] if params.key?(:description)
80
- body['color'] = params[:color] if params.key?(:color)
81
87
  body['location'] = params[:location] if params.key?(:location)
82
88
  body['recurringEventId'] = params[:recurring_event_id] if params.key?(:recurring_event_id)
83
89
  body['updateMode'] = params[:update_mode] if params.key?(:update_mode)
84
90
  body['availability'] = params[:availability] if params.key?(:availability)
85
91
  body['privacy'] = params[:privacy] if params.key?(:privacy)
92
+ body['status'] = params[:status] if params.key?(:status)
86
93
 
87
94
  if params.key?(:recurrence)
88
95
  body['recurrence'] =
89
96
  params[:recurrence].is_a?(RecurrenceRule) ? params[:recurrence].to_wire : params[:recurrence]
90
97
  end
91
98
 
92
- if params.key?(:attendees)
93
- body['attendees'] = params[:attendees].map { |a| a.is_a?(Attendee) ? a.to_h : a }
94
- end
99
+ body['attendees'] = Array(params[:attendees]).map { |a| attendee_email(a) } if params.key?(:attendees)
95
100
 
96
101
  body['conference'] = params[:conference] if params.key?(:conference)
102
+ body['conferenceData'] = params[:conference_data] if params.key?(:conference_data)
97
103
  body['custom'] = params[:custom] if params.key?(:custom)
98
104
  body
99
105
  end
106
+
107
+ # The API takes attendees as email strings; an Attendee or a Hash is reduced to its email.
108
+ def attendee_email(attendee)
109
+ case attendee
110
+ when Attendee then attendee.email
111
+ when Hash then attendee['email'] || attendee[:email]
112
+ else attendee
113
+ end
114
+ end
100
115
  end
101
116
  end
102
117
  end
@@ -16,8 +16,11 @@ module Mobiscroll
16
16
 
17
17
  # Subscribes to push notifications for changes on a calendar.
18
18
  #
19
- # `channel_id` is auto-generated server-side when omitted. `expiration` is a
20
- # provider-specific timestamp (ms epoch) the caller can suggest.
19
+ # Pass the calendar's real ID from Calendars#list as `calendar_id`; an alias such as
20
+ # 'primary' creates a duplicate subscription. `channel_id` is auto-generated
21
+ # server-side when omitted; one that another user already holds is rejected with
22
+ # Mobiscroll::Connect::Error (HTTP 409). `expiration` is a provider-specific timestamp
23
+ # (ms epoch) the caller can suggest.
21
24
  def subscribe_webhook(provider:, calendar_id:, channel_id: nil, expiration: nil)
22
25
  body = { 'provider' => provider, 'calendarId' => calendar_id }
23
26
  body['channelId'] = channel_id if channel_id
@@ -33,6 +36,9 @@ module Mobiscroll
33
36
  # The backend treats a 200 response as final even when the provider-side
34
37
  # unsubscribe itself failed (e.g. an already-expired subscription) — the local
35
38
  # mapping is removed either way, and `message` explains what happened.
39
+ #
40
+ # Use the current channel ID: Connect replaces it when it renews a subscription, so
41
+ # take it from the latest delivery's `metadata.channel_id`.
36
42
  def unsubscribe_webhook(provider:, channel_id:, resource_id: nil)
37
43
  body = { 'provider' => provider, 'channelId' => channel_id }
38
44
  body['resourceId'] = resource_id if resource_id
@@ -53,14 +59,15 @@ module Mobiscroll
53
59
  # `headers` is a Hash (any key casing) or a Rack env / Rails `request.headers`.
54
60
  #
55
61
  # Returns a WebhookDelivery. Raises WebhookVerificationError when the delivery is not
56
- # genuine; respond with a 4xx.
62
+ # verified: respond with 503 when its `reason` is 'no_public_keys' (Connect retries)
63
+ # and with 401 otherwise (Connect does not retry).
57
64
  #
58
65
  # post '/webhooks/mobiscroll' do
59
66
  # delivery = client.webhooks.verify_webhook(request.body.read, request.env)
60
67
  # handle_delivery(delivery)
61
68
  # status 204
62
- # rescue Mobiscroll::Connect::WebhookVerificationError
63
- # halt 401
69
+ # rescue Mobiscroll::Connect::WebhookVerificationError => e
70
+ # halt(e.reason == 'no_public_keys' ? 503 : 401)
64
71
  # end
65
72
  def verify_webhook(payload, headers)
66
73
  store = WebhookKeyStore.for_url(URI.join(@config.base_url, WEBHOOK_KEYS_PATH).to_s)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mobiscroll
4
4
  module Connect
5
- VERSION = '1.6.0'
5
+ VERSION = '1.6.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobiscroll-connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mobiscroll
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-08 00:00:00.000000000 Z
11
+ date: 2026-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64