nylas 6.7.0 → 6.8.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 +4 -4
- data/lib/nylas/client.rb +36 -0
- data/lib/nylas/handler/api_operations.rb +38 -21
- data/lib/nylas/handler/http_client.rb +108 -23
- data/lib/nylas/handler/service_account_signer.rb +112 -0
- data/lib/nylas/resources/applications.rb +14 -0
- data/lib/nylas/resources/bookings.rb +4 -2
- data/lib/nylas/resources/domains.rb +269 -0
- data/lib/nylas/resources/lists.rb +36 -0
- data/lib/nylas/resources/policies.rb +124 -0
- data/lib/nylas/resources/redirect_uris.rb +2 -2
- data/lib/nylas/resources/rules.rb +161 -0
- data/lib/nylas/resources/webhooks.rb +4 -5
- data/lib/nylas/resources/workspaces.rb +111 -0
- data/lib/nylas/utils/file_utils.rb +6 -3
- data/lib/nylas/version.rb +1 -1
- data/lib/nylas.rb +6 -0
- metadata +24 -4
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "resource"
|
|
4
|
+
require_relative "../handler/api_operations"
|
|
5
|
+
|
|
6
|
+
module Nylas
|
|
7
|
+
# Nylas Workspaces API
|
|
8
|
+
#
|
|
9
|
+
# A workspace groups grants in a Nylas application by email domain. Grants can be
|
|
10
|
+
# auto-grouped (by matching email domain) or manually assigned/removed.
|
|
11
|
+
class Workspaces < Resource
|
|
12
|
+
include ApiOperations::Get
|
|
13
|
+
include ApiOperations::Post
|
|
14
|
+
include ApiOperations::Patch
|
|
15
|
+
include ApiOperations::Delete
|
|
16
|
+
|
|
17
|
+
# Return all workspaces for the application.
|
|
18
|
+
#
|
|
19
|
+
# The list endpoint is not paginated; +data+ is a flat array of workspaces.
|
|
20
|
+
#
|
|
21
|
+
# @return [Array(Array(Hash), String, Hash)] The list of workspaces, API Request ID,
|
|
22
|
+
# and response headers.
|
|
23
|
+
def list
|
|
24
|
+
get(
|
|
25
|
+
path: "#{api_uri}/v3/workspaces"
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Return a workspace.
|
|
30
|
+
#
|
|
31
|
+
# @param workspace_id [String] The id of the workspace to return. Accepts a workspace
|
|
32
|
+
# UUID or an email domain.
|
|
33
|
+
# @return [Array(Hash, String, Hash)] The workspace, API Request ID, and response headers.
|
|
34
|
+
def find(workspace_id:)
|
|
35
|
+
get(
|
|
36
|
+
path: "#{api_uri}/v3/workspaces/#{workspace_id}"
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Create a workspace.
|
|
41
|
+
#
|
|
42
|
+
# @param request_body [Hash] The values to create the workspace with. Only +name+ is
|
|
43
|
+
# required.
|
|
44
|
+
# @return [Array(Hash, String, Hash)] The created workspace, API Request ID, and
|
|
45
|
+
# response headers.
|
|
46
|
+
def create(request_body:)
|
|
47
|
+
post(
|
|
48
|
+
path: "#{api_uri}/v3/workspaces",
|
|
49
|
+
request_body: request_body
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Update a workspace.
|
|
54
|
+
#
|
|
55
|
+
# The API exposes update via PATCH only (there is no PUT route). The workspace must be
|
|
56
|
+
# addressed by its UUID; a domain path param is not accepted on update.
|
|
57
|
+
#
|
|
58
|
+
# @param workspace_id [String] The UUID of the workspace to update.
|
|
59
|
+
# @param request_body [Hash] The values to update the workspace with.
|
|
60
|
+
# @return [Array(Hash, String)] The updated workspace and API Request ID.
|
|
61
|
+
def update(workspace_id:, request_body:)
|
|
62
|
+
patch(
|
|
63
|
+
path: "#{api_uri}/v3/workspaces/#{workspace_id}",
|
|
64
|
+
request_body: request_body
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Delete a workspace.
|
|
69
|
+
#
|
|
70
|
+
# @param workspace_id [String] The id of the workspace to delete. Accepts a workspace
|
|
71
|
+
# UUID or an email domain.
|
|
72
|
+
# @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
|
|
73
|
+
def destroy(workspace_id:)
|
|
74
|
+
_, request_id = delete(
|
|
75
|
+
path: "#{api_uri}/v3/workspaces/#{workspace_id}"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
[true, request_id]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Auto-group grants into workspaces by matching email domain.
|
|
82
|
+
#
|
|
83
|
+
# Runs as a background job and returns immediately with a job ID. Rate limited to one
|
|
84
|
+
# call per minute per application.
|
|
85
|
+
#
|
|
86
|
+
# @param request_body [Hash] Optional filters to scope which grants are grouped,
|
|
87
|
+
# including +after_created_at+, +invalid_also+, and +specific_domain+.
|
|
88
|
+
# @return [Array(Hash, String, Hash)] The job info, API Request ID, and response headers.
|
|
89
|
+
def auto_group(request_body: nil)
|
|
90
|
+
post(
|
|
91
|
+
path: "#{api_uri}/v3/workspaces/auto-group",
|
|
92
|
+
request_body: request_body
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Manually assign grants to or remove grants from a workspace.
|
|
97
|
+
#
|
|
98
|
+
# @param workspace_id [String] The id of the workspace to update. Accepts a workspace
|
|
99
|
+
# UUID or an email domain.
|
|
100
|
+
# @param request_body [Hash] The grants to assign and/or remove (+assign_grants+,
|
|
101
|
+
# +remove_grants+).
|
|
102
|
+
# @return [Array(Hash, String, Hash)] The assignment result, API Request ID, and
|
|
103
|
+
# response headers.
|
|
104
|
+
def manual_assign(workspace_id:, request_body:)
|
|
105
|
+
post(
|
|
106
|
+
path: "#{api_uri}/v3/workspaces/#{workspace_id}/manual-assign",
|
|
107
|
+
request_body: request_body
|
|
108
|
+
)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -28,12 +28,13 @@ module Nylas
|
|
|
28
28
|
|
|
29
29
|
attachments.each_with_index do |attachment, index|
|
|
30
30
|
file = attachment[:content] || attachment["content"]
|
|
31
|
+
file_path = attachment[:file_path] || attachment["file_path"]
|
|
31
32
|
if file.respond_to?(:closed?) && file.closed?
|
|
32
|
-
unless
|
|
33
|
+
unless file_path
|
|
33
34
|
raise ArgumentError, "The file at index #{index} is closed and no file_path was provided."
|
|
34
35
|
end
|
|
35
36
|
|
|
36
|
-
file = File.open(
|
|
37
|
+
file = File.open(file_path, "rb")
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
# Setting original filename and content type if available. See rest-client#lib/restclient/payload.rb
|
|
@@ -87,7 +88,9 @@ module Nylas
|
|
|
87
88
|
|
|
88
89
|
# Use form data only if the attachment size is greater than 3mb
|
|
89
90
|
attachments = payload[:attachments]
|
|
90
|
-
|
|
91
|
+
# Support both string and symbol keys for attachment size to handle
|
|
92
|
+
# user-provided hashes that may use either key type
|
|
93
|
+
attachment_size = attachments&.sum { |attachment| attachment[:size] || attachment["size"] || 0 } || 0
|
|
91
94
|
|
|
92
95
|
# Handle the attachment encoding depending on the size
|
|
93
96
|
if attachment_size >= FORM_DATA_ATTACHMENT_SIZE
|
data/lib/nylas/version.rb
CHANGED
data/lib/nylas.rb
CHANGED
|
@@ -12,6 +12,7 @@ require_relative "nylas/client"
|
|
|
12
12
|
require_relative "nylas/config"
|
|
13
13
|
|
|
14
14
|
require_relative "nylas/handler/http_client"
|
|
15
|
+
require_relative "nylas/handler/service_account_signer"
|
|
15
16
|
|
|
16
17
|
require_relative "nylas/resources/applications"
|
|
17
18
|
require_relative "nylas/resources/attachments"
|
|
@@ -24,11 +25,16 @@ require_relative "nylas/resources/drafts"
|
|
|
24
25
|
require_relative "nylas/resources/events"
|
|
25
26
|
require_relative "nylas/resources/folders"
|
|
26
27
|
require_relative "nylas/resources/grants"
|
|
28
|
+
require_relative "nylas/resources/lists"
|
|
27
29
|
require_relative "nylas/resources/messages"
|
|
28
30
|
require_relative "nylas/resources/notetakers"
|
|
29
31
|
require_relative "nylas/resources/smart_compose"
|
|
30
32
|
require_relative "nylas/resources/threads"
|
|
31
33
|
require_relative "nylas/resources/redirect_uris"
|
|
34
|
+
require_relative "nylas/resources/policies"
|
|
35
|
+
require_relative "nylas/resources/rules"
|
|
36
|
+
require_relative "nylas/resources/workspaces"
|
|
37
|
+
require_relative "nylas/resources/domains"
|
|
32
38
|
require_relative "nylas/resources/webhooks"
|
|
33
39
|
require_relative "nylas/resources/scheduler"
|
|
34
40
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nylas
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nylas, Inc.
|
|
@@ -57,6 +57,20 @@ dependencies:
|
|
|
57
57
|
- - ">="
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
59
|
version: 3.5.1
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: multipart-post
|
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - "~>"
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '2.0'
|
|
67
|
+
type: :runtime
|
|
68
|
+
prerelease: false
|
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - "~>"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '2.0'
|
|
60
74
|
- !ruby/object:Gem::Dependency
|
|
61
75
|
name: ostruct
|
|
62
76
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -139,14 +153,14 @@ dependencies:
|
|
|
139
153
|
requirements:
|
|
140
154
|
- - "~>"
|
|
141
155
|
- !ruby/object:Gem::Version
|
|
142
|
-
version: '
|
|
156
|
+
version: '3.5'
|
|
143
157
|
type: :development
|
|
144
158
|
prerelease: false
|
|
145
159
|
version_requirements: !ruby/object:Gem::Requirement
|
|
146
160
|
requirements:
|
|
147
161
|
- - "~>"
|
|
148
162
|
- !ruby/object:Gem::Version
|
|
149
|
-
version: '
|
|
163
|
+
version: '3.5'
|
|
150
164
|
- !ruby/object:Gem::Dependency
|
|
151
165
|
name: rubocop-capybara
|
|
152
166
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -269,6 +283,7 @@ files:
|
|
|
269
283
|
- lib/nylas/errors.rb
|
|
270
284
|
- lib/nylas/handler/api_operations.rb
|
|
271
285
|
- lib/nylas/handler/http_client.rb
|
|
286
|
+
- lib/nylas/handler/service_account_signer.rb
|
|
272
287
|
- lib/nylas/resources/applications.rb
|
|
273
288
|
- lib/nylas/resources/attachments.rb
|
|
274
289
|
- lib/nylas/resources/auth.rb
|
|
@@ -279,19 +294,24 @@ files:
|
|
|
279
294
|
- lib/nylas/resources/connectors.rb
|
|
280
295
|
- lib/nylas/resources/contacts.rb
|
|
281
296
|
- lib/nylas/resources/credentials.rb
|
|
297
|
+
- lib/nylas/resources/domains.rb
|
|
282
298
|
- lib/nylas/resources/drafts.rb
|
|
283
299
|
- lib/nylas/resources/events.rb
|
|
284
300
|
- lib/nylas/resources/folders.rb
|
|
285
301
|
- lib/nylas/resources/grants.rb
|
|
302
|
+
- lib/nylas/resources/lists.rb
|
|
286
303
|
- lib/nylas/resources/messages.rb
|
|
287
304
|
- lib/nylas/resources/notetakers.rb
|
|
305
|
+
- lib/nylas/resources/policies.rb
|
|
288
306
|
- lib/nylas/resources/redirect_uris.rb
|
|
289
307
|
- lib/nylas/resources/resource.rb
|
|
308
|
+
- lib/nylas/resources/rules.rb
|
|
290
309
|
- lib/nylas/resources/scheduler.rb
|
|
291
310
|
- lib/nylas/resources/sessions.rb
|
|
292
311
|
- lib/nylas/resources/smart_compose.rb
|
|
293
312
|
- lib/nylas/resources/threads.rb
|
|
294
313
|
- lib/nylas/resources/webhooks.rb
|
|
314
|
+
- lib/nylas/resources/workspaces.rb
|
|
295
315
|
- lib/nylas/utils/file_utils.rb
|
|
296
316
|
- lib/nylas/version.rb
|
|
297
317
|
licenses:
|
|
@@ -317,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
317
337
|
- !ruby/object:Gem::Version
|
|
318
338
|
version: '0'
|
|
319
339
|
requirements: []
|
|
320
|
-
rubygems_version:
|
|
340
|
+
rubygems_version: 4.0.3
|
|
321
341
|
specification_version: 4
|
|
322
342
|
summary: Gem for interacting with the Nylas API
|
|
323
343
|
test_files: []
|