calendly 0.5.2 → 0.6.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.
@@ -12,6 +12,7 @@ module Calendly
12
12
  # @return [String]
13
13
  # unique id of the Organization object.
14
14
  attr_accessor :uuid
15
+
15
16
  # @return [String]
16
17
  # Canonical resource reference.
17
18
  attr_accessor :uri
@@ -28,7 +29,7 @@ module Calendly
28
29
  # @raise [Calendly::ApiError] if the api returns error code.
29
30
  # @since 0.1.0
30
31
  def memberships(opts = {})
31
- return @cached_memberships if @cached_memberships
32
+ return @cached_memberships if defined?(@cached_memberships) && @cached_memberships
32
33
 
33
34
  request_proc = proc { |options| client.memberships uri, options }
34
35
  @cached_memberships = auto_pagination request_proc, opts
@@ -55,7 +56,7 @@ module Calendly
55
56
  # @raise [Calendly::ApiError] if the api returns error code.
56
57
  # @since 0.1.0
57
58
  def invitations(opts = {})
58
- return @cached_invitations if @cached_invitations
59
+ return @cached_invitations if defined?(@cached_invitations) && @cached_invitations
59
60
 
60
61
  request_proc = proc { |options| client.invitations uuid, options }
61
62
  @cached_invitations = auto_pagination request_proc, opts
@@ -80,6 +81,31 @@ module Calendly
80
81
  client.create_invitation uuid, email
81
82
  end
82
83
 
84
+ #
85
+ # Returns all Event Types associated with self.
86
+ #
87
+ # @param [Hash] opts the optional request parameters.
88
+ # @option opts [Integer] :count Number of rows to return.
89
+ # @option opts [String] :page_token Pass this to get the next portion of collection.
90
+ # @option opts [String] :sort Order results by the specified field and direction.
91
+ # Accepts comma-separated list of {field}:{direction} values.
92
+ # @return [Array<Calendly::EventType>]
93
+ # @raise [Calendly::Error] if the uri is empty.
94
+ # @raise [Calendly::ApiError] if the api returns error code.
95
+ # @since 0.6.0
96
+ def event_types(opts = {})
97
+ return @cached_event_types if defined?(@cached_event_types) && @cached_event_types
98
+
99
+ request_proc = proc { |options| client.event_types uri, options }
100
+ @cached_event_types = auto_pagination request_proc, opts
101
+ end
102
+
103
+ # @since 0.6.0
104
+ def event_types!(opts = {})
105
+ @cached_event_types = nil
106
+ event_types opts
107
+ end
108
+
83
109
  #
84
110
  # Returns all Scheduled Events associated with self.
85
111
  #
@@ -97,7 +123,7 @@ module Calendly
97
123
  # @raise [Calendly::ApiError] if the api returns error code.
98
124
  # @since 0.5.0
99
125
  def scheduled_events(opts = {})
100
- return @cached_scheduled_events if @cached_scheduled_events
126
+ return @cached_scheduled_events if defined?(@cached_scheduled_events) && @cached_scheduled_events
101
127
 
102
128
  request_proc = proc { |options| client.scheduled_events uri, options }
103
129
  @cached_scheduled_events = auto_pagination request_proc, opts
@@ -122,7 +148,7 @@ module Calendly
122
148
  # @raise [Calendly::ApiError] if the api returns error code.
123
149
  # @since 0.1.3
124
150
  def webhooks(opts = {})
125
- return @cached_webhooks if @cached_webhooks
151
+ return @cached_webhooks if defined?(@cached_webhooks) && @cached_webhooks
126
152
 
127
153
  request_proc = proc { |options| client.webhooks uri, options }
128
154
  @cached_webhooks = auto_pagination request_proc, opts
@@ -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
@@ -72,18 +76,12 @@ module Calendly
72
76
  # @raise [Calendly::ApiError] if the api returns error code.
73
77
  # @since 0.1.3
74
78
  def user_scope_webhooks(opts = {})
75
- return @cached_user_scope_webhooks if @cached_user_scope_webhooks
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
79
+ user.webhooks(opts)
81
80
  end
82
81
 
83
82
  # @since 0.2.0
84
83
  def user_scope_webhooks!(opts = {})
85
- @cached_user_scope_webhooks = nil
86
- user_scope_webhooks opts
84
+ user.webhooks!(opts)
87
85
  end
88
86
 
89
87
  #
@@ -98,9 +96,20 @@ module Calendly
98
96
  # @raise [Calendly::ApiError] if the api returns error code.
99
97
  # @since 0.1.3
100
98
  def create_user_scope_webhook(url, events)
101
- org_uri = organization.uri if organization
102
- user_uri = user.uri if user
103
- client.create_webhook url, events, org_uri, user_uri
99
+ user.create_webhook url, events
100
+ end
101
+
102
+ private
103
+
104
+ def after_set_attributes(attrs)
105
+ super attrs
106
+ if user.is_a?(User) && user.current_organization.nil? && organization.is_a?(Organization) # rubocop:disable Style/GuardClause
107
+ user.current_organization = organization
108
+ end
109
+ end
110
+
111
+ def inspect_attributes
112
+ super + %i[role]
104
113
  end
105
114
  end
106
115
  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
@@ -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
- return @cached_organization_membership if @cached_organization_membership
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
@@ -85,9 +101,9 @@ module Calendly
85
101
  # @raise [Calendly::ApiError] if the api returns error code.
86
102
  # @since 0.1.0
87
103
  def event_types(opts = {})
88
- return @cached_event_types if @cached_event_types
104
+ return @cached_event_types if defined?(@cached_event_types) && @cached_event_types
89
105
 
90
- request_proc = proc { |options| client.event_types uri, options }
106
+ request_proc = proc { |options| client.event_types_by_user uri, options }
91
107
  @cached_event_types = auto_pagination request_proc, opts
92
108
  end
93
109
 
@@ -114,7 +130,7 @@ module Calendly
114
130
  # @raise [Calendly::ApiError] if the api returns error code.
115
131
  # @since 0.1.0
116
132
  def scheduled_events(opts = {})
117
- return @cached_scheduled_events if @cached_scheduled_events
133
+ return @cached_scheduled_events if defined?(@cached_scheduled_events) && @cached_scheduled_events
118
134
 
119
135
  request_proc = proc { |options| client.scheduled_events_by_user uri, options }
120
136
  @cached_scheduled_events = auto_pagination request_proc, opts
@@ -125,5 +141,48 @@ module Calendly
125
141
  @cached_scheduled_events = nil
126
142
  scheduled_events opts
127
143
  end
144
+
145
+ #
146
+ # Get List of user scope Webhooks associated with self.
147
+ #
148
+ # @param [Hash] opts the optional request parameters.
149
+ # @option opts [Integer] :count Number of rows to return.
150
+ # @option opts [String] :page_token Pass this to get the next portion of collection.
151
+ # @option opts [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(opts = {})
159
+ return @cached_webhooks if defined?(@cached_webhooks) && @cached_webhooks
160
+
161
+ org_uri = current_organization&.uri
162
+ request_proc = proc { |options| client.user_scope_webhooks org_uri, uri, options }
163
+ @cached_webhooks = auto_pagination request_proc, opts
164
+ end
165
+
166
+ # @since 0.6.0
167
+ def webhooks!(opts = {})
168
+ @cached_webhooks = nil
169
+ webhooks opts
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
+ # @return [Calendly::WebhookSubscription]
178
+ # @raise [Calendly::Error] if the url arg is empty.
179
+ # @raise [Calendly::Error] if the events arg is empty.
180
+ # @raise [Calendly::Error] if the organization.uri is empty.
181
+ # @raise [Calendly::ApiError] if the api returns error code.
182
+ # @since 0.6.0
183
+ def create_webhook(url, events)
184
+ org_uri = current_organization&.uri
185
+ client.create_webhook url, events, org_uri, uri
186
+ end
128
187
  end
129
188
  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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Calendly
4
- VERSION = '0.5.2'
4
+ VERSION = '0.6.0'
5
5
  end
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.5.2
4
+ version: 0.6.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: 2020-12-13 00:00:00.000000000 Z
11
+ date: 2021-05-30 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.5.2
164
+ documentation_uri: https://www.rubydoc.info/gems/calendly/0.6.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