calendly 0.1.1 → 0.4.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.
@@ -1,12 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'calendly/client'
4
+ require 'calendly/models/model_utils'
5
+ require 'calendly/models/organization'
6
+ require 'calendly/models/user'
7
+
3
8
  module Calendly
4
9
  # Calendly's organization invitation model.
5
10
  class OrganizationInvitation
6
11
  include ModelUtils
7
12
  UUID_RE = %r{\A#{Client::API_HOST}/organizations/\w+/invitations/(\w+)\z}.freeze
8
13
  TIME_FIELDS = %i[created_at updated_at last_sent_at].freeze
9
- ASSOCIATION = { user: User, organization: Organization }.freeze
14
+ ASSOCIATION = {user: User, organization: Organization}.freeze
10
15
 
11
16
  # @return [String]
12
17
  # unique id of the OrganizationInvitation object.
@@ -1,12 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'calendly/client'
4
+ require 'calendly/models/model_utils'
5
+ require 'calendly/models/organization'
6
+ require 'calendly/models/user'
7
+
3
8
  module Calendly
4
9
  # Calendly's organization membership model.
5
10
  class OrganizationMembership
6
11
  include ModelUtils
7
12
  UUID_RE = %r{\A#{Client::API_HOST}/organization_memberships/(\w+)\z}.freeze
8
13
  TIME_FIELDS = %i[created_at updated_at].freeze
9
- ASSOCIATION = { user: User, organization: Organization }.freeze
14
+ ASSOCIATION = {user: User, organization: Organization}.freeze
10
15
 
11
16
  # @return [String]
12
17
  # unique id of the OrganizationMembership object.
@@ -52,5 +57,50 @@ module Calendly
52
57
  def delete
53
58
  client.delete_membership uuid
54
59
  end
60
+
61
+ #
62
+ # Get List of user scope Webhooks associated with self.
63
+ #
64
+ # @param [Hash] opts the optional request parameters.
65
+ # @option opts [Integer] :count Number of rows to return.
66
+ # @option opts [String] :page_token Pass this to get the next portion of collection.
67
+ # @option opts [String] :sort Order results by the specified field and directin. Accepts comma-separated list of {field}:{direction} values.
68
+ # Accepts comma-separated list of {field}:{direction} values.
69
+ # @return [Array<Calendly::WebhookSubscription>]
70
+ # @raise [Calendly::Error] if the organization.uri is empty.
71
+ # @raise [Calendly::Error] if the user.uri is empty.
72
+ # @raise [Calendly::ApiError] if the api returns error code.
73
+ # @since 0.1.3
74
+ 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
81
+ end
82
+
83
+ # @since 0.2.0
84
+ def user_scope_webhooks!(opts = {})
85
+ @cached_user_scope_webhooks = nil
86
+ user_scope_webhooks opts
87
+ end
88
+
89
+ #
90
+ # Create a user scope webhook associated with self.
91
+ #
92
+ # @param [String] url Canonical reference (unique identifier) for the resource.
93
+ # @param [Array<String>] events List of user events to subscribe to. options: invitee.created or invitee.canceled
94
+ # @return [Calendly::WebhookSubscription]
95
+ # @raise [Calendly::Error] if the url arg is empty.
96
+ # @raise [Calendly::Error] if the events arg is empty.
97
+ # @raise [Calendly::Error] if the organization.uri is empty.
98
+ # @raise [Calendly::ApiError] if the api returns error code.
99
+ # @since 0.1.3
100
+ 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
104
+ end
55
105
  end
56
106
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'calendly/client'
4
+ require 'calendly/models/model_utils'
5
+
3
6
  module Calendly
4
7
  # Calendly's user model.
5
8
  # Primary account details of a specific user.
@@ -57,8 +60,16 @@ module Calendly
57
60
  # @raise [Calendly::Error] if the uri is empty.
58
61
  # @since 0.1.0
59
62
  def organization_membership
63
+ return @cached_organization_membership if @cached_organization_membership
64
+
60
65
  mems, = client.memberships_by_user uri
61
- mems.first
66
+ @cached_organization_membership = mems.first
67
+ end
68
+
69
+ # @since 0.2.0
70
+ def organization_membership!
71
+ @cached_organization_membership = nil
72
+ organization_membership
62
73
  end
63
74
 
64
75
  #
@@ -67,14 +78,23 @@ module Calendly
67
78
  # @param [Hash] opts the optional request parameters.
68
79
  # @option opts [Integer] :count Number of rows to return.
69
80
  # @option opts [String] :page_token Pass this to get the next portion of collection.
70
- # @option opts [String] :sort Order results by the specified field and direction. Accepts comma-separated list of {field}:{direction} values.
81
+ # @option opts [String] :sort Order results by the specified field and direction.
82
+ # Accepts comma-separated list of {field}:{direction} values.
71
83
  # @return [Array<Calendly::EventType>]
72
84
  # @raise [Calendly::Error] if the uri is empty.
73
85
  # @raise [Calendly::ApiError] if the api returns error code.
74
86
  # @since 0.1.0
75
87
  def event_types(opts = {})
88
+ return @cached_event_types if @cached_event_types
89
+
76
90
  request_proc = proc { |options| client.event_types uri, options }
77
- auto_pagination request_proc, opts
91
+ @cached_event_types = auto_pagination request_proc, opts
92
+ end
93
+
94
+ # @since 0.2.0
95
+ def event_types!(opts = {})
96
+ @cached_event_types = nil
97
+ event_types opts
78
98
  end
79
99
 
80
100
  #
@@ -83,18 +103,27 @@ module Calendly
83
103
  # @param [Hash] opts the optional request parameters.
84
104
  # @option opts [Integer] :count Number of rows to return.
85
105
  # @option opts [String] :invitee_email Return events scheduled with the specified invitee email
86
- # @option opts [String] :max_start_time Upper bound (inclusive) for an event's start time to filter by.
106
+ # @option opts [String] :max_start_timeUpper bound (inclusive) for an event's start time to filter by.
87
107
  # @option opts [String] :min_start_time Lower bound (inclusive) for an event's start time to filter by.
88
108
  # @option opts [String] :page_token Pass this to get the next portion of collection.
89
- # @option opts [String] :sort Order results by the specified field and directin. Accepts comma-separated list of {field}:{direction} values.
109
+ # @option opts [String] :sort Order results by the specified field and directin.
110
+ # Accepts comma-separated list of {field}:{direction} values.
90
111
  # @option opts [String] :status Whether the scheduled event is active or canceled
91
112
  # @return [Array<Calendly::Event>]
92
113
  # @raise [Calendly::Error] if the uri is empty.
93
114
  # @raise [Calendly::ApiError] if the api returns error code.
94
115
  # @since 0.1.0
95
116
  def scheduled_events(opts = {})
117
+ return @cached_scheduled_events if @cached_scheduled_events
118
+
96
119
  request_proc = proc { |options| client.scheduled_events uri, options }
97
- auto_pagination request_proc, opts
120
+ @cached_scheduled_events = auto_pagination request_proc, opts
121
+ end
122
+
123
+ # @since 0.2.0
124
+ def scheduled_events!(opts = {})
125
+ @cached_scheduled_events = nil
126
+ scheduled_events opts
98
127
  end
99
128
  end
100
129
  end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'calendly/client'
4
+ require 'calendly/models/model_utils'
5
+ require 'calendly/models/organization'
6
+ require 'calendly/models/user'
7
+
8
+ module Calendly
9
+ # Calendly's webhook model.
10
+ class WebhookSubscription
11
+ include ModelUtils
12
+ UUID_RE = %r{\A#{Client::API_HOST}/webhook_subscriptions/(\w+)\z}.freeze
13
+ TIME_FIELDS = %i[created_at updated_at retry_started_at].freeze
14
+ ASSOCIATION = {organization: Organization, user: User, creator: User}.freeze
15
+
16
+ # @return [String]
17
+ # unique id of the WebhookSubscription object.
18
+ attr_accessor :uuid
19
+ # @return [String]
20
+ # Canonical reference (unique identifier) for the webhook.
21
+ attr_accessor :uri
22
+ # @return [String]
23
+ # The callback URL to use when the event is triggered.
24
+ attr_accessor :callback_url
25
+ # @return [Time]
26
+ # The moment when the webhook subscription was created.
27
+ attr_accessor :created_at
28
+ # @return [Time]
29
+ # The moment when the webhook subscription was last updated.
30
+ attr_accessor :updated_at
31
+ # @return [Time]
32
+ # The date and time the webhook subscription is retried.
33
+ attr_accessor :retry_started_at
34
+ # @return [String]
35
+ # Indicates if the webhook subscription is "active" or "disabled".
36
+ attr_accessor :state
37
+ # @return [Array<String>]
38
+ # A list of events to which the webhook is subscribed.
39
+ attr_accessor :events
40
+ # @return [String]
41
+ # The scope of the webhook subscription.
42
+ attr_accessor :scope
43
+ # @return [Calendly::Organization]
44
+ # The organization that's associated with the webhook subscription.
45
+ attr_accessor :organization
46
+ # @return [Calendly::User]
47
+ # The user that's associated with the webhook subscription.
48
+ attr_accessor :user
49
+ # @return [Calendly::User]
50
+ # The user who created the webhook subscription.
51
+ attr_accessor :creator
52
+
53
+ #
54
+ # Get a webhook subscription associated with self.
55
+ #
56
+ # @return [Calendly::WebhookSubscription]
57
+ # @raise [Calendly::Error] if the uuid is empty.
58
+ # @raise [Calendly::ApiError] if the api returns error code.
59
+ # @since 0.1.3
60
+ def fetch
61
+ client.webhook uuid
62
+ end
63
+
64
+ #
65
+ # Delete a webhook subscription associated with self.
66
+ #
67
+ # @return [true]
68
+ # @raise [Calendly::Error] if the uuid is empty.
69
+ # @raise [Calendly::ApiError] if the api returns error code.
70
+ # @since 0.1.0
71
+ def delete
72
+ client.delete_webhook uuid
73
+ end
74
+ end
75
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Calendly
4
- VERSION = '0.1.1'
4
+ VERSION = '0.4.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.1.1
4
+ version: 0.4.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-08-27 00:00:00.000000000 Z
11
+ date: 2020-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.4.4
27
- - !ruby/object:Gem::Dependency
28
- name: zeitwerk
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.3.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 2.3.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -132,7 +118,7 @@ files:
132
118
  - ".github/workflows/gem-push.yml"
133
119
  - ".github/workflows/test.yml"
134
120
  - ".gitignore"
135
- - ".rubocom.yml"
121
+ - ".rubocop.yml"
136
122
  - CHANGELOG.md
137
123
  - CODE_OF_CONDUCT.md
138
124
  - Gemfile
@@ -147,6 +133,7 @@ files:
147
133
  - lib/calendly/client.rb
148
134
  - lib/calendly/configuration.rb
149
135
  - lib/calendly/error.rb
136
+ - lib/calendly/loggable.rb
150
137
  - lib/calendly/models/event.rb
151
138
  - lib/calendly/models/event_type.rb
152
139
  - lib/calendly/models/invitee.rb
@@ -158,6 +145,7 @@ files:
158
145
  - lib/calendly/models/organization_invitation.rb
159
146
  - lib/calendly/models/organization_membership.rb
160
147
  - lib/calendly/models/user.rb
148
+ - lib/calendly/models/webhook_subscription.rb
161
149
  - lib/calendly/version.rb
162
150
  homepage: https://github.com/koshilife/calendly-api-ruby-client
163
151
  licenses:
@@ -166,7 +154,7 @@ metadata:
166
154
  homepage_uri: https://github.com/koshilife/calendly-api-ruby-client
167
155
  source_code_uri: https://github.com/koshilife/calendly-api-ruby-client
168
156
  changelog_uri: https://github.com/koshilife/calendly-api-ruby-client/blob/master/CHANGELOG.md
169
- documentation_uri: https://www.rubydoc.info/gems/calendly/0.1.1
157
+ documentation_uri: https://www.rubydoc.info/gems/calendly/0.4.0
170
158
  post_install_message:
171
159
  rdoc_options: []
172
160
  require_paths: