calendly 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.0'
4
+ VERSION = '0.3.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.0
4
+ version: 0.3.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-25 00:00:00.000000000 Z
11
+ date: 2020-11-18 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.0
157
+ documentation_uri: https://www.rubydoc.info/gems/calendly/0.3.0
170
158
  post_install_message:
171
159
  rdoc_options: []
172
160
  require_paths: