nylas 6.0.0.beta.2 → 6.0.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fa40920f9d190cc73e988935bdd235ad3a4bb342c8762be925fdb81f8c1c45f
4
- data.tar.gz: 6bf0722aae4e7b9699abeda1e25436ac62256aa7c14a1f9d330eff2d8908c9c6
3
+ metadata.gz: 5153fbe30a05d237c4e17da6ff51005ded6667ae710a50e349535079bfd5db91
4
+ data.tar.gz: 21e167b02e08cbf456ca45ffd94372fe6db8bf3fc7a1b5637ecf8bd5cde361bc
5
5
  SHA512:
6
- metadata.gz: 3fb796e62d9c6545d5632c0112ac328ee69ce0fbda26e82a31ce4adf790bea75096a172a7252a4b75da850cf6268a864ea6365137e40f8ff6e7682767bc7f3da
7
- data.tar.gz: 13b91300931cc49f195f1a3ab01d5c72fe7100bf0c83dcfac5acdd965c0da4b2a7c547bc0611482916c3de8a6f7255604f9ca47f3894f94aba09a483da1f8c73
6
+ metadata.gz: 232c65750e5e6027cf4414519be4e91a497c48b394d779ac2500af8bf82f3bf5317ecb1ec94261f80eb0cd46b373e88727c2aed65b036950f9d239a4276d313c
7
+ data.tar.gz: ccb50fddee574741f2baf36d4f44b46e246b219e0cb9d764d1ee2f1307cf8bf1a45aaec3a3bbe363f471b98ecc646fd60b79643ab730262308e9914a199b4719
data/lib/nylas/client.rb CHANGED
@@ -62,6 +62,13 @@ module Nylas
62
62
  Connectors.new(self)
63
63
  end
64
64
 
65
+ # The contact resources for your Nylas application.
66
+ #
67
+ # @return [Nylas::Contacts] Contact resources for your Nylas application.
68
+ def contacts
69
+ Contacts.new(self)
70
+ end
71
+
65
72
  # The draft resources for your Nylas application.
66
73
  #
67
74
  # @return [Nylas::Drafts] Draft resources for your Nylas application.
@@ -83,6 +90,13 @@ module Nylas
83
90
  Folders.new(self)
84
91
  end
85
92
 
93
+ # The grants resources for your Nylas application.
94
+ #
95
+ # @return [Nylas::Grants] Grant resources for your Nylas application
96
+ def grants
97
+ Grants.new(self)
98
+ end
99
+
86
100
  # The message resources for your Nylas application.
87
101
  #
88
102
  # @return [Nylas::Messages] Message resources for your Nylas application
@@ -16,15 +16,6 @@ module Nylas
16
16
  include ApiOperations::Post
17
17
  include ApiOperations::Get
18
18
 
19
- # Initializes Auth.
20
- def initialize(sdk_instance)
21
- super(sdk_instance)
22
-
23
- @grants = Grants.new(sdk_instance)
24
- end
25
-
26
- attr_reader :grants
27
-
28
19
  # Builds the URL for authenticating users to your application with OAuth 2.0.
29
20
  #
30
21
  # @param config [Hash] Configuration for building the URL.
@@ -43,6 +34,17 @@ module Nylas
43
34
  execute_token_request(request)
44
35
  end
45
36
 
37
+ # Create a Grant via Custom Authentication.
38
+ #
39
+ # @param request_body [Hash] The values to create the Grant with.
40
+ # @return [Array(Hash, String)] Created grant and API Request ID.
41
+ def custom_authentication(request_body)
42
+ post(
43
+ path: "#{api_uri}/v3/connect/custom",
44
+ request_body: request_body
45
+ )
46
+ end
47
+
46
48
  # Refreshes an access token.
47
49
  #
48
50
  # @param request [Hash] Code exchange request.
@@ -156,32 +158,17 @@ module Nylas
156
158
  "access_type" => config[:access_type] || "online",
157
159
  "response_type" => "code"
158
160
  }
159
- set_params(config)
160
-
161
- URI.encode_www_form(params)
162
- end
163
-
164
- # Set the parameters for the query
165
- def set_params(config)
166
161
  params["provider"] = config[:provider] if config[:provider]
167
- set_config_params(config)
168
- set_more_config(config)
169
- end
170
-
171
- # Set login related configurations
172
- def set_config_params(config)
162
+ params["prompt"] = config[:prompt] if config[:prompt]
163
+ params["metadata"] = config[:metadata] if config[:metadata]
164
+ params["state"] = config[:state] if config[:state]
165
+ params["scope"] = config[:scope].join(" ") if config[:scope]
173
166
  if config[:login_hint]
174
167
  params["login_hint"] = config[:login_hint]
175
168
  params["include_grant_scopes"] = config[:include_grant_scopes].to_s if config[:include_grant_scopes]
176
169
  end
177
- params["scope"] = config[:scope].join(" ") if config[:scope]
178
- end
179
170
 
180
- # More config
181
- def set_more_config(config)
182
- params["prompt"] = config[:prompt] if config[:prompt]
183
- params["metadata"] = config[:metadata] if config[:metadata]
184
- params["state"] = config[:state] if config[:state]
171
+ URI.encode_www_form(params)
185
172
  end
186
173
 
187
174
  # Hashes the secret for PKCE authentication.
@@ -93,7 +93,7 @@ module Nylas
93
93
  # @return [Array(Array(Hash), String)] The free/busy response.
94
94
  def get_free_busy(identifier:, request_body:)
95
95
  post(
96
- path: "#{api_uri}/v3/grants/#{identifier}/calendars/availability",
96
+ path: "#{api_uri}/v3/grants/#{identifier}/calendars/free-busy",
97
97
  request_body: request_body
98
98
  )
99
99
  end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+ require_relative "../handler/api_operations"
5
+
6
+ module Nylas
7
+ # Nylas Contact API
8
+ class Contacts < Resource
9
+ include ApiOperations::Get
10
+ include ApiOperations::Post
11
+ include ApiOperations::Put
12
+ include ApiOperations::Delete
13
+
14
+ # Return all contacts.
15
+ #
16
+ # @param identifier [String] Grant ID or email account to query.
17
+ # @param query_params [Hash, nil] Query params to pass to the request.
18
+ # @return [Array(Array(Hash), String)] The list of contacts and API Request ID.
19
+ def list(identifier:, query_params: nil)
20
+ get(
21
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts",
22
+ query_params: query_params
23
+ )
24
+ end
25
+
26
+ # Return a contact.
27
+ #
28
+ # @param identifier [String] Grant ID or email account to query.
29
+ # @param contact_id [String] The id of the contact to return.
30
+ # @param query_params [Hash, nil] Query params to pass to the request.
31
+ # @return [Array(Hash, String)] The contact and API request ID.
32
+ def find(identifier:, contact_id:, query_params: nil)
33
+ get(
34
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts/#{contact_id}",
35
+ query_params: query_params
36
+ )
37
+ end
38
+
39
+ # Create a contact.
40
+ #
41
+ # @param identifier [String] Grant ID or email account in which to create the object.
42
+ # @param request_body [Hash] The values to create the contact with.
43
+ # @return [Array(Hash, String)] The created contact and API Request ID.
44
+ def create(identifier:, request_body:)
45
+ post(
46
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts",
47
+ request_body: request_body
48
+ )
49
+ end
50
+
51
+ # Update a contact.
52
+ #
53
+ # @param identifier [String] Grant ID or email account in which to update an object.
54
+ # @param contact_id [String] The id of the contact to update.
55
+ # @param request_body [Hash] The values to update the contact with
56
+ # @return [Array(Hash, String)] The updated contact and API Request ID.
57
+ def update(identifier:, contact_id:, request_body:)
58
+ put(
59
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts/#{contact_id}",
60
+ request_body: request_body
61
+ )
62
+ end
63
+
64
+ # Delete a contact.
65
+ #
66
+ # @param identifier [String] Grant ID or email account from which to delete an object.
67
+ # @param contact_id [String] The id of the contact to delete.
68
+ # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
69
+ def destroy(identifier:, contact_id:)
70
+ _, request_id = delete(
71
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts/#{contact_id}"
72
+ )
73
+
74
+ [true, request_id]
75
+ end
76
+
77
+ # Return all contact groups.
78
+ #
79
+ # @param identifier [String] Grant ID or email account to query.
80
+ # @param query_params [Hash, nil] Query params to pass to the request.
81
+ # @return [Array(Array(Hash), String)] The list of contact groups and API Request ID.
82
+ def contact_groups(identifier:, query_params: nil)
83
+ get(
84
+ path: "#{api_uri}/v3/grants/#{identifier}/contacts/groups",
85
+ query_params: query_params
86
+ )
87
+ end
88
+ end
89
+ end
@@ -87,5 +87,16 @@ module Nylas
87
87
 
88
88
  [true, request_id]
89
89
  end
90
+
91
+ # Send an draft.
92
+ #
93
+ # @param identifier [String] Grant ID or email account from which to send the draft.
94
+ # @param draft_id [String] The id of the draft to send.
95
+ # @return [Array(Hash, String)] The sent message draft and the API Request ID.
96
+ def send(identifier:, draft_id:)
97
+ post(
98
+ path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}"
99
+ )
100
+ end
90
101
  end
91
102
  end
@@ -79,5 +79,20 @@ module Nylas
79
79
 
80
80
  [true, request_id]
81
81
  end
82
+
83
+ # Send RSVP. Allows users to respond to events they have been added to as an attendee.
84
+ #
85
+ # @param identifier [String] Grant ID or email account from which to send RSVP with.
86
+ # @param event_id [String] The id of the event to respond to.
87
+ # @param request_body [Hash] The status values to send the RSVP with.
88
+ # @param query_params [Hash] The query parameters to include in the request
89
+ # @return [Hash] Response object with the API Request ID.
90
+ def send_rsvp(identifier:, event_id:, request_body:, query_params:)
91
+ post(
92
+ path: "#{api_uri}/v3/grants/#{identifier}/events/#{event_id}/send-rsvp",
93
+ query_params: query_params,
94
+ request_body: request_body
95
+ )
96
+ end
82
97
  end
83
98
  end
@@ -7,7 +7,6 @@ module Nylas
7
7
  # Grants
8
8
  class Grants < Resource
9
9
  include ApiOperations::Get
10
- include ApiOperations::Post
11
10
  include ApiOperations::Put
12
11
  include ApiOperations::Delete
13
12
 
@@ -32,17 +31,6 @@ module Nylas
32
31
  )
33
32
  end
34
33
 
35
- # Create a Grant via Custom Authentication.
36
- #
37
- # @param request_body [Hash] The values to create the Grant with.
38
- # @return [Array(Hash, String)] Created grant and API Request ID.
39
- def create(request_body)
40
- post(
41
- path: "#{api_uri}/v3/#{resource_name}/custom",
42
- request_body: request_body
43
- )
44
- end
45
-
46
34
  # Update a grant.
47
35
  #
48
36
  # @param grant_id [String] The id of the grant to update.
@@ -19,6 +19,9 @@ module Nylas
19
19
  GRANT_EXPIRED = "grant.expired"
20
20
  MESSAGE_SEND_SUCCESS = "message.send_success"
21
21
  MESSAGE_SEND_FAILED = "message.send_failed"
22
+ MESSAGE_OPENED = "message.opened"
23
+ MESSAGE_LINK_CLICKED = "message.link_clicked"
24
+ THREAD_REPLIED = "thread.replied"
22
25
  end
23
26
 
24
27
  # Nylas Webhooks API
@@ -11,9 +11,14 @@ module Nylas
11
11
  # @!visibility private
12
12
  def self.build_form_request(request_body)
13
13
  attachments = request_body.delete(:attachments) || request_body.delete("attachments") || []
14
- message_payload = request_body.to_json
14
+
15
+ # RestClient will not send a multipart request if there are no attachments
16
+ # so we need to return the message payload to be used as a json payload
17
+ return [request_body, []] if attachments.empty?
15
18
 
16
19
  # Prepare the data to return
20
+ message_payload = request_body.to_json
21
+
17
22
  form_data = {}
18
23
  opened_files = []
19
24
 
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.0.0.beta.2"
4
+ VERSION = "6.0.0.beta.3"
5
5
  end
data/lib/nylas.rb CHANGED
@@ -32,6 +32,7 @@ require_relative "nylas/resources/attachments"
32
32
  require_relative "nylas/resources/auth"
33
33
  require_relative "nylas/resources/calendars"
34
34
  require_relative "nylas/resources/connectors"
35
+ require_relative "nylas/resources/contacts"
35
36
  require_relative "nylas/resources/credentials"
36
37
  require_relative "nylas/resources/drafts"
37
38
  require_relative "nylas/resources/events"
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.0.0.beta.2
4
+ version: 6.0.0.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nylas, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-21 00:00:00.000000000 Z
11
+ date: 2024-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -239,6 +239,7 @@ files:
239
239
  - lib/nylas/resources/auth.rb
240
240
  - lib/nylas/resources/calendars.rb
241
241
  - lib/nylas/resources/connectors.rb
242
+ - lib/nylas/resources/contacts.rb
242
243
  - lib/nylas/resources/credentials.rb
243
244
  - lib/nylas/resources/drafts.rb
244
245
  - lib/nylas/resources/events.rb