vortex-ruby-sdk 1.3.0 → 1.6.0

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: ef46095579ff2ce432423b52947fe7b09bcbac70a9aeaaa72c28245f79aee801
4
- data.tar.gz: b71a185023f2593be2fd5adfa28771eb281de595b8539b023a60448119b29a7b
3
+ metadata.gz: c4007275edb1f0eeffa2386fa04e11236f7a12402ad3169c729f4d5bd73faa6b
4
+ data.tar.gz: 0ce765593b51887883c4de24671481fcca207285e4314625914b485f199d65b5
5
5
  SHA512:
6
- metadata.gz: f9fee1a62aa03ee7184bf596b13644f48bb3df7a6164eec8bae3be10ebe9f66e21c848410831a09ff99136d01a023aa7bebdbbe9cdf95c7333d7a55a94bd58ed
7
- data.tar.gz: 315cdc79b63d0f79563d25e9568df67043245cd8c3d230ef79e322b02c39c7559eb3f5613f0c575b946b01f651397052e1ca8aa76ec51683bec5988a7b2445d2
6
+ metadata.gz: c537cdd1f516a455cd01e648d5f6e62fc7ece380d604480d4b618b0168186fbd01f441b4bf6072c48bf8ad367a5a45bdf287b81d6f337c2e0cbeddcf7fb2667c
7
+ data.tar.gz: fa0e660c5faf465511c1fa5fb43fdd6ee8648d35ed95e96c48e2efb79d79586186be4dc39c90a8c9397dcfbd86581565cca8cfccc794cf3ed52e490793f30ac4
data/README.md CHANGED
@@ -47,7 +47,9 @@ client = Vortex::Client.new(ENV['VORTEX_API_KEY'])
47
47
  user = {
48
48
  id: 'user-123',
49
49
  email: 'user@example.com',
50
- admin_scopes: ['autojoin'] # Optional - included as adminScopes array in JWT
50
+ user_name: 'Jane Doe', # Optional: user's display name
51
+ user_avatar_url: 'https://example.com/avatars/jane.jpg', # Optional: user's avatar URL
52
+ admin_scopes: ['autojoin'] # Optional: grants autojoin admin privileges
51
53
  }
52
54
 
53
55
  # Generate JWT
@@ -63,22 +65,6 @@ client.accept_invitations(['inv1', 'inv2'], { type: 'email', value: 'user@exampl
63
65
  group_invitations = client.get_invitations_by_group('team', 'team1')
64
66
  ```
65
67
 
66
- ### Generate JWT with Additional Properties
67
-
68
- ```ruby
69
- user = {
70
- id: 'user-123',
71
- email: 'user@example.com'
72
- }
73
-
74
- extra = {
75
- role: 'admin',
76
- department: 'Engineering'
77
- }
78
-
79
- jwt = client.generate_jwt(user: user, extra: extra)
80
- ```
81
-
82
68
  ## Rails Integration
83
69
 
84
70
  Create a controller with Vortex routes:
data/lib/vortex/client.rb CHANGED
@@ -81,13 +81,13 @@ module Vortex
81
81
  }
82
82
 
83
83
  # Add name if present (convert snake_case to camelCase for JWT)
84
- if user[:name]
85
- payload[:name] = user[:name]
84
+ if user[:user_name]
85
+ payload[:userName] = user[:user_name]
86
86
  end
87
87
 
88
- # Add avatarUrl if present (convert snake_case to camelCase for JWT)
89
- if user[:avatar_url]
90
- payload[:avatarUrl] = user[:avatar_url]
88
+ # Add userAvatarUrl if present (convert snake_case to camelCase for JWT)
89
+ if user[:user_avatar_url]
90
+ payload[:userAvatarUrl] = user[:user_avatar_url]
91
91
  end
92
92
 
93
93
  # Add adminScopes if present
@@ -303,17 +303,23 @@ module Vortex
303
303
  # @param inviter [Hash] The inviter info: { user_id: '...', user_email: '...', name: '...' }
304
304
  # @param groups [Array<Hash>, nil] Optional groups: [{ type: '...', group_id: '...', name: '...' }]
305
305
  # @param source [String, nil] Optional source for analytics (defaults to 'api')
306
+ # @param subtype [String, nil] Optional subtype for analytics segmentation (e.g., 'pymk', 'find-friends')
306
307
  # @param template_variables [Hash, nil] Optional template variables for email customization
307
308
  # @param metadata [Hash, nil] Optional metadata passed through to webhooks
309
+ # @param unfurl_config [Hash, nil] Optional link unfurl (Open Graph) config: { title: '...', description: '...', image: '...', type: '...', site_name: '...' }
308
310
  # @return [Hash] Created invitation with :id, :short_link, :status, :created_at
309
311
  # @raise [VortexError] If the request fails
310
312
  #
311
- # @example Create an email invitation
313
+ # @example Create an email invitation with custom link preview
312
314
  # result = client.create_invitation(
313
315
  # 'widget-config-123',
314
316
  # { type: 'email', value: 'invitee@example.com' },
315
317
  # { user_id: 'user-456', user_email: 'inviter@example.com', name: 'John Doe' },
316
- # [{ type: 'team', group_id: 'team-789', name: 'Engineering' }]
318
+ # [{ type: 'team', group_id: 'team-789', name: 'Engineering' }],
319
+ # nil,
320
+ # nil,
321
+ # nil,
322
+ # { title: 'Join the team!', description: 'You have been invited', image: 'https://example.com/og.png' }
317
323
  # )
318
324
  #
319
325
  # @example Create an internal invitation (PYMK flow - no email sent)
@@ -324,7 +330,7 @@ module Vortex
324
330
  # nil,
325
331
  # 'pymk'
326
332
  # )
327
- def create_invitation(widget_configuration_id, target, inviter, groups = nil, source = nil, template_variables = nil, metadata = nil)
333
+ def create_invitation(widget_configuration_id, target, inviter, groups = nil, source = nil, subtype = nil, template_variables = nil, metadata = nil, unfurl_config = nil)
328
334
  raise VortexError, 'widget_configuration_id is required' if widget_configuration_id.nil? || widget_configuration_id.empty?
329
335
  raise VortexError, 'target must have type and value' if target[:type].nil? || target[:value].nil?
330
336
  raise VortexError, 'inviter must have user_id' if inviter[:user_id].nil?
@@ -336,8 +342,8 @@ module Vortex
336
342
  inviter: {
337
343
  userId: inviter[:user_id],
338
344
  userEmail: inviter[:user_email],
339
- name: inviter[:name],
340
- avatarUrl: inviter[:avatar_url]
345
+ userName: inviter[:user_name],
346
+ userAvatarUrl: inviter[:user_avatar_url]
341
347
  }.compact
342
348
  }
343
349
 
@@ -352,8 +358,18 @@ module Vortex
352
358
  end
353
359
 
354
360
  body[:source] = source if source
361
+ body[:subtype] = subtype if subtype
355
362
  body[:templateVariables] = template_variables if template_variables
356
363
  body[:metadata] = metadata if metadata
364
+ if unfurl_config
365
+ body[:unfurlConfig] = {
366
+ title: unfurl_config[:title],
367
+ description: unfurl_config[:description],
368
+ image: unfurl_config[:image],
369
+ type: unfurl_config[:type],
370
+ siteName: unfurl_config[:site_name]
371
+ }.compact
372
+ end
357
373
 
358
374
  response = @connection.post('/api/v1/invitations') do |req|
359
375
  req.headers['Content-Type'] = 'application/json'
@@ -367,6 +383,81 @@ module Vortex
367
383
  raise VortexError, "Failed to create invitation: #{e.message}"
368
384
  end
369
385
 
386
+ # Get autojoin domains configured for a specific scope
387
+ #
388
+ # @param scope_type [String] The type of scope (e.g., "organization", "team", "project")
389
+ # @param scope [String] The scope identifier (customer's group ID)
390
+ # @return [Hash] Response with :autojoin_domains array and :invitation
391
+ # @raise [VortexError] If the request fails
392
+ #
393
+ # @example
394
+ # result = client.get_autojoin_domains('organization', 'acme-org')
395
+ # result['autojoinDomains'].each do |domain|
396
+ # puts "Domain: #{domain['domain']}"
397
+ # end
398
+ def get_autojoin_domains(scope_type, scope)
399
+ encoded_scope_type = URI.encode_www_form_component(scope_type)
400
+ encoded_scope = URI.encode_www_form_component(scope)
401
+
402
+ response = @connection.get("/api/v1/invitations/by-scope/#{encoded_scope_type}/#{encoded_scope}/autojoin")
403
+ handle_response(response)
404
+ rescue VortexError
405
+ raise
406
+ rescue => e
407
+ raise VortexError, "Failed to get autojoin domains: #{e.message}"
408
+ end
409
+
410
+ # Configure autojoin domains for a specific scope
411
+ #
412
+ # This endpoint syncs autojoin domains - it will add new domains, remove domains
413
+ # not in the provided list, and deactivate the autojoin invitation if all domains
414
+ # are removed (empty array).
415
+ #
416
+ # @param scope [String] The scope identifier (customer's group ID)
417
+ # @param scope_type [String] The type of scope (e.g., "organization", "team")
418
+ # @param domains [Array<String>] Array of domains to configure for autojoin
419
+ # @param widget_id [String] The widget configuration ID
420
+ # @param scope_name [String, nil] Optional display name for the scope
421
+ # @param metadata [Hash, nil] Optional metadata to attach to the invitation
422
+ # @return [Hash] Response with :autojoin_domains array and :invitation
423
+ # @raise [VortexError] If the request fails
424
+ #
425
+ # @example
426
+ # result = client.configure_autojoin(
427
+ # 'acme-org',
428
+ # 'organization',
429
+ # ['acme.com', 'acme.org'],
430
+ # 'widget-123',
431
+ # 'Acme Corporation'
432
+ # )
433
+ def configure_autojoin(scope, scope_type, domains, widget_id, scope_name = nil, metadata = nil)
434
+ raise VortexError, 'scope is required' if scope.nil? || scope.empty?
435
+ raise VortexError, 'scope_type is required' if scope_type.nil? || scope_type.empty?
436
+ raise VortexError, 'widget_id is required' if widget_id.nil? || widget_id.empty?
437
+ raise VortexError, 'domains must be an array' unless domains.is_a?(Array)
438
+
439
+ body = {
440
+ scope: scope,
441
+ scopeType: scope_type,
442
+ domains: domains,
443
+ widgetId: widget_id
444
+ }
445
+
446
+ body[:scopeName] = scope_name if scope_name
447
+ body[:metadata] = metadata if metadata
448
+
449
+ response = @connection.post('/api/v1/invitations/autojoin') do |req|
450
+ req.headers['Content-Type'] = 'application/json'
451
+ req.body = JSON.generate(body)
452
+ end
453
+
454
+ handle_response(response)
455
+ rescue VortexError
456
+ raise
457
+ rescue => e
458
+ raise VortexError, "Failed to configure autojoin: #{e.message}"
459
+ end
460
+
370
461
  private
371
462
 
372
463
  def build_connection
data/lib/vortex/types.rb CHANGED
@@ -60,6 +60,21 @@ module Vortex
60
60
  # groups: [INVITATION_GROUP, ...],
61
61
  # # ... other fields
62
62
  # }
63
+ # InvitationTarget represents the target of an invitation
64
+ # @example
65
+ # {
66
+ # type: 'email', # 'email', 'phone', 'share', or 'internal'
67
+ # value: 'user@example.com',
68
+ # name: 'Jane Smith', # Optional: Display name of the person being invited
69
+ # avatarUrl: 'https://...' # Optional: Avatar URL for display in invitation lists
70
+ # }
71
+ INVITATION_TARGET = {
72
+ type: String, # Required: 'email', 'phone', 'share', or 'internal'
73
+ value: String, # Required: Email, phone, or internal ID
74
+ name: String, # Optional: Display name of the person being invited
75
+ avatarUrl: String # Optional: Avatar URL for the person being invited
76
+ }.freeze
77
+
63
78
  INVITATION = {
64
79
  id: String,
65
80
  accountId: String,
@@ -74,7 +89,7 @@ module Vortex
74
89
  invitationType: String,
75
90
  modifiedAt: String,
76
91
  status: String,
77
- target: Array, # of { type: String, value: String }
92
+ target: Array, # of INVITATION_TARGET structures
78
93
  views: Integer,
79
94
  widgetConfigurationId: String,
80
95
  projectId: String,
@@ -83,5 +98,61 @@ module Vortex
83
98
  expired: :boolean,
84
99
  expires: String # ISO 8601 timestamp (optional)
85
100
  }.freeze
101
+
102
+ # CreateInvitationTarget for creating invitations
103
+ # @example
104
+ # {
105
+ # type: 'email',
106
+ # value: 'invitee@example.com',
107
+ # name: 'Jane Smith', # Optional
108
+ # avatarUrl: 'https://...' # Optional
109
+ # }
110
+ CREATE_INVITATION_TARGET = {
111
+ type: String, # Required: 'email', 'phone', or 'internal'
112
+ value: String, # Required: Email, phone, or internal ID
113
+ name: String, # Optional: Display name of the person being invited
114
+ avatarUrl: String # Optional: Avatar URL for the person being invited
115
+ }.freeze
116
+
117
+ # AutojoinDomain structure for autojoin domain configuration
118
+ # @example
119
+ # {
120
+ # id: '550e8400-e29b-41d4-a716-446655440000',
121
+ # domain: 'acme.com'
122
+ # }
123
+ AUTOJOIN_DOMAIN = {
124
+ id: String, # Vortex internal UUID
125
+ domain: String # The domain configured for autojoin
126
+ }.freeze
127
+
128
+ # AutojoinDomainsResponse from autojoin API endpoints
129
+ # @example
130
+ # {
131
+ # autojoinDomains: [AUTOJOIN_DOMAIN, ...],
132
+ # invitation: INVITATION # or nil
133
+ # }
134
+ AUTOJOIN_DOMAINS_RESPONSE = {
135
+ autojoinDomains: Array, # Array of AUTOJOIN_DOMAIN structures
136
+ invitation: Hash # INVITATION structure or nil
137
+ }.freeze
138
+
139
+ # ConfigureAutojoinRequest for configuring autojoin domains
140
+ # @example
141
+ # {
142
+ # scope: 'acme-org',
143
+ # scopeType: 'organization',
144
+ # scopeName: 'Acme Corporation', # Optional
145
+ # domains: ['acme.com', 'acme.org'],
146
+ # widgetId: 'widget-123',
147
+ # metadata: { ... } # Optional
148
+ # }
149
+ CONFIGURE_AUTOJOIN_REQUEST = {
150
+ scope: String, # Required: Customer's group ID
151
+ scopeType: String, # Required: Type of scope (e.g., "organization", "team")
152
+ scopeName: String, # Optional: Display name for the scope
153
+ domains: Array, # Required: Array of domain strings
154
+ widgetId: String, # Required: Widget configuration ID
155
+ metadata: Hash # Optional: Metadata to attach to the invitation
156
+ }.freeze
86
157
  end
87
158
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vortex
4
- VERSION = '1.3.0'
4
+ VERSION = '1.6.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vortex-ruby-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vortex Software
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-01-28 00:00:00.000000000 Z
11
+ date: 2026-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday