nylas 6.1.1 → 6.2.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: a2876cab1f609fb357369d692fa8ed5b0fa04754d8b95b30b9d483856bbcff2e
4
- data.tar.gz: 94db4b8a8c253c4737348dcdb2fbdddf0fbdf021ac626ef0318ade71da4bf247
3
+ metadata.gz: 66046a0bdf3cda4d6c782bba25fba8459223c97930d3bf0d15f46e000f04546a
4
+ data.tar.gz: cf1e2a07df881e98a6087255c654078ceefcc2dca4b47a0cc79506edbbca63c1
5
5
  SHA512:
6
- metadata.gz: bade836048e4f19c3a1aebcf03a792bb73d38d850473fe9e60ff116fe6e7ca613f5e48c7f4d4f959f36cf0b361f3b2e7414cc96d5347c60bd7d306961da13e55
7
- data.tar.gz: 76d8048ed9eb92a1a660e3edc4d04cda08d7a676898c40092739f60c87250b99afefb19cf04ceef79b08a8cc7bf5425b87178d02e019f74c9937694a86d953e7
6
+ metadata.gz: fd94c45db1d031e7e431f7c6f09f2b6f0f8263787fd4a94c1c5978b14a8e57032febfdc5476705eb55f26c33ef3781554dcf3df9c2e4ea21b57764447cc4d7ed
7
+ data.tar.gz: a2aa5c353495efbdf033131569c12f5166297c760ee10ef50911bb55a4aec98f4823c5779660ba57904eb65b06751021d51a579046938e2a445b382cfa188a19
@@ -14,10 +14,12 @@ module Nylas
14
14
  # Return all folders.
15
15
  #
16
16
  # @param identifier [String] Grant ID or email account to query.
17
+ # @param query_params [Hash, nil] Query params to pass to the request.
17
18
  # @return [Array(Array(Hash), String, String)] The list of folders, API Request ID, and next cursor.
18
- def list(identifier:)
19
+ def list(identifier:, query_params: nil)
19
20
  get_list(
20
- path: "#{api_uri}/v3/grants/#{identifier}/folders"
21
+ path: "#{api_uri}/v3/grants/#{identifier}/folders",
22
+ query_params: query_params
21
23
  )
22
24
  end
23
25
 
data/lib/nylas/test.rb ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'nylas'
4
+
5
+ nylas = Nylas::Client.new(
6
+ api_key: "nyk_v0_tRgvnXpqESPGVaaf5QTDzoSYet94natpftScKTT8auH6Www49RJUQ1WJ5VAWplqu"
7
+ )
8
+
9
+ # file = Nylas::FileUtils.attach_file_request_builder("/Users/mostafa.r@nylas.com/Downloads/05i7gc9wvgv51.jpg")
10
+ file = Nylas::FileUtils.attach_file_request_builder("/Users/mostafa.r@nylas.com/Downloads/zara_reciept.pdf")
11
+
12
+ request_body = {
13
+ subject: "Ruby SDK attachment test - 8.30.24 x1",
14
+ to: [{email: "mostafa.r@nylas.com"}],
15
+ attachments: [file],
16
+ }
17
+
18
+ puts "Before request"
19
+ puts request_body
20
+
21
+ begin
22
+ email, _ = nylas.messages.send(identifier: "mostafa.r@nylas.com", request_body: request_body)
23
+ puts "Email sent successfully: #{email}"
24
+ rescue StandardError => e
25
+ puts "An error occurred: #{e.message}"
26
+ end
27
+
28
+ puts "After request"
29
+ puts request_body
30
+
31
+ # begin
32
+ # email, _ = nylas.messages.send(identifier: "mostafa.r@nylas.com", request_body: request_body)
33
+ # puts "Email sent successfully: #{email}"
34
+ # rescue StandardError => e1
35
+ # puts "An error occurred: #{e1.message}"
36
+ # end
@@ -13,20 +13,29 @@ module Nylas
13
13
  # @return The form data to send to the API and the opened files.
14
14
  # @!visibility private
15
15
  def self.build_form_request(request_body)
16
- attachments = request_body.delete(:attachments) || request_body.delete("attachments") || []
16
+ attachments = request_body[:attachments] || request_body["attachments"] || []
17
+ serializable_body = request_body.reject { |key, _| [:attachments, "attachments"].include?(key) }
18
+ request_body_copy = Marshal.load(Marshal.dump(serializable_body))
17
19
 
18
20
  # RestClient will not send a multipart request if there are no attachments
19
- # so we need to return the message payload to be used as a json payload
20
- return [request_body, []] if attachments.empty?
21
+ return [request_body_copy, []] if attachments.empty?
21
22
 
22
23
  # Prepare the data to return
23
- message_payload = request_body.to_json
24
+ message_payload = request_body_copy.to_json
24
25
 
25
26
  form_data = {}
26
27
  opened_files = []
27
28
 
28
29
  attachments.each_with_index do |attachment, index|
29
30
  file = attachment[:content] || attachment["content"]
31
+ if file.respond_to?(:closed?) && file.closed?
32
+ unless attachment[:file_path]
33
+ raise ArgumentError, "The file at index #{index} is closed and no file_path was provided."
34
+ end
35
+
36
+ file = File.open(attachment[:file_path], "rb")
37
+ end
38
+
30
39
  form_data.merge!({ "file#{index}" => file })
31
40
  opened_files << file
32
41
  end
@@ -98,7 +107,8 @@ module Nylas
98
107
  filename: filename,
99
108
  content_type: content_type,
100
109
  size: size,
101
- content: content
110
+ content: content,
111
+ file_path: file_path
102
112
  }
103
113
  end
104
114
  end
data/lib/nylas/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nylas
4
- VERSION = "6.1.1"
4
+ VERSION = "6.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nylas
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.1
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nylas, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-20 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -31,12 +31,26 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.5.1
33
33
  - !ruby/object:Gem::Dependency
34
- name: rest-client
34
+ name: ostruct
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.1'
39
+ version: '0.6'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rest-client
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.0.0
40
54
  - - "<"
41
55
  - !ruby/object:Gem::Version
42
56
  version: '3.0'
@@ -44,9 +58,9 @@ dependencies:
44
58
  prerelease: false
45
59
  version_requirements: !ruby/object:Gem::Requirement
46
60
  requirements:
47
- - - "~>"
61
+ - - ">="
48
62
  - !ruby/object:Gem::Version
49
- version: '2.1'
63
+ version: 2.0.0
50
64
  - - "<"
51
65
  - !ruby/object:Gem::Version
52
66
  version: '3.0'
@@ -251,6 +265,7 @@ files:
251
265
  - lib/nylas/resources/smart_compose.rb
252
266
  - lib/nylas/resources/threads.rb
253
267
  - lib/nylas/resources/webhooks.rb
268
+ - lib/nylas/test.rb
254
269
  - lib/nylas/utils/file_utils.rb
255
270
  - lib/nylas/version.rb
256
271
  homepage: