calendly 0.5.0 → 0.8.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +93 -0
- data/README.md +41 -30
- data/lib/calendly/api_error.rb +3 -0
- data/lib/calendly/client.rb +136 -75
- data/lib/calendly/configuration.rb +6 -1
- data/lib/calendly/models/event.rb +44 -31
- data/lib/calendly/models/event_type.rb +76 -21
- data/lib/calendly/models/event_type_custom_question.rb +48 -0
- data/lib/calendly/models/event_type_profile.rb +54 -0
- data/lib/calendly/models/guest.rb +21 -0
- data/lib/calendly/models/invitee.rb +41 -13
- data/lib/calendly/models/invitee_cancellation.rb +17 -0
- data/lib/calendly/models/invitee_payment.rb +28 -0
- data/lib/calendly/models/invitee_question_and_answer.rb +9 -1
- data/lib/calendly/models/invitee_tracking.rb +12 -1
- data/lib/calendly/models/invitees_counter.rb +19 -0
- data/lib/calendly/models/location.rb +10 -0
- data/lib/calendly/models/model_utils.rb +32 -6
- data/lib/calendly/models/organization.rb +75 -48
- data/lib/calendly/models/organization_invitation.rb +6 -0
- data/lib/calendly/models/organization_membership.rb +28 -18
- data/lib/calendly/models/team.rb +20 -0
- data/lib/calendly/models/user.rb +85 -25
- data/lib/calendly/models/webhook_subscription.rb +17 -0
- data/lib/calendly/version.rb +1 -1
- metadata +11 -4
@@ -7,19 +7,24 @@ module Calendly
|
|
7
7
|
class Configuration
|
8
8
|
# @return [String]
|
9
9
|
attr_accessor :client_id
|
10
|
+
|
10
11
|
# @return [String]
|
11
12
|
attr_accessor :client_secret
|
13
|
+
|
12
14
|
# @return [String]
|
13
15
|
attr_accessor :token
|
16
|
+
|
14
17
|
# @return [String]
|
15
18
|
attr_accessor :refresh_token
|
19
|
+
|
16
20
|
# @return [Integer]
|
17
21
|
attr_accessor :token_expires_at
|
22
|
+
|
18
23
|
# @return [Logger]
|
19
24
|
attr_accessor :logger
|
20
25
|
|
21
26
|
def initialize
|
22
|
-
@logger = Logger.new
|
27
|
+
@logger = Logger.new $stdout
|
23
28
|
@logger.level = :warn
|
24
29
|
end
|
25
30
|
end
|
@@ -3,37 +3,52 @@
|
|
3
3
|
require 'calendly/client'
|
4
4
|
require 'calendly/models/model_utils'
|
5
5
|
require 'calendly/models/event_type'
|
6
|
+
require 'calendly/models/guest'
|
7
|
+
require 'calendly/models/invitees_counter'
|
8
|
+
require 'calendly/models/location'
|
6
9
|
|
7
10
|
module Calendly
|
8
11
|
# Calendly's event model.
|
9
|
-
# A meeting that has been scheduled
|
12
|
+
# A meeting that has been scheduled.
|
10
13
|
class Event
|
11
14
|
include ModelUtils
|
12
15
|
UUID_RE = %r{\A#{Client::API_HOST}/scheduled_events/(\w+)\z}.freeze
|
13
16
|
TIME_FIELDS = %i[start_time end_time created_at updated_at].freeze
|
14
|
-
ASSOCIATION = {
|
17
|
+
ASSOCIATION = {
|
18
|
+
event_type: EventType,
|
19
|
+
event_guests: Guest,
|
20
|
+
invitees_counter: InviteesCounter,
|
21
|
+
location: Location
|
22
|
+
}.freeze
|
15
23
|
|
16
24
|
# @return [String]
|
17
25
|
# unique id of the Event object.
|
18
26
|
attr_accessor :uuid
|
27
|
+
|
19
28
|
# @return [String]
|
20
29
|
# Canonical resource reference.
|
21
30
|
attr_accessor :uri
|
31
|
+
|
22
32
|
# @return [String]
|
23
33
|
# Name of the event.
|
24
34
|
attr_accessor :name
|
35
|
+
|
25
36
|
# @return [String]
|
26
37
|
# Whether the event is active or canceled.
|
27
38
|
attr_accessor :status
|
39
|
+
|
28
40
|
# @return [Time]
|
29
41
|
# Moment when event is (or was) scheduled to begin.
|
30
42
|
attr_accessor :start_time
|
43
|
+
|
31
44
|
# @return [Time]
|
32
45
|
# Moment when event is (or was) scheduled to end.
|
33
46
|
attr_accessor :end_time
|
47
|
+
|
34
48
|
# @return [Time]
|
35
49
|
# Moment when user record was first created.
|
36
50
|
attr_accessor :created_at
|
51
|
+
|
37
52
|
# @return [Time]
|
38
53
|
# Moment when user record was last updated.
|
39
54
|
attr_accessor :updated_at
|
@@ -46,15 +61,17 @@ module Calendly
|
|
46
61
|
# location in this event.
|
47
62
|
attr_accessor :location
|
48
63
|
|
49
|
-
# @return [
|
50
|
-
#
|
51
|
-
attr_accessor :
|
52
|
-
|
53
|
-
#
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
64
|
+
# @return [InviteesCounter]
|
65
|
+
# invitees counter.
|
66
|
+
attr_accessor :invitees_counter
|
67
|
+
|
68
|
+
# @return [Array<User>]
|
69
|
+
# Event membership list.
|
70
|
+
attr_accessor :event_memberships
|
71
|
+
|
72
|
+
# @return [Array<Guest>]
|
73
|
+
# Additional people added to an event by an invitee.
|
74
|
+
attr_accessor :event_guests
|
58
75
|
|
59
76
|
#
|
60
77
|
# Get Scheduled Event associated with self.
|
@@ -70,10 +87,10 @@ module Calendly
|
|
70
87
|
#
|
71
88
|
# Returns all Event Invitees associated with self.
|
72
89
|
#
|
73
|
-
# @param [Hash]
|
74
|
-
# @option
|
75
|
-
# @option
|
76
|
-
# @option
|
90
|
+
# @param [Hash] options the optional request parameters. Optional.
|
91
|
+
# @option options [Integer] :count Number of rows to return.
|
92
|
+
# @option options [String] :email Filter by email.
|
93
|
+
# @option options [String] :page_token
|
77
94
|
# Pass this to get the next portion of collection.
|
78
95
|
# @option opts [String] :sort Order results by the specified field and directin.
|
79
96
|
# Accepts comma-separated list of {field}:{direction} values.
|
@@ -82,33 +99,29 @@ module Calendly
|
|
82
99
|
# @raise [Calendly::Error] if the uuid is empty.
|
83
100
|
# @raise [Calendly::ApiError] if the api returns error code.
|
84
101
|
# @since 0.1.0
|
85
|
-
def invitees(
|
86
|
-
return @cached_invitees if @cached_invitees
|
102
|
+
def invitees(options: nil)
|
103
|
+
return @cached_invitees if defined?(@cached_invitees) && @cached_invitees
|
87
104
|
|
88
|
-
request_proc = proc { |
|
89
|
-
@cached_invitees = auto_pagination request_proc,
|
105
|
+
request_proc = proc { |opts| client.event_invitees uuid, options: opts }
|
106
|
+
@cached_invitees = auto_pagination request_proc, options
|
90
107
|
end
|
91
108
|
|
92
109
|
# @since 0.2.0
|
93
|
-
def invitees!(
|
110
|
+
def invitees!(options: nil)
|
94
111
|
@cached_invitees = nil
|
95
|
-
invitees
|
112
|
+
invitees options: options
|
96
113
|
end
|
97
114
|
|
98
115
|
private
|
99
116
|
|
100
117
|
def after_set_attributes(attrs)
|
101
118
|
super attrs
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
@invitees_counter_total = inv_cnt_attrs[:total]
|
110
|
-
@invitees_counter_active = inv_cnt_attrs[:active]
|
111
|
-
@invitees_counter_limit = inv_cnt_attrs[:limit]
|
119
|
+
if event_memberships.is_a? Array # rubocop:disable Style/GuardClause
|
120
|
+
@event_memberships = event_memberships.map do |params|
|
121
|
+
uri = params[:user]
|
122
|
+
User.new({uri: uri}, @client)
|
123
|
+
end
|
124
|
+
end
|
112
125
|
end
|
113
126
|
end
|
114
127
|
end
|
@@ -2,89 +2,144 @@
|
|
2
2
|
|
3
3
|
require 'calendly/client'
|
4
4
|
require 'calendly/models/model_utils'
|
5
|
+
require 'calendly/models/event_type_profile'
|
6
|
+
require 'calendly/models/event_type_custom_question'
|
5
7
|
|
6
8
|
module Calendly
|
7
9
|
# Calendly's event type model.
|
8
|
-
# A configuration for a schedulable event
|
10
|
+
# A configuration for a schedulable event.
|
9
11
|
class EventType
|
10
12
|
include ModelUtils
|
11
13
|
UUID_RE = %r{\A#{Client::API_HOST}/event_types/(\w+)\z}.freeze
|
12
14
|
TIME_FIELDS = %i[created_at updated_at].freeze
|
15
|
+
ASSOCIATION = {profile: EventTypeProfile, custom_questions: EventTypeCustomQuestion}.freeze
|
13
16
|
|
14
17
|
# @return [String]
|
15
18
|
# unique id of the EventType object.
|
16
19
|
attr_accessor :uuid
|
20
|
+
|
17
21
|
# @return [String]
|
18
22
|
# Canonical resource reference.
|
19
23
|
attr_accessor :uri
|
24
|
+
|
20
25
|
# @return [Boolean]
|
21
26
|
# Is this event type currently active?
|
22
27
|
attr_accessor :active
|
28
|
+
|
23
29
|
# @return [String]
|
24
30
|
# The web page styling color for this event type,
|
25
31
|
# expressed as a hexadecimal RGB value (e.g. #fa12e4).
|
26
32
|
attr_accessor :color
|
33
|
+
|
27
34
|
# @return [String]
|
28
35
|
# Longer text description with HTML formatting.
|
29
36
|
attr_accessor :description_html
|
37
|
+
|
30
38
|
# @return [String]
|
31
39
|
# Longer text description in plain text.
|
32
40
|
attr_accessor :description_plain
|
41
|
+
|
33
42
|
# @return [Integer]
|
34
43
|
# Length of event type in minutes.
|
35
44
|
attr_accessor :duration
|
45
|
+
|
36
46
|
# @return [String]
|
37
47
|
# Optional internal note on an event type.
|
38
48
|
attr_accessor :internal_note
|
49
|
+
|
39
50
|
# @return [String]
|
40
51
|
# Whether the event type is “solo” or with a “group”.
|
41
52
|
attr_accessor :kind
|
53
|
+
|
42
54
|
# @return [String]
|
43
55
|
# Human-readable name. Note: some Event Types don't have a name.
|
44
56
|
attr_accessor :name
|
57
|
+
|
45
58
|
# @return [String]
|
46
59
|
# Whether the event type is "round_robin" or "collective".
|
47
60
|
# This value is null if the event type does not pool team members' availability.
|
48
61
|
attr_accessor :pooling_type
|
62
|
+
|
49
63
|
# @return [String]
|
50
64
|
# The full URL of the web page for this event type.
|
51
65
|
attr_accessor :scheduling_url
|
66
|
+
|
52
67
|
# @return [String]
|
53
68
|
# Unique human-readable slug used in page URL.
|
54
69
|
attr_accessor :slug
|
70
|
+
|
55
71
|
# @return [String]
|
56
72
|
# Whether the event type is a “StandardEventType” or an "AdhocEventType”.
|
57
73
|
attr_accessor :type
|
74
|
+
|
75
|
+
# @return [Boolean]
|
76
|
+
# Indicates if the event type is hidden on the owner's main scheduling page.
|
77
|
+
attr_accessor :secret
|
78
|
+
|
58
79
|
# @return [Time]
|
59
80
|
# Moment when event type was eventually created.
|
60
81
|
attr_accessor :created_at
|
82
|
+
|
61
83
|
# @return [Time]
|
62
84
|
# Moment when event type was last updated.
|
63
85
|
attr_accessor :updated_at
|
64
86
|
|
65
|
-
# @return [
|
66
|
-
#
|
67
|
-
attr_accessor :
|
68
|
-
# @return [String]
|
69
|
-
# Reference to the profile owner.
|
70
|
-
attr_accessor :owner_uri
|
71
|
-
# @return [String]
|
72
|
-
# Human-readable name.
|
73
|
-
attr_accessor :owner_name
|
74
|
-
# @return [String]
|
75
|
-
# Whether the profile belongs to a “User” or a “Team”.
|
76
|
-
attr_accessor :owner_type
|
87
|
+
# @return [EventTypeProfile]
|
88
|
+
# The profile of the User that's associated with the Event Type.
|
89
|
+
attr_accessor :profile
|
77
90
|
|
78
|
-
|
91
|
+
# @return [Array<EventTypeCustomQuestion>]
|
92
|
+
# A collection of custom questions.
|
93
|
+
attr_accessor :custom_questions
|
94
|
+
|
95
|
+
# The owner user if the profile belongs to a "user" (individual).
|
96
|
+
# @return [User]
|
97
|
+
# @since 0.6.0
|
98
|
+
def owner_user
|
99
|
+
profile&.owner_user
|
100
|
+
end
|
79
101
|
|
80
|
-
|
81
|
-
|
82
|
-
|
102
|
+
# The owner team if the profile belongs to a "team".
|
103
|
+
# @return [Team]
|
104
|
+
# @since 0.6.0
|
105
|
+
def owner_team
|
106
|
+
profile&.owner_team
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# Get EventType associated with self.
|
111
|
+
#
|
112
|
+
# @return [Calendly::EventType]
|
113
|
+
# @raise [Calendly::Error] if the uuid is empty.
|
114
|
+
# @raise [Calendly::ApiError] if the api returns error code.
|
115
|
+
# @since 0.5.1
|
116
|
+
def fetch
|
117
|
+
client.event_type uuid
|
118
|
+
end
|
119
|
+
|
120
|
+
#
|
121
|
+
# Create an associated scheduling link.
|
122
|
+
#
|
123
|
+
# @param [String] max_event_count The max number of events that can be scheduled using this scheduling link.
|
124
|
+
# @return [Hash]
|
125
|
+
# e.g.
|
126
|
+
# {
|
127
|
+
# booking_url: "https://calendly.com/s/FOO-BAR-SLUG",
|
128
|
+
# owner: "https://api.calendly.com/event_types/GBGBDCAADAEDCRZ2",
|
129
|
+
# owner_type: "EventType"
|
130
|
+
# }
|
131
|
+
# @raise [Calendly::Error] if the uri is empty.
|
132
|
+
# @raise [Calendly::Error] if the max_event_count arg is empty.
|
133
|
+
# @raise [Calendly::ApiError] if the api returns error code.
|
134
|
+
# @since 0.5.2
|
135
|
+
def create_schedule_link(max_event_count: 1)
|
136
|
+
client.create_schedule_link uri, max_event_count: max_event_count, owner_type: 'EventType'
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
83
140
|
|
84
|
-
|
85
|
-
|
86
|
-
@owner_name = attrs[:profile][:name]
|
87
|
-
@owner_type = attrs[:profile][:type]
|
141
|
+
def inspect_attributes
|
142
|
+
super + %i[active kind scheduling_url]
|
88
143
|
end
|
89
144
|
end
|
90
145
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'calendly/models/model_utils'
|
4
|
+
|
5
|
+
module Calendly
|
6
|
+
# Calendly's custom question model.
|
7
|
+
class EventTypeCustomQuestion
|
8
|
+
include ModelUtils
|
9
|
+
|
10
|
+
# @return [String]
|
11
|
+
# The custom question that the host created for the event type.
|
12
|
+
attr_accessor :name
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
# The type of response that the invitee provides to the custom question;
|
16
|
+
# can be one or multiple lines of text, a phone number, or single- or multiple-select.
|
17
|
+
attr_accessor :type
|
18
|
+
|
19
|
+
# @return [Integer]
|
20
|
+
# The numerical position of the question on the event booking page after the name and email address fields.
|
21
|
+
attr_accessor :position
|
22
|
+
|
23
|
+
# @return [Boolean]
|
24
|
+
# true if the question created by the host is turned ON and visible on the event booking page;
|
25
|
+
# false if turned OFF and invisible on the event booking page.
|
26
|
+
attr_accessor :enabled
|
27
|
+
|
28
|
+
# @return [Boolean]
|
29
|
+
# true if a response to the question created by the host is required for invitees to book the event type;
|
30
|
+
# false if not required.
|
31
|
+
attr_accessor :required
|
32
|
+
|
33
|
+
# @return [Array<String>]
|
34
|
+
# The invitee’s option(s) for single_select or multi_select type of responses.
|
35
|
+
attr_accessor :answer_choices
|
36
|
+
|
37
|
+
# @return [Boolean]
|
38
|
+
# true if the custom question lets invitees record a written response in addition to single-select or multiple-select type of responses;
|
39
|
+
# false if it doesn’t.
|
40
|
+
attr_accessor :include_other
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def inspect_attributes
|
45
|
+
super + %i[enabled position]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'calendly/models/model_utils'
|
4
|
+
|
5
|
+
module Calendly
|
6
|
+
# Calendly's event type profile model.
|
7
|
+
class EventTypeProfile
|
8
|
+
include ModelUtils
|
9
|
+
|
10
|
+
# @return [String]
|
11
|
+
# Indicates if the profile belongs to a "user" (individual) or "team"
|
12
|
+
attr_accessor :type
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
# Human-readable name for the profile of the user that's associated with the event type
|
16
|
+
attr_accessor :name
|
17
|
+
|
18
|
+
# @return [String]
|
19
|
+
# The unique reference to the user associated with the profile
|
20
|
+
attr_accessor :owner
|
21
|
+
|
22
|
+
# @return [User]
|
23
|
+
# The owner user if the profile belongs to a "user" (individual).
|
24
|
+
attr_accessor :owner_user
|
25
|
+
|
26
|
+
# @return [Team]
|
27
|
+
# The owner team if the profile belongs to a "team".
|
28
|
+
attr_accessor :owner_team
|
29
|
+
|
30
|
+
# whether type is user or not.
|
31
|
+
# @return [Boolean]
|
32
|
+
# @since 0.6.0
|
33
|
+
def type_user?
|
34
|
+
type&.downcase == 'user'
|
35
|
+
end
|
36
|
+
|
37
|
+
# whether type is team or not.
|
38
|
+
# @return [Boolean]
|
39
|
+
# @since 0.6.0
|
40
|
+
def type_team?
|
41
|
+
type&.downcase == 'team'
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def after_set_attributes(attrs)
|
47
|
+
super attrs
|
48
|
+
if owner # rubocop:disable Style/GuardClause
|
49
|
+
@owner_user = User.new({uri: owner}, @client) if type_user?
|
50
|
+
@owner_team = Team.new({uri: owner}, @client) if type_team?
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'calendly/models/model_utils'
|
4
|
+
|
5
|
+
module Calendly
|
6
|
+
# Calendly's guest model.
|
7
|
+
# Additional people added to an event by an invitee.
|
8
|
+
class Guest
|
9
|
+
include ModelUtils
|
10
|
+
TIME_FIELDS = %i[created_at updated_at].freeze
|
11
|
+
|
12
|
+
# @return [String]
|
13
|
+
attr_accessor :email
|
14
|
+
|
15
|
+
# @return [Time]
|
16
|
+
attr_accessor :created_at
|
17
|
+
|
18
|
+
# @return [Time]
|
19
|
+
attr_accessor :updated_at
|
20
|
+
end
|
21
|
+
end
|