calendly 0.4.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,9 +130,9 @@ 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
- request_proc = proc { |options| client.scheduled_events uri, options }
135
+ request_proc = proc { |options| client.scheduled_events_by_user uri, options }
120
136
  @cached_scheduled_events = auto_pagination request_proc, opts
121
137
  end
122
138
 
@@ -125,5 +141,49 @@ 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
+ # @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
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Calendly
4
- VERSION = '0.4.2'
4
+ VERSION = '0.7.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.4.2
4
+ version: 0.7.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-11-26 00:00:00.000000000 Z
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.4.2
164
+ documentation_uri: https://www.rubydoc.info/gems/calendly/0.7.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