nylas 5.7.0 → 5.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nylas/calendar_collection.rb +22 -10
- data/lib/nylas/version.rb +1 -1
- data/lib/nylas/webhook.rb +77 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cf10f2710c3235c9230e3b86d41282e527c91f00771fd639609afa1ee2a81e9
|
4
|
+
data.tar.gz: 69569f23b2d53e00453171fb16d72e20ee6c91612e63af2de693b0e2bd6100aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7751effbad21dd7118415731e2cc96c370c2fbc53c39b7d536cc24ead935ea6ce86bbf4919ae6f530b45c1e4bdc0e420ee26ddb4438fd27a39ade73999bf059b
|
7
|
+
data.tar.gz: 85f42e07ef66b54180fbebd61f9808013675b2d459f23ce2cc1f347b9682f0dcfc92a7999536e1725cbba1ff41f18fff96b827d0eb44de25adcff72f0298b154
|
@@ -5,47 +5,53 @@ module Nylas
|
|
5
5
|
# @see https://developer.nylas.com/docs/connectivity/calendar
|
6
6
|
class CalendarCollection < Collection
|
7
7
|
def availability(duration_minutes:,
|
8
|
-
|
8
|
+
interval_minutes:,
|
9
9
|
start_time:,
|
10
10
|
end_time:,
|
11
|
-
emails
|
11
|
+
emails: [],
|
12
12
|
buffer: nil,
|
13
13
|
round_robin: nil,
|
14
14
|
free_busy: [],
|
15
|
-
open_hours: []
|
15
|
+
open_hours: [],
|
16
|
+
calendars: [])
|
17
|
+
validate_calendars_or_emails(calendars, emails)
|
16
18
|
validate_open_hours(emails, free_busy, open_hours) unless open_hours.empty?
|
17
19
|
|
18
20
|
execute_availability("/calendars/availability",
|
19
21
|
duration_minutes: duration_minutes,
|
20
|
-
|
22
|
+
interval_minutes: interval_minutes,
|
21
23
|
start_time: start_time,
|
22
24
|
end_time: end_time,
|
23
25
|
emails: emails,
|
24
26
|
buffer: buffer,
|
25
27
|
round_robin: round_robin,
|
26
28
|
free_busy: free_busy,
|
27
|
-
open_hours: open_hours
|
29
|
+
open_hours: open_hours,
|
30
|
+
calendars: calendars)
|
28
31
|
end
|
29
32
|
|
30
33
|
def consecutive_availability(duration_minutes:,
|
31
|
-
|
34
|
+
interval_minutes:,
|
32
35
|
start_time:,
|
33
36
|
end_time:,
|
34
|
-
emails
|
37
|
+
emails: [],
|
35
38
|
buffer: nil,
|
36
39
|
free_busy: [],
|
37
|
-
open_hours: []
|
40
|
+
open_hours: [],
|
41
|
+
calendars: [])
|
42
|
+
validate_calendars_or_emails(emails, calendars)
|
38
43
|
validate_open_hours(emails, free_busy, open_hours) unless open_hours.empty?
|
39
44
|
|
40
45
|
execute_availability("/calendars/availability/consecutive",
|
41
46
|
duration_minutes: duration_minutes,
|
42
|
-
|
47
|
+
interval_minutes: interval_minutes,
|
43
48
|
start_time: start_time,
|
44
49
|
end_time: end_time,
|
45
50
|
emails: emails,
|
46
51
|
buffer: buffer,
|
47
52
|
free_busy: free_busy,
|
48
|
-
open_hours: open_hours
|
53
|
+
open_hours: open_hours,
|
54
|
+
calendars: calendars)
|
49
55
|
end
|
50
56
|
|
51
57
|
private
|
@@ -58,6 +64,12 @@ module Nylas
|
|
58
64
|
)
|
59
65
|
end
|
60
66
|
|
67
|
+
def validate_calendars_or_emails(calendars, emails)
|
68
|
+
return unless calendars.empty? && emails.empty?
|
69
|
+
|
70
|
+
raise ArgumentError, "You must provide at least one of 'emails' or 'calendars'"
|
71
|
+
end
|
72
|
+
|
61
73
|
def validate_open_hours(emails, free_busy, open_hours)
|
62
74
|
raise TypeError, "open_hours' must be an array." unless open_hours.is_a?(Array)
|
63
75
|
|
data/lib/nylas/version.rb
CHANGED
data/lib/nylas/webhook.rb
CHANGED
@@ -1,21 +1,94 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module WebhookState
|
4
|
+
# Module representing the possible 'state' values in a Webhook
|
5
|
+
# @see https://developer.nylas.com/docs/api#post/a/client_id/webhooks
|
6
|
+
|
7
|
+
ACTIVE = "active"
|
8
|
+
INACTIVE = "inactive"
|
9
|
+
end
|
10
|
+
|
11
|
+
module WebhookTrigger
|
12
|
+
# Module representing the possible 'trigger' values in a Webhook
|
13
|
+
# @see https://developer.nylas.com/docs/api#post/a/client_id/webhooks
|
14
|
+
|
15
|
+
ACCOUNT_CONNECTED = "account.connected"
|
16
|
+
ACCOUNT_RUNNING = "account.running"
|
17
|
+
ACCOUNT_STOPPED = "account.stopped"
|
18
|
+
ACCOUNT_INVALID = "account.invalid"
|
19
|
+
ACCOUNT_SYNC_ERROR = "account.sync_error"
|
20
|
+
MESSAGE_CREATED = "message.created"
|
21
|
+
MESSAGE_OPENED = "message.opened"
|
22
|
+
MESSAGE_LINK_CLICKED = "message.link_created"
|
23
|
+
MESSAGE_UPDATED = "message.updated"
|
24
|
+
MESSAGE_BOUNCED = "message.bounced"
|
25
|
+
THREAD_REPLIED = "thread.replied"
|
26
|
+
CONTACT_CREATED = "contact.created"
|
27
|
+
CONTACT_UPDATED = "contact.updated"
|
28
|
+
CONTACT_DELETED = "contact.deleted"
|
29
|
+
CALENDAR_CREATED = "calendar.created"
|
30
|
+
CALENDAR_UPDATED = "calendar.updated"
|
31
|
+
CALENDAR_DELETED = "calendar.deleted"
|
32
|
+
EVENT_CREATED = "event.created"
|
33
|
+
EVENT_UPDATED = "event.updated"
|
34
|
+
EVENT_DELETED = "event.deleted"
|
35
|
+
JOB_SUCCESSFUL = "job.successful"
|
36
|
+
JOB_FAILED = "job.failed"
|
37
|
+
end
|
38
|
+
|
3
39
|
module Nylas
|
4
40
|
# Represents a webhook attached to your application.
|
5
41
|
# @see https://docs.nylas.com/reference#webhooks
|
6
42
|
class Webhook
|
7
43
|
include Model
|
8
|
-
allows_operations(listable: true, showable: true
|
9
|
-
|
10
|
-
attribute :
|
44
|
+
allows_operations(creatable: true, listable: true, showable: true, updatable: true,
|
45
|
+
destroyable: true)
|
46
|
+
attribute :id, :string, read_only: true
|
47
|
+
attribute :application_id, :string, read_only: true
|
11
48
|
|
12
49
|
attribute :callback_url, :string
|
13
50
|
attribute :state, :string
|
14
|
-
attribute :version, :string
|
51
|
+
attribute :version, :string, read_only: true
|
15
52
|
has_n_of_attribute :triggers, :string
|
16
53
|
|
54
|
+
STATE = [:inactive].freeze
|
55
|
+
|
56
|
+
def save
|
57
|
+
result = if persisted?
|
58
|
+
update_call(update_payload)
|
59
|
+
else
|
60
|
+
create
|
61
|
+
end
|
62
|
+
|
63
|
+
attributes.merge(result)
|
64
|
+
end
|
65
|
+
|
66
|
+
def save_all_attributes
|
67
|
+
save
|
68
|
+
end
|
69
|
+
|
70
|
+
def update(**data)
|
71
|
+
raise ArgumentError, "Only 'state' is allowed to be updated" if data.length > 1 || !data.key?(:state)
|
72
|
+
|
73
|
+
attributes.merge(**data)
|
74
|
+
payload = JSON.dump(data)
|
75
|
+
update_call(payload)
|
76
|
+
|
77
|
+
true
|
78
|
+
end
|
79
|
+
|
80
|
+
def update_all_attributes(**data)
|
81
|
+
update(**data)
|
82
|
+
end
|
83
|
+
|
17
84
|
def self.resources_path(api:)
|
18
85
|
"/a/#{api.app_id}/webhooks"
|
19
86
|
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def update_payload
|
91
|
+
JSON.dump({ state: state })
|
92
|
+
end
|
20
93
|
end
|
21
94
|
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: 5.
|
4
|
+
version: 5.8.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: 2022-
|
11
|
+
date: 2022-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -374,7 +374,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
374
374
|
- !ruby/object:Gem::Version
|
375
375
|
version: '0'
|
376
376
|
requirements: []
|
377
|
-
rubygems_version: 3.
|
377
|
+
rubygems_version: 3.3.3
|
378
378
|
signing_key:
|
379
379
|
specification_version: 4
|
380
380
|
summary: Gem for interacting with the Nylas API
|