calendly 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa6443944ba1a41d6f868879ddd4aac837f09ce9285eb210d7b61acd5c644615
4
- data.tar.gz: efccf9e1c02314b14447e2d99ee9b67cb599f7eff3f9cd37d2b1396dd96d5bbd
3
+ metadata.gz: f21bb676098bf2f9d6f6e3ea600f7c4017d48207834646b185dbd459a6a8a531
4
+ data.tar.gz: e5e2accd3cc7145d99b3457f7ed87d79223b3b9fc18e0d49abdeb3a6b75b094f
5
5
  SHA512:
6
- metadata.gz: be6f91ef55bc88c7a7b925d80de73028f3390b6077765ad91648a486992845db1137778ddbe048cc08e861f025a2fcb653699289f0698a6fd6706144e00638e2
7
- data.tar.gz: 490abe0dc221919393b84d23c1eab5dfc776779df1b8f1c52206fd3251e36e09a8d8e8d6324cfad622540ea91d0a433283ca2cbff6f38fbd07ff49801a4851de
6
+ metadata.gz: ad14b69a614f2f3d39ff993f58b2b5c6f2e5c3a3d74a41b24ac5b17a9a6e915a84f0b99a7282695827d73009019d7ab9c6209a60c1ce8063609f5ab4a1cf5ba1
7
+ data.tar.gz: 5c5418b39536db9b1d88247e963e9277ae0964eaa64fdd7aabaef9edc29024aa6afed84e4df9b542fd93bf65fd0f311bdc467365bb7ac3097cc2a1a371dd5774
@@ -23,12 +23,11 @@ Metrics/BlockNesting:
23
23
  Max: 2
24
24
 
25
25
  Layout/LineLength:
26
- AllowURI: true
27
- Enabled: false
26
+ Max: 120
28
27
 
29
28
  Metrics/MethodLength:
30
29
  CountComments: false
31
- Max: 15
30
+ Max: 20
32
31
 
33
32
  Metrics/ParameterLists:
34
33
  Max: 4
@@ -39,10 +38,10 @@ Metrics/AbcSize:
39
38
 
40
39
  Style/CollectionMethods:
41
40
  PreferredMethods:
42
- map: 'collect'
43
- reduce: 'inject'
44
- find: 'detect'
45
- find_all: 'select'
41
+ map: "collect"
42
+ reduce: "inject"
43
+ find: "detect"
44
+ find_all: "select"
46
45
 
47
46
  Style/Documentation:
48
47
  Enabled: false
@@ -60,10 +59,13 @@ Style/ExpandPathArguments:
60
59
  Enabled: false
61
60
 
62
61
  Style/HashSyntax:
63
- EnforcedStyle: hash_rockets
62
+ EnforcedStyle: ruby19
64
63
 
65
64
  Style/Lambda:
66
65
  Enabled: false
67
66
 
68
67
  Style/RaiseArgs:
69
- EnforcedStyle: compact
68
+ EnforcedStyle: compact
69
+
70
+ Style/AsciiComments:
71
+ Enabled: false
@@ -1,27 +1,33 @@
1
- # 0.1.1
1
+ # CHANGELOG
2
+
3
+ ## 0.1.2
4
+
5
+ - fix rubocop warnings.
6
+
7
+ ## 0.1.1
2
8
 
3
9
  - add tests to make coverage 100%.
4
10
 
5
- # 0.1.0
11
+ ## 0.1.0
6
12
 
7
13
  - define methods to access associated resources with each model.
8
14
  - rename methods:
9
15
  - `Calendly::Client#events` to `Calendly::Client#scheduled_events`
10
16
 
11
- # 0.0.7.alpha
17
+ ## 0.0.7.alpha
12
18
 
13
19
  - support APIs
14
20
  - `POST /organizations/{uuid}/invitations`
15
21
  - `DELETE /organizations/{org_uuid}/invitations/{invitation_uuid}`
16
22
  - `DELETE /organization_memberships/{uuid}`
17
23
 
18
- # 0.0.6.alpha
24
+ ## 0.0.6.alpha
19
25
 
20
26
  - support APIs
21
27
  - `GET /organizations/{uuid}/invitations`
22
28
  - `GET /organizations/{organization_uuid}/invitations/{invitation_uuid}`
23
29
 
24
- # 0.0.5.alpha
30
+ ## 0.0.5.alpha
25
31
 
26
32
  - support APIs
27
33
  - `GET /organization_memberships`
@@ -30,24 +36,24 @@
30
36
  - Invitee#event to Invitee#event_uri
31
37
  - Event#event_type to Event#event_type_uri
32
38
 
33
- # 0.0.4.alpha
39
+ ## 0.0.4.alpha
34
40
 
35
41
  - support APIs
36
42
  - `GET /scheduled_events/{event_uuid}/invitees`
37
43
  - `GET /scheduled_events/{event_uuid}/invitees/{invitee_uuid}`
38
44
 
39
- # 0.0.3.alpha
45
+ ## 0.0.3.alpha
40
46
 
41
47
  - support APIs
42
48
  - `GET /scheduled_events`
43
49
  - `GET /scheduled_events/{uuid}`
44
50
 
45
- # 0.0.2.alpha
51
+ ## 0.0.2.alpha
46
52
 
47
53
  - support APIs
48
54
  - `GET /event_types`
49
55
 
50
- # 0.0.1.alpha
56
+ ## 0.0.1.alpha
51
57
 
52
58
  - Initial release
53
59
  - support APIs
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
3
5
 
4
6
  Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
8
10
  end
9
11
 
10
- task :default => :test
12
+ task default: :test
@@ -25,9 +25,9 @@ module Calendly
25
25
  "\#<#{self.class}:#{object_id} title:#{title}, status:#{status}>"
26
26
  end
27
27
 
28
- private
28
+ private
29
29
 
30
- def set_attributes_from_response
30
+ def set_attributes_from_response # rubocop:disable Metrics/CyclomaticComplexity
31
31
  return unless response
32
32
  return unless response.respond_to? :body
33
33
 
@@ -4,14 +4,15 @@ require 'oauth2'
4
4
 
5
5
  module Calendly
6
6
  # Calendly apis client.
7
- class Client
7
+ class Client # rubocop:disable Metrics/ClassLength
8
+ include Loggable
8
9
  API_HOST = 'https://api.calendly.com'
9
10
  AUTH_API_HOST = 'https://auth.calendly.com'
10
11
 
11
12
  # @param [String] token a Calendly's access token.
13
+ # @raise [Calendly::Error] if the token is empty.
12
14
  def initialize(token = nil)
13
15
  @config = Calendly.configuration
14
- @logger = @config.logger
15
16
  @token = token || Calendly.configuration.token
16
17
 
17
18
  check_not_empty @token, 'token'
@@ -95,7 +96,7 @@ module Calendly
95
96
  check_not_empty user_uri, 'user_uri'
96
97
 
97
98
  opts_keys = %i[count page_token sort]
98
- params = { user: user_uri }
99
+ params = {user: user_uri}
99
100
  params = merge_options opts, opts_keys, params
100
101
  body = request :get, 'event_types', params: params
101
102
 
@@ -140,7 +141,7 @@ module Calendly
140
141
  check_not_empty user_uri, 'user_uri'
141
142
 
142
143
  opts_keys = %i[count invitee_email max_start_time min_start_time page_token sort status]
143
- params = { user: user_uri }
144
+ params = {user: user_uri}
144
145
  params = merge_options opts, opts_keys, params
145
146
  body = request :get, 'scheduled_events', params: params
146
147
 
@@ -227,7 +228,7 @@ module Calendly
227
228
  check_not_empty org_uri, 'org_uri'
228
229
 
229
230
  opts_keys = %i[count email page_token]
230
- params = { organization: org_uri }
231
+ params = {organization: org_uri}
231
232
  params = merge_options opts, opts_keys, params
232
233
  body = request :get, 'organization_memberships', params: params
233
234
 
@@ -254,7 +255,7 @@ module Calendly
254
255
  check_not_empty user_uri, 'user_uri'
255
256
 
256
257
  opts_keys = %i[count email page_token]
257
- params = { user: user_uri }
258
+ params = {user: user_uri}
258
259
  params = merge_options opts, opts_keys, params
259
260
  body = request :get, 'organization_memberships', params: params
260
261
 
@@ -339,7 +340,7 @@ module Calendly
339
340
  body = request(
340
341
  :post,
341
342
  "organizations/#{uuid}/invitations",
342
- body: { email: email }
343
+ body: {email: email}
343
344
  )
344
345
  OrganizationInvitation.new body[:resource], self
345
346
  end
@@ -361,13 +362,7 @@ module Calendly
361
362
  true
362
363
  end
363
364
 
364
- private
365
-
366
- def debug_log(msg)
367
- return unless @logger
368
-
369
- @logger.debug msg
370
- end
365
+ private
371
366
 
372
367
  def request(method, path, params: nil, body: nil)
373
368
  debug_log "Request #{method.to_s.upcase} #{API_HOST}/#{path} params:#{params}, body:#{body}"
@@ -388,7 +383,7 @@ module Calendly
388
383
  end
389
384
 
390
385
  def check_not_empty(value, name)
391
- raise Calendly::Error, "#{name} is required." if blank? value
386
+ raise Calendly::Error.new("#{name} is required.") if blank? value
392
387
  end
393
388
 
394
389
  def blank?(value)
@@ -3,21 +3,15 @@
3
3
  module Calendly
4
4
  # calendly module's base error object
5
5
  class Error < StandardError
6
+ include Loggable
7
+
6
8
  def initialize(message = nil)
7
9
  @logger = Calendly.configuration.logger
8
10
  msg = "#{self.class} occured."
9
11
  msg += " status:#{status}" if respond_to?(:status)
10
12
  msg += " message:#{message}"
11
- log msg
13
+ warn_log msg
12
14
  super message
13
15
  end
14
-
15
- private
16
-
17
- def log(msg, level = :warn)
18
- return if @logger.nil?
19
-
20
- @logger.send level, msg
21
- end
22
16
  end
23
17
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Calendly
4
+ # Calendly logger utility module.
5
+ module Loggable
6
+ def error_log(msg)
7
+ log msg, :error
8
+ end
9
+
10
+ def warn_log(msg)
11
+ log msg, :warn
12
+ end
13
+
14
+ def info_log(msg)
15
+ log msg, :info
16
+ end
17
+
18
+ def debug_log(msg)
19
+ log msg, :debug
20
+ end
21
+
22
+ private
23
+
24
+ def log(msg, level = :info)
25
+ logger = Calendly.configuration.logger
26
+ return unless logger
27
+ return unless logger.respond_to? level
28
+
29
+ logger.send level, msg
30
+ end
31
+ end
32
+ end
@@ -7,7 +7,7 @@ module Calendly
7
7
  include ModelUtils
8
8
  UUID_RE = %r{\A#{Client::API_HOST}/scheduled_events/(\w+)\z}.freeze
9
9
  TIME_FIELDS = %i[start_time end_time created_at updated_at].freeze
10
- ASSOCIATION = { event_type: EventType }.freeze
10
+ ASSOCIATION = {event_type: EventType}.freeze
11
11
 
12
12
  # @return [String]
13
13
  # unique id of the Event object.
@@ -69,8 +69,10 @@ module Calendly
69
69
  # @param [Hash] opts the optional request parameters.
70
70
  # @option opts [Integer] :count Number of rows to return.
71
71
  # @option opts [String] :email Filter by email.
72
- # @option opts [String] :page_token Pass this to get the next portion of collection.
73
- # @option opts [String] :sort Order results by the specified field and directin. Accepts comma-separated list of {field}:{direction} values.
72
+ # @option opts [String] :page_token
73
+ # Pass this to get the next portion of collection.
74
+ # @option opts [String] :sort Order results by the specified field and directin.
75
+ # Accepts comma-separated list of {field}:{direction} values.
74
76
  # @option opts [String] :status Whether the scheduled event is active or canceled.
75
77
  # @return [Array<Calendly::Invitee>]
76
78
  # @raise [Calendly::Error] if the uuid is empty.
@@ -81,7 +83,7 @@ module Calendly
81
83
  auto_pagination request_proc, opts
82
84
  end
83
85
 
84
- private
86
+ private
85
87
 
86
88
  def after_set_attributes(attrs)
87
89
  super attrs
@@ -89,11 +91,12 @@ module Calendly
89
91
  @location = Location.new loc_params if loc_params&.is_a? Hash
90
92
 
91
93
  inv_cnt_attrs = attrs[:invitees_counter]
92
- if inv_cnt_attrs&.is_a? Hash
93
- @invitees_counter_total = inv_cnt_attrs[:total]
94
- @invitees_counter_active = inv_cnt_attrs[:active]
95
- @invitees_counter_limit = inv_cnt_attrs[:limit]
96
- end
94
+ return unless inv_cnt_attrs
95
+ return unless inv_cnt_attrs.is_a? Hash
96
+
97
+ @invitees_counter_total = inv_cnt_attrs[:total]
98
+ @invitees_counter_active = inv_cnt_attrs[:active]
99
+ @invitees_counter_limit = inv_cnt_attrs[:limit]
97
100
  end
98
101
  end
99
102
  end
@@ -72,17 +72,16 @@ module Calendly
72
72
  # Whether the profile belongs to a “User” or a “Team”.
73
73
  attr_accessor :owner_type
74
74
 
75
- private
75
+ private
76
76
 
77
77
  def after_set_attributes(attrs)
78
78
  super attrs
79
- if attrs[:profile]
79
+ return unless attrs[:profile]
80
80
 
81
- @owner_uri = attrs[:profile][:owner]
82
- @owner_uuid = User.extract_uuid owner_uri
83
- @owner_name = attrs[:profile][:name]
84
- @owner_type = attrs[:profile][:type]
85
- end
81
+ @owner_uri = attrs[:profile][:owner]
82
+ @owner_uuid = User.extract_uuid owner_uri
83
+ @owner_name = attrs[:profile][:name]
84
+ @owner_type = attrs[:profile][:type]
86
85
  end
87
86
  end
88
87
  end
@@ -7,7 +7,7 @@ module Calendly
7
7
  include ModelUtils
8
8
  UUID_RE = %r{\A#{Client::API_HOST}/scheduled_events/\w+/invitees/(\w+)\z}.freeze
9
9
  TIME_FIELDS = %i[created_at updated_at].freeze
10
- ASSOCIATION = { event: Event }.freeze
10
+ ASSOCIATION = {event: Event}.freeze
11
11
 
12
12
  # @return [String]
13
13
  # unique id of the Invitee object.
@@ -61,14 +61,12 @@ module Calendly
61
61
  client.event_invitee ev_uuid, uuid
62
62
  end
63
63
 
64
- private
64
+ private
65
65
 
66
66
  def after_set_attributes(attrs)
67
67
  super attrs
68
68
  answers = attrs[:questions_and_answers]
69
- if answers&.is_a? Array
70
- @questions_and_answers = answers.map { |ans| InviteeQuestionAndAnswer.new ans }
71
- end
69
+ @questions_and_answers = answers.map { |ans| InviteeQuestionAndAnswer.new ans } if answers&.is_a? Array
72
70
 
73
71
  trac_attrs = attrs[:tracking]
74
72
  @tracking = InviteeTracking.new trac_attrs if trac_attrs&.is_a? Hash
@@ -19,7 +19,7 @@ module Calendly
19
19
  # @raise [Calendly::Error] if the client is nil.
20
20
  # @since 0.1.0
21
21
  def client
22
- raise Error, '@client is not ready.' if !@client || !@client.is_a?(Client)
22
+ raise Error.new('@client is not ready.') if !@client || !@client.is_a?(Client)
23
23
 
24
24
  @client
25
25
  end
@@ -31,7 +31,7 @@ module Calendly
31
31
  # @raise [Calendly::Error] if uuid is not defined.
32
32
  # @since 0.1.0
33
33
  def id
34
- raise Error, 'uuid is not defined.' unless defined? uuid
34
+ raise Error.new('uuid is not defined.') unless defined? uuid
35
35
 
36
36
  uuid
37
37
  end
@@ -58,9 +58,9 @@ module Calendly
58
58
  base.extend ClassMethods
59
59
  end
60
60
 
61
- private
61
+ private
62
62
 
63
- def set_attributes(attrs)
63
+ def set_attributes(attrs) # rubocop:disable all
64
64
  return if attrs.nil?
65
65
  return unless attrs.is_a? Hash
66
66
  return if attrs.empty?
@@ -69,7 +69,7 @@ module Calendly
69
69
  next unless respond_to? "#{key}=".to_sym
70
70
 
71
71
  if defined?(self.class::ASSOCIATION) && self.class::ASSOCIATION.key?(key)
72
- associated_attrs = value.is_a?(Hash) ? value : { uri: value }
72
+ associated_attrs = value.is_a?(Hash) ? value : {uri: value}
73
73
  value = self.class::ASSOCIATION[key].new associated_attrs, @client
74
74
  elsif defined?(self.class::TIME_FIELDS) && self.class::TIME_FIELDS.include?(key)
75
75
  value = Time.parse value
@@ -36,7 +36,8 @@ module Calendly
36
36
  # @option opts [Integer] :count Number of rows to return.
37
37
  # @option opts [String] :email Filter by email.
38
38
  # @option opts [String] :page_token Pass this to get the next portion of collection.
39
- # @option opts [String] :sort Order results by the specified field and directin. Accepts comma-separated list of {field}:{direction} values.
39
+ # @option opts [String] :sort Order results by the specified field and directin.
40
+ # Accepts comma-separated list of {field}:{direction} values.
40
41
  # @option opts [String] :status Filter by status.
41
42
  # @return [Array<Calendly::OrganizationInvitation>]
42
43
  # @raise [Calendly::Error] if the uuid is empty.
@@ -6,7 +6,7 @@ module Calendly
6
6
  include ModelUtils
7
7
  UUID_RE = %r{\A#{Client::API_HOST}/organizations/\w+/invitations/(\w+)\z}.freeze
8
8
  TIME_FIELDS = %i[created_at updated_at last_sent_at].freeze
9
- ASSOCIATION = { user: User, organization: Organization }.freeze
9
+ ASSOCIATION = {user: User, organization: Organization}.freeze
10
10
 
11
11
  # @return [String]
12
12
  # unique id of the OrganizationInvitation object.
@@ -6,7 +6,7 @@ module Calendly
6
6
  include ModelUtils
7
7
  UUID_RE = %r{\A#{Client::API_HOST}/organization_memberships/(\w+)\z}.freeze
8
8
  TIME_FIELDS = %i[created_at updated_at].freeze
9
- ASSOCIATION = { user: User, organization: Organization }.freeze
9
+ ASSOCIATION = {user: User, organization: Organization}.freeze
10
10
 
11
11
  # @return [String]
12
12
  # unique id of the OrganizationMembership object.
@@ -67,7 +67,8 @@ module Calendly
67
67
  # @param [Hash] opts the optional request parameters.
68
68
  # @option opts [Integer] :count Number of rows to return.
69
69
  # @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.
70
+ # @option opts [String] :sort Order results by the specified field and direction.
71
+ # Accepts comma-separated list of {field}:{direction} values.
71
72
  # @return [Array<Calendly::EventType>]
72
73
  # @raise [Calendly::Error] if the uri is empty.
73
74
  # @raise [Calendly::ApiError] if the api returns error code.
@@ -83,10 +84,11 @@ module Calendly
83
84
  # @param [Hash] opts the optional request parameters.
84
85
  # @option opts [Integer] :count Number of rows to return.
85
86
  # @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.
87
+ # @option opts [String] :max_start_timeUpper bound (inclusive) for an event's start time to filter by.
87
88
  # @option opts [String] :min_start_time Lower bound (inclusive) for an event's start time to filter by.
88
89
  # @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.
90
+ # @option opts [String] :sort Order results by the specified field and directin.
91
+ # Accepts comma-separated list of {field}:{direction} values.
90
92
  # @option opts [String] :status Whether the scheduled event is active or canceled
91
93
  # @return [Array<Calendly::Event>]
92
94
  # @raise [Calendly::Error] if the uri is empty.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Calendly
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
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.1.2
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-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -132,7 +132,7 @@ files:
132
132
  - ".github/workflows/gem-push.yml"
133
133
  - ".github/workflows/test.yml"
134
134
  - ".gitignore"
135
- - ".rubocom.yml"
135
+ - ".rubocop.yml"
136
136
  - CHANGELOG.md
137
137
  - CODE_OF_CONDUCT.md
138
138
  - Gemfile
@@ -147,6 +147,7 @@ files:
147
147
  - lib/calendly/client.rb
148
148
  - lib/calendly/configuration.rb
149
149
  - lib/calendly/error.rb
150
+ - lib/calendly/loggable.rb
150
151
  - lib/calendly/models/event.rb
151
152
  - lib/calendly/models/event_type.rb
152
153
  - lib/calendly/models/invitee.rb
@@ -166,7 +167,7 @@ metadata:
166
167
  homepage_uri: https://github.com/koshilife/calendly-api-ruby-client
167
168
  source_code_uri: https://github.com/koshilife/calendly-api-ruby-client
168
169
  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
170
+ documentation_uri: https://www.rubydoc.info/gems/calendly/0.1.2
170
171
  post_install_message:
171
172
  rdoc_options: []
172
173
  require_paths: