calendly 0.5.0 → 0.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/CHANGELOG.md +93 -0
- data/README.md +41 -30
- data/lib/calendly/api_error.rb +3 -0
- data/lib/calendly/client.rb +136 -75
- data/lib/calendly/configuration.rb +6 -1
- data/lib/calendly/models/event.rb +44 -31
- data/lib/calendly/models/event_type.rb +76 -21
- data/lib/calendly/models/event_type_custom_question.rb +48 -0
- data/lib/calendly/models/event_type_profile.rb +54 -0
- data/lib/calendly/models/guest.rb +21 -0
- data/lib/calendly/models/invitee.rb +41 -13
- data/lib/calendly/models/invitee_cancellation.rb +17 -0
- data/lib/calendly/models/invitee_payment.rb +28 -0
- data/lib/calendly/models/invitee_question_and_answer.rb +9 -1
- data/lib/calendly/models/invitee_tracking.rb +12 -1
- data/lib/calendly/models/invitees_counter.rb +19 -0
- data/lib/calendly/models/location.rb +10 -0
- data/lib/calendly/models/model_utils.rb +32 -6
- data/lib/calendly/models/organization.rb +75 -48
- data/lib/calendly/models/organization_invitation.rb +6 -0
- data/lib/calendly/models/organization_membership.rb +28 -18
- data/lib/calendly/models/team.rb +20 -0
- data/lib/calendly/models/user.rb +85 -25
- data/lib/calendly/models/webhook_subscription.rb +17 -0
- data/lib/calendly/version.rb +1 -1
- metadata +11 -4
@@ -16,21 +16,27 @@ module Calendly
|
|
16
16
|
# @return [String]
|
17
17
|
# unique id of the OrganizationInvitation object.
|
18
18
|
attr_accessor :uuid
|
19
|
+
|
19
20
|
# @return [String]
|
20
21
|
# Canonical resource reference.
|
21
22
|
attr_accessor :uri
|
23
|
+
|
22
24
|
# @return [String]
|
23
25
|
# Invited person's email.
|
24
26
|
attr_accessor :email
|
27
|
+
|
25
28
|
# @return [String]
|
26
29
|
# Invitation status.
|
27
30
|
attr_accessor :status
|
31
|
+
|
28
32
|
# @return [Time]
|
29
33
|
# Moment when user record was first created.
|
30
34
|
attr_accessor :created_at
|
35
|
+
|
31
36
|
# @return [Time]
|
32
37
|
# Moment when user record was last updated.
|
33
38
|
attr_accessor :updated_at
|
39
|
+
|
34
40
|
# @return [Time]
|
35
41
|
# Moment when the last invitation was sent.
|
36
42
|
attr_accessor :last_sent_at
|
@@ -16,15 +16,19 @@ module Calendly
|
|
16
16
|
# @return [String]
|
17
17
|
# unique id of the OrganizationMembership object.
|
18
18
|
attr_accessor :uuid
|
19
|
+
|
19
20
|
# @return [String]
|
20
21
|
# Canonical resource reference.
|
21
22
|
attr_accessor :uri
|
23
|
+
|
22
24
|
# @return [String]
|
23
25
|
# User's role within the organization
|
24
26
|
attr_accessor :role
|
27
|
+
|
25
28
|
# @return [Time]
|
26
29
|
# Moment when user record was first created.
|
27
30
|
attr_accessor :created_at
|
31
|
+
|
28
32
|
# @return [Time]
|
29
33
|
# Moment when user record was last updated.
|
30
34
|
attr_accessor :updated_at
|
@@ -61,29 +65,23 @@ module Calendly
|
|
61
65
|
#
|
62
66
|
# Get List of user scope Webhooks associated with self.
|
63
67
|
#
|
64
|
-
# @param [Hash]
|
65
|
-
# @option
|
66
|
-
# @option
|
67
|
-
# @option
|
68
|
+
# @param [Hash] options the optional request parameters. Optional.
|
69
|
+
# @option options [Integer] :count Number of rows to return.
|
70
|
+
# @option options [String] :page_token Pass this to get the next portion of collection.
|
71
|
+
# @option options [String] :sort Order results by the specified field and directin. Accepts comma-separated list of {field}:{direction} values.
|
68
72
|
# Accepts comma-separated list of {field}:{direction} values.
|
69
73
|
# @return [Array<Calendly::WebhookSubscription>]
|
70
74
|
# @raise [Calendly::Error] if the organization.uri is empty.
|
71
75
|
# @raise [Calendly::Error] if the user.uri is empty.
|
72
76
|
# @raise [Calendly::ApiError] if the api returns error code.
|
73
77
|
# @since 0.1.3
|
74
|
-
def user_scope_webhooks(
|
75
|
-
|
76
|
-
|
77
|
-
org_uri = organization.uri if organization
|
78
|
-
user_uri = user.uri if user
|
79
|
-
request_proc = proc { |options| client.user_scope_webhooks org_uri, user_uri, options }
|
80
|
-
@cached_user_scope_webhooks = auto_pagination request_proc, opts
|
78
|
+
def user_scope_webhooks(options: nil)
|
79
|
+
user.webhooks options: options
|
81
80
|
end
|
82
81
|
|
83
82
|
# @since 0.2.0
|
84
|
-
def user_scope_webhooks!(
|
85
|
-
|
86
|
-
user_scope_webhooks opts
|
83
|
+
def user_scope_webhooks!(options: nil)
|
84
|
+
user.webhooks! options: options
|
87
85
|
end
|
88
86
|
|
89
87
|
#
|
@@ -91,16 +89,28 @@ module Calendly
|
|
91
89
|
#
|
92
90
|
# @param [String] url Canonical reference (unique identifier) for the resource.
|
93
91
|
# @param [Array<String>] events List of user events to subscribe to. options: invitee.created or invitee.canceled
|
92
|
+
# @param [String] signing_key secret key shared between your application and Calendly. Optional.
|
94
93
|
# @return [Calendly::WebhookSubscription]
|
95
94
|
# @raise [Calendly::Error] if the url arg is empty.
|
96
95
|
# @raise [Calendly::Error] if the events arg is empty.
|
97
96
|
# @raise [Calendly::Error] if the organization.uri is empty.
|
98
97
|
# @raise [Calendly::ApiError] if the api returns error code.
|
99
98
|
# @since 0.1.3
|
100
|
-
def create_user_scope_webhook(url, events)
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
def create_user_scope_webhook(url, events, signing_key: nil)
|
100
|
+
user.create_webhook url, events, signing_key: signing_key
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def after_set_attributes(attrs)
|
106
|
+
super attrs
|
107
|
+
if user.is_a?(User) && user.current_organization.nil? && organization.is_a?(Organization) # rubocop:disable Style/GuardClause
|
108
|
+
user.current_organization = organization
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def inspect_attributes
|
113
|
+
super + %i[role]
|
104
114
|
end
|
105
115
|
end
|
106
116
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'calendly/client'
|
4
|
+
require 'calendly/models/model_utils'
|
5
|
+
|
6
|
+
module Calendly
|
7
|
+
# Calendly's team model.
|
8
|
+
class Team
|
9
|
+
include ModelUtils
|
10
|
+
UUID_RE = %r{\A#{Client::API_HOST}/teams/(\w+)\z}.freeze
|
11
|
+
|
12
|
+
# @return [String]
|
13
|
+
# unique id of the Team object.
|
14
|
+
attr_accessor :uuid
|
15
|
+
|
16
|
+
# @return [String]
|
17
|
+
# Canonical resource reference.
|
18
|
+
attr_accessor :uri
|
19
|
+
end
|
20
|
+
end
|
data/lib/calendly/models/user.rb
CHANGED
@@ -10,38 +10,52 @@ module Calendly
|
|
10
10
|
include ModelUtils
|
11
11
|
UUID_RE = %r{\A#{Client::API_HOST}/users/(\w+)\z}.freeze
|
12
12
|
TIME_FIELDS = %i[created_at updated_at].freeze
|
13
|
+
ASSOCIATION = {current_organization: Organization}.freeze
|
13
14
|
|
14
15
|
# @return [String]
|
15
16
|
# unique id of the User object.
|
16
17
|
attr_accessor :uuid
|
18
|
+
|
17
19
|
# @return [String]
|
18
20
|
# Canonical resource reference.
|
19
21
|
attr_accessor :uri
|
22
|
+
|
20
23
|
# @return [String]
|
21
24
|
# User's human-readable name.
|
22
25
|
attr_accessor :name
|
26
|
+
|
23
27
|
# @return [String]
|
24
28
|
# Unique readable value used in page URL.
|
25
29
|
attr_accessor :slug
|
30
|
+
|
26
31
|
# @return [String]
|
27
32
|
# User's email address.
|
28
33
|
attr_accessor :email
|
34
|
+
|
29
35
|
# @return [String]
|
30
36
|
# URL of user's avatar image.
|
31
37
|
attr_accessor :avatar_url
|
38
|
+
|
32
39
|
# @return [String]
|
33
40
|
# URL of user's event page.
|
34
41
|
attr_accessor :scheduling_url
|
42
|
+
|
35
43
|
# @return [String]
|
36
44
|
# Timezone offest to use when presenting time information to user.
|
37
45
|
attr_accessor :timezone
|
46
|
+
|
38
47
|
# @return [Time]
|
39
48
|
# Moment when user record was first created.
|
40
49
|
attr_accessor :created_at
|
50
|
+
|
41
51
|
# @return [Time]
|
42
52
|
# Moment when user record was last updated.
|
43
53
|
attr_accessor :updated_at
|
44
54
|
|
55
|
+
# @return [Organization]
|
56
|
+
# user's current organization
|
57
|
+
attr_accessor :current_organization
|
58
|
+
|
45
59
|
#
|
46
60
|
# Get basic information associated with self.
|
47
61
|
#
|
@@ -60,7 +74,9 @@ module Calendly
|
|
60
74
|
# @raise [Calendly::Error] if the uri is empty.
|
61
75
|
# @since 0.1.0
|
62
76
|
def organization_membership
|
63
|
-
|
77
|
+
if defined?(@cached_organization_membership) && @cached_organization_membership
|
78
|
+
return @cached_organization_membership
|
79
|
+
end
|
64
80
|
|
65
81
|
mems, = client.memberships_by_user uri
|
66
82
|
@cached_organization_membership = mems.first
|
@@ -75,55 +91,99 @@ module Calendly
|
|
75
91
|
#
|
76
92
|
# Returns all Event Types associated with self.
|
77
93
|
#
|
78
|
-
# @param [Hash]
|
79
|
-
# @option
|
80
|
-
# @option
|
81
|
-
# @option
|
94
|
+
# @param [Hash] options the optional request parameters. Optional.
|
95
|
+
# @option options [Integer] :count Number of rows to return.
|
96
|
+
# @option options [String] :page_token Pass this to get the next portion of collection.
|
97
|
+
# @option options [String] :sort Order results by the specified field and direction.
|
82
98
|
# Accepts comma-separated list of {field}:{direction} values.
|
83
99
|
# @return [Array<Calendly::EventType>]
|
84
100
|
# @raise [Calendly::Error] if the uri is empty.
|
85
101
|
# @raise [Calendly::ApiError] if the api returns error code.
|
86
102
|
# @since 0.1.0
|
87
|
-
def event_types(
|
88
|
-
return @cached_event_types if @cached_event_types
|
103
|
+
def event_types(options: nil)
|
104
|
+
return @cached_event_types if defined?(@cached_event_types) && @cached_event_types
|
89
105
|
|
90
|
-
request_proc = proc { |
|
91
|
-
@cached_event_types = auto_pagination request_proc,
|
106
|
+
request_proc = proc { |opts| client.event_types_by_user uri, options: opts }
|
107
|
+
@cached_event_types = auto_pagination request_proc, options
|
92
108
|
end
|
93
109
|
|
94
110
|
# @since 0.2.0
|
95
|
-
def event_types!(
|
111
|
+
def event_types!(options: nil)
|
96
112
|
@cached_event_types = nil
|
97
|
-
event_types
|
113
|
+
event_types options: options
|
98
114
|
end
|
99
115
|
|
100
116
|
#
|
101
117
|
# Returns all Scheduled Events associated with self.
|
102
118
|
#
|
103
|
-
# @param [Hash]
|
104
|
-
# @option
|
105
|
-
# @option
|
106
|
-
# @option
|
107
|
-
# @option
|
108
|
-
# @option
|
109
|
-
# @option
|
119
|
+
# @param [Hash] options the optional request parameters. Optional.
|
120
|
+
# @option options [Integer] :count Number of rows to return.
|
121
|
+
# @option options [String] :invitee_email Return events scheduled with the specified invitee email
|
122
|
+
# @option options [String] :max_start_timeUpper bound (inclusive) for an event's start time to filter by.
|
123
|
+
# @option options [String] :min_start_time Lower bound (inclusive) for an event's start time to filter by.
|
124
|
+
# @option options [String] :page_token Pass this to get the next portion of collection.
|
125
|
+
# @option options [String] :sort Order results by the specified field and directin.
|
110
126
|
# Accepts comma-separated list of {field}:{direction} values.
|
111
|
-
# @option
|
127
|
+
# @option options [String] :status Whether the scheduled event is active or canceled
|
112
128
|
# @return [Array<Calendly::Event>]
|
113
129
|
# @raise [Calendly::Error] if the uri is empty.
|
114
130
|
# @raise [Calendly::ApiError] if the api returns error code.
|
115
131
|
# @since 0.1.0
|
116
|
-
def scheduled_events(
|
117
|
-
return @cached_scheduled_events if @cached_scheduled_events
|
132
|
+
def scheduled_events(options: nil)
|
133
|
+
return @cached_scheduled_events if defined?(@cached_scheduled_events) && @cached_scheduled_events
|
118
134
|
|
119
|
-
request_proc = proc { |
|
120
|
-
@cached_scheduled_events = auto_pagination request_proc,
|
135
|
+
request_proc = proc { |opts| client.scheduled_events_by_user uri, options: opts }
|
136
|
+
@cached_scheduled_events = auto_pagination request_proc, options
|
121
137
|
end
|
122
138
|
|
123
139
|
# @since 0.2.0
|
124
|
-
def scheduled_events!(
|
140
|
+
def scheduled_events!(options: nil)
|
125
141
|
@cached_scheduled_events = nil
|
126
|
-
scheduled_events
|
142
|
+
scheduled_events options: options
|
143
|
+
end
|
144
|
+
|
145
|
+
#
|
146
|
+
# Get List of user scope Webhooks associated with self.
|
147
|
+
#
|
148
|
+
# @param [Hash] options the optional request parameters. Optional.
|
149
|
+
# @option options [Integer] :count Number of rows to return.
|
150
|
+
# @option options [String] :page_token Pass this to get the next portion of collection.
|
151
|
+
# @option options [String] :sort Order results by the specified field and directin. Accepts comma-separated list of {field}:{direction} values.
|
152
|
+
# Accepts comma-separated list of {field}:{direction} values.
|
153
|
+
# @return [Array<Calendly::WebhookSubscription>]
|
154
|
+
# @raise [Calendly::Error] if the organization.uri is empty.
|
155
|
+
# @raise [Calendly::Error] if the uri is empty.
|
156
|
+
# @raise [Calendly::ApiError] if the api returns error code.
|
157
|
+
# @since 0.6.0
|
158
|
+
def webhooks(options: nil)
|
159
|
+
return @cached_webhooks if defined?(@cached_webhooks) && @cached_webhooks
|
160
|
+
|
161
|
+
org_uri = current_organization&.uri
|
162
|
+
request_proc = proc { |opts| client.user_scope_webhooks org_uri, uri, options: opts }
|
163
|
+
@cached_webhooks = auto_pagination request_proc, options
|
164
|
+
end
|
165
|
+
|
166
|
+
# @since 0.6.0
|
167
|
+
def webhooks!(options: nil)
|
168
|
+
@cached_webhooks = nil
|
169
|
+
webhooks options: options
|
170
|
+
end
|
171
|
+
|
172
|
+
#
|
173
|
+
# Create a user scope webhook associated with self.
|
174
|
+
#
|
175
|
+
# @param [String] url Canonical reference (unique identifier) for the resource.
|
176
|
+
# @param [Array<String>] events List of user events to subscribe to. options: invitee.created or invitee.canceled
|
177
|
+
# @param [String] signing_key secret key shared between your application and Calendly. Optional.
|
178
|
+
# @return [Calendly::WebhookSubscription]
|
179
|
+
# @raise [Calendly::Error] if the url arg is empty.
|
180
|
+
# @raise [Calendly::Error] if the events arg is empty.
|
181
|
+
# @raise [Calendly::Error] if the organization.uri is empty.
|
182
|
+
# @raise [Calendly::ApiError] if the api returns error code.
|
183
|
+
# @since 0.6.0
|
184
|
+
def create_webhook(url, events, signing_key: nil)
|
185
|
+
org_uri = current_organization&.uri
|
186
|
+
client.create_webhook url, events, org_uri, user_uri: uri, signing_key: signing_key
|
127
187
|
end
|
128
188
|
end
|
129
189
|
end
|
@@ -16,36 +16,47 @@ module Calendly
|
|
16
16
|
# @return [String]
|
17
17
|
# unique id of the WebhookSubscription object.
|
18
18
|
attr_accessor :uuid
|
19
|
+
|
19
20
|
# @return [String]
|
20
21
|
# Canonical reference (unique identifier) for the webhook.
|
21
22
|
attr_accessor :uri
|
23
|
+
|
22
24
|
# @return [String]
|
23
25
|
# The callback URL to use when the event is triggered.
|
24
26
|
attr_accessor :callback_url
|
27
|
+
|
25
28
|
# @return [Time]
|
26
29
|
# The moment when the webhook subscription was created.
|
27
30
|
attr_accessor :created_at
|
31
|
+
|
28
32
|
# @return [Time]
|
29
33
|
# The moment when the webhook subscription was last updated.
|
30
34
|
attr_accessor :updated_at
|
35
|
+
|
31
36
|
# @return [Time]
|
32
37
|
# The date and time the webhook subscription is retried.
|
33
38
|
attr_accessor :retry_started_at
|
39
|
+
|
34
40
|
# @return [String]
|
35
41
|
# Indicates if the webhook subscription is "active" or "disabled".
|
36
42
|
attr_accessor :state
|
43
|
+
|
37
44
|
# @return [Array<String>]
|
38
45
|
# A list of events to which the webhook is subscribed.
|
39
46
|
attr_accessor :events
|
47
|
+
|
40
48
|
# @return [String]
|
41
49
|
# The scope of the webhook subscription.
|
42
50
|
attr_accessor :scope
|
51
|
+
|
43
52
|
# @return [Calendly::Organization]
|
44
53
|
# The organization that's associated with the webhook subscription.
|
45
54
|
attr_accessor :organization
|
55
|
+
|
46
56
|
# @return [Calendly::User]
|
47
57
|
# The user that's associated with the webhook subscription.
|
48
58
|
attr_accessor :user
|
59
|
+
|
49
60
|
# @return [Calendly::User]
|
50
61
|
# The user who created the webhook subscription.
|
51
62
|
attr_accessor :creator
|
@@ -71,5 +82,11 @@ module Calendly
|
|
71
82
|
def delete
|
72
83
|
client.delete_webhook uuid
|
73
84
|
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def inspect_attributes
|
89
|
+
super + %i[state scope events callback_url]
|
90
|
+
end
|
74
91
|
end
|
75
92
|
end
|
data/lib/calendly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calendly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenji Koshikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -136,14 +136,21 @@ files:
|
|
136
136
|
- lib/calendly/loggable.rb
|
137
137
|
- lib/calendly/models/event.rb
|
138
138
|
- lib/calendly/models/event_type.rb
|
139
|
+
- lib/calendly/models/event_type_custom_question.rb
|
140
|
+
- lib/calendly/models/event_type_profile.rb
|
141
|
+
- lib/calendly/models/guest.rb
|
139
142
|
- lib/calendly/models/invitee.rb
|
143
|
+
- lib/calendly/models/invitee_cancellation.rb
|
144
|
+
- lib/calendly/models/invitee_payment.rb
|
140
145
|
- lib/calendly/models/invitee_question_and_answer.rb
|
141
146
|
- lib/calendly/models/invitee_tracking.rb
|
147
|
+
- lib/calendly/models/invitees_counter.rb
|
142
148
|
- lib/calendly/models/location.rb
|
143
149
|
- lib/calendly/models/model_utils.rb
|
144
150
|
- lib/calendly/models/organization.rb
|
145
151
|
- lib/calendly/models/organization_invitation.rb
|
146
152
|
- lib/calendly/models/organization_membership.rb
|
153
|
+
- lib/calendly/models/team.rb
|
147
154
|
- lib/calendly/models/user.rb
|
148
155
|
- lib/calendly/models/webhook_subscription.rb
|
149
156
|
- lib/calendly/version.rb
|
@@ -154,7 +161,7 @@ metadata:
|
|
154
161
|
homepage_uri: https://github.com/koshilife/calendly-api-ruby-client
|
155
162
|
source_code_uri: https://github.com/koshilife/calendly-api-ruby-client
|
156
163
|
changelog_uri: https://github.com/koshilife/calendly-api-ruby-client/blob/master/CHANGELOG.md
|
157
|
-
documentation_uri: https://www.rubydoc.info/gems/calendly/0.
|
164
|
+
documentation_uri: https://www.rubydoc.info/gems/calendly/0.8.0
|
158
165
|
post_install_message:
|
159
166
|
rdoc_options: []
|
160
167
|
require_paths:
|
@@ -170,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
177
|
- !ruby/object:Gem::Version
|
171
178
|
version: '0'
|
172
179
|
requirements: []
|
173
|
-
rubygems_version: 3.0.3
|
180
|
+
rubygems_version: 3.0.3.1
|
174
181
|
signing_key:
|
175
182
|
specification_version: 4
|
176
183
|
summary: Client for accessing Calendly APIs
|